

// TRIM FUNCTION

function leftTrim(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
return sString;
}

function rightTrim(sString)
{
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


function SecureWords(theValue) {

var myArray = new Array('select','insert','update','delete','*','=','"');

	for (var i=0;i<=myArray.length;i++) {
		theValue = theValue.toLowerCase().replace(myArray[i],'');				
	}	
	
return theValue; 	
}


function MainSearch() {


if (document.searchFrm.slist.value == '') {
	alert('Select a Category...');	
}
else if (trimAll(document.searchFrm.keyword.value) == '') {
	alert('Enter a keyword...');		
	document.searchFrm.keyword.value = '';	
}
else {
	document.searchFrm.keyword.value = SecureWords(document.searchFrm.keyword.value);
	document.searchFrm.submit();	
}	
	
}

function MainSearch_GR() {


if (document.searchFrm.slist.value == '') {
	alert('Επιλέξτε κατηγορία...');	
}
else if (trimAll(document.searchFrm.keyword.value) == '') {
	alert('Εισάγετε λέξη κλειδί...');		
	document.searchFrm.keyword.value = '';	
}
else {
	document.searchFrm.keyword.value = SecureWords(document.searchFrm.keyword.value);
	document.searchFrm.submit();	
}	
	
}

function CatForm() {
	if (document.form1.pricelist.value=='' || document.form1.catid.value=='') {
		alert('You must select both price range and category!');	
	}
	else {
		document.form1.submit();		
	}
}

function CatForm_GR() {
	if (document.form1.pricelist.value=='' || document.form1.catid.value=='') {
		alert('Πρέπει να επιλέξετε εύρος τιμών και κατηγορία!');	
	}
	else {
		document.form1.submit();		
	}
}

function RefreshCatList(MAINCAT_ID,CAT_ID) {
	location.href = 'products.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID;
}

function RefreshCatList_GR(MAINCAT_ID,CAT_ID) {
	location.href = 'products_gr.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID;
}

function RefreshOrderList(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'products.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList_GR(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'products_gr.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList2(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'fp.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList2_GR(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'fp_gr.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList3(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'fp2.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList3_GR(MAINCAT_ID,CAT_ID,ORDERLIST) {
	location.href = 'fp2_gr.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST;
}

function RefreshOrderList4(MAINCAT_ID,CAT_ID,ORDERLIST,KEYWORD) {
	location.href = 'search.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST + '&keyword='+KEYWORD;
}

function RefreshOrderList4_GR(MAINCAT_ID,CAT_ID,ORDERLIST,KEYWORD) {
	location.href = 'search_gr.asp?maincatid=' + MAINCAT_ID + '&catid=' + CAT_ID+ '&orderlist=' + ORDERLIST + '&keyword='+KEYWORD;
}

function AddToBasket(AVAIL,PRODUCT_ID) {
	if (AVAIL == 1) {
		alert('The product is not Available');
	}
	else {
	location.href = 'basket.asp?productid=' + PRODUCT_ID;	
	}
}

function AddToBasket_GR(AVAIL,PRODUCT_ID) {
	if (AVAIL == 1) {
		alert('Το προϊόν δεν είναι διαθέσιμο...');
	}
	else {
	location.href = 'basket_gr.asp?productid=' + PRODUCT_ID;	
	}
}

function ValidateStock(QUANT,STOCK) {
if (QUANT >= STOCK) {
	alert('The maximum available stock for this product is ' + STOCK + ' item(s)');	
}
}

function ValidateStock_GR(QUANT,STOCK) {
if (QUANT >= STOCK) {
	alert('Η μέγιστη διαθεσιμότητα για το προϊόν αυτό είναι ' + STOCK + ' τεμάχιο(α)');	
}
}


function Register() {
	if (trimAll(document.RegFrm.FULLNAME.value)=='' || trimAll(document.RegFrm.TEL.value)=='' || trimAll(document.RegFrm.MOBILE.value)=='' || 
			trimAll(document.RegFrm.EMAIL.value)=='' || trimAll(document.RegFrm.PASSWORD.value)=='' || trimAll(document.RegFrm.PASSWORD2.value)==''	||																																															
			trimAll(document.RegFrm.ADDRESS.value)=='' || trimAll(document.RegFrm.REGION.value)=='' || trimAll(document.RegFrm.CITY.value)=='' || trimAll(document.RegFrm.COUNTRY_ID.value)=='') {
		alert('Please fill in all the required information!');
	}
	else if (document.RegFrm.PASSWORD.value != document.RegFrm.PASSWORD2.value){
		alert('Confirm must be the same to Password');		
	}
	else {
		document.RegFrm.Action.value = 'Register';
		document.RegFrm.submit();		
	}
}

function Register_GR() {
	if (trimAll(document.RegFrm.FULLNAME.value)=='' || trimAll(document.RegFrm.TEL.value)=='' || trimAll(document.RegFrm.MOBILE.value)=='' || 
			trimAll(document.RegFrm.EMAIL.value)=='' || trimAll(document.RegFrm.PASSWORD.value)=='' || trimAll(document.RegFrm.PASSWORD2.value)==''	||																																															
			trimAll(document.RegFrm.ADDRESS.value)=='' || trimAll(document.RegFrm.REGION.value)=='' || trimAll(document.RegFrm.CITY.value)=='' || trimAll(document.RegFrm.COUNTRY_ID.value)=='') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');
	}
	else if (document.RegFrm.PASSWORD.value != document.RegFrm.PASSWORD2.value){
		alert('Η επιβεβαίωση κωδικού πρέπει να είναι ίδια με τον κωδικό');		
	}
	else {
		document.RegFrm.Action.value = 'Register';
		document.RegFrm.submit();		
	}
}

function Update() {
	if (trimAll(document.RegFrm.FULLNAME.value)=='' || trimAll(document.RegFrm.TEL.value)=='' || trimAll(document.RegFrm.MOBILE.value)=='' || 
			trimAll(document.RegFrm.EMAIL.value)=='' || trimAll(document.RegFrm.PASSWORD.value)=='' || trimAll(document.RegFrm.PASSWORD2.value)==''	||																																															
			trimAll(document.RegFrm.ADDRESS.value)=='' || trimAll(document.RegFrm.REGION.value)=='' || trimAll(document.RegFrm.CITY.value)=='' || trimAll(document.RegFrm.COUNTRY_ID.value)=='') {
		alert('Please fill in all the required information!');
	}
	else if (document.RegFrm.PASSWORD.value != document.RegFrm.PASSWORD2.value){
		alert('Confirm must be the same to Password');		
	}
	else {
		document.RegFrm.Action.value = 'Update';
		document.RegFrm.submit();		
	}
}

function Update_GR() {
	if (trimAll(document.RegFrm.FULLNAME.value)=='' || trimAll(document.RegFrm.TEL.value)=='' || trimAll(document.RegFrm.MOBILE.value)=='' || 
			trimAll(document.RegFrm.EMAIL.value)=='' || trimAll(document.RegFrm.PASSWORD.value)=='' || trimAll(document.RegFrm.PASSWORD2.value)==''	||																																															
			trimAll(document.RegFrm.ADDRESS.value)=='' || trimAll(document.RegFrm.REGION.value)=='' || trimAll(document.RegFrm.CITY.value)=='' || trimAll(document.RegFrm.COUNTRY_ID.value)=='') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');
	}
	else if (document.RegFrm.PASSWORD.value != document.RegFrm.PASSWORD2.value){
		alert('Η επιβεβαίωση κωδικού πρέπει να είναι ίδια με τον κωδικό');		
	}
	else {
		document.RegFrm.Action.value = 'Update';
		document.RegFrm.submit();		
	}
}

function Update2() {
	if (trimAll(document.Frm1.FULLNAME1.value)=='' || trimAll(document.Frm1.TEL1.value)=='' || trimAll(document.Frm1.MOBILE1.value)=='' || 
			trimAll(document.Frm1.EMAIL1.value)=='' ||																																															
			trimAll(document.Frm1.ADDRESS1.value)=='' || trimAll(document.Frm1.REGION1.value)=='' || trimAll(document.Frm1.CITY1.value)=='' || trimAll(document.Frm1.COUNTRY_ID1.value)=='') {
		alert('Please fill in all the required information!');
	}
	else {
		document.Frm1.Action1.value = 'Update';
		document.Frm1.submit();		
	}
}

function Update2_GR() {
	if (trimAll(document.Frm1.FULLNAME1.value)=='' || trimAll(document.Frm1.TEL1.value)=='' || trimAll(document.Frm1.MOBILE1.value)=='' || 
			trimAll(document.Frm1.EMAIL1.value)=='' ||																																															
			trimAll(document.Frm1.ADDRESS1.value)=='' || trimAll(document.Frm1.REGION1.value)=='' || trimAll(document.Frm1.CITY1.value)=='' || trimAll(document.Frm1.COUNTRY_ID1.value)=='') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');
	}
	else {
		document.Frm1.Action1.value = 'Update';
		document.Frm1.submit();		
	}
}

function Update3() {
	if (trimAll(document.Frm2.FULLNAME2.value)=='' || trimAll(document.Frm2.TEL2.value)=='' || trimAll(document.Frm2.MOBILE2.value)=='' || 
			trimAll(document.Frm2.EMAIL2.value)=='' ||																																														
			trimAll(document.Frm2.ADDRESS2.value)=='' || trimAll(document.Frm2.REGION2.value)=='' || trimAll(document.Frm2.CITY2.value)=='' || trimAll(document.Frm2.COUNTRY_ID2.value)=='') {
		alert('Please fill in all the required information!');
	}
	else {
		document.Frm2.Action2.value = 'Update';
		document.Frm2.submit();		
	}
}

function Update3_GR() {
	if (trimAll(document.Frm2.FULLNAME2.value)=='' || trimAll(document.Frm2.TEL2.value)=='' || trimAll(document.Frm2.MOBILE2.value)=='' || 
			trimAll(document.Frm2.EMAIL2.value)=='' ||																																														
			trimAll(document.Frm2.ADDRESS2.value)=='' || trimAll(document.Frm2.REGION2.value)=='' || trimAll(document.Frm2.CITY2.value)=='' || trimAll(document.Frm2.COUNTRY_ID2.value)=='') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');
	}
	else {
		document.Frm2.Action2.value = 'Update';
		document.Frm2.submit();		
	}
}

function Login() {
	if (trimAll(document.Frm.EMAIL.value)=='' || trimAll(document.Frm.PASSWORD.value)=='' ) {
		alert('Please fill in all the required information!');

	}
	else {
		document.Frm.Action.value = 'Login';
		document.Frm.submit();		
	}
}

function Login_GR() {
	if (trimAll(document.Frm.EMAIL.value)=='' || trimAll(document.Frm.PASSWORD.value)=='' ) {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');

	}
	else {
		document.Frm.Action.value = 'Login';
		document.Frm.submit();		
	}
}

function Recover() {
	if (trimAll(document.Frm.EMAIL2.value)=='') {
		alert('Please fill in all the required information!');
	}
	else {
		document.Frm.Action.value = 'Recover';
		document.Frm.submit();		
	}
}

function Recover_GR() {
	if (trimAll(document.Frm.EMAIL2.value)=='') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');
	}
	else {
		document.Frm.Action.value = 'Recover';
		document.Frm.submit();		
	}
}

function Contact() {
	if (trimAll(document.frm.FULLNAME.value) == '' || trimAll(document.frm.TEL.value) == '' || trimAll(document.frm.EMAIL.value) == '' || trimAll(document.frm.COMMENTS.value) == '') {
		alert('Please fill in all the information!');	
	}
	else {
		document.frm.Action.value = 'Contact';
		document.frm.submit();
	}	
}

function Contact_GR() {
	if (trimAll(document.frm.FULLNAME.value) == '' || trimAll(document.frm.TEL.value) == '' || trimAll(document.frm.EMAIL.value) == '' || trimAll(document.frm.COMMENTS.value) == '') {
		alert('Συμπληρώστε όλες τις απαραίτητες πληροφορίες!');	
	}
	else {
		document.frm.Action.value = 'Contact';
		document.frm.submit();
	}	
}

function UnNewslet() {
	if (trimAll(document.frm.EMAIL.value) == '') {
		alert('Please fill in your Email!');	
	}
	else {
		document.frm.Action.value = 'Unsubscribe';
		document.frm.submit();
	}	
}

function UnNewslet_GR() {
	if (trimAll(document.frm.EMAIL.value) == '') {
		alert('Συμπληρώστε το Email σας!');	
	}
	else {
		document.frm.Action.value = 'Unsubscribe';
		document.frm.submit();
	}	
}

function Newslet() {
	if (trimAll(document.frm.EMAIL.value) == '') {
		alert('Please fill in your Email!');	
	}
	else {
		document.frm.Action.value = 'Newslet';
		document.frm.submit();
	}	
}

function Newslet_GR() {
	if (trimAll(document.frm.EMAIL.value) == '') {
		alert('Συμπληρώστε το Email σας!');	
	}
	else {
		document.frm.Action.value = 'Newslet';
		document.frm.submit();
	}	
}