function changeLanguage(lang){
	langForm.l.value = lang;
	langForm.submit();
}

function changeDivStatus(divID,statusValue){
	document.getElementById(divID).style.display = statusValue;
}

function forgetPasswd(){
	window.open('forgetPassword.php','forgetWindows','width=400,height=300');
}

function trim(stringToTrim) { 
	return stringToTrim.replace(/^\s+|\s+$/g,"");
} 

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}

function enquiryProduct(productIDArray){
	var choosedID = new Array();
	var notChoosedID = new Array();
	
	for ( productID in productIDArray ) {
   		if(productIDArray[productID])
   			choosedID[choosedID.length] = productID;
   		else
   			notChoosedID[notChoosedID.length] = productID;
	}
	
	url = "enquiryList.php?choosedID=" + choosedID.join(',') + "&notChoosedID=" + notChoosedID.join(',');
	
	properties = "width=350,height=180,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes";
	enquiryListWindow = window.open(url, "enquiry_list" , properties, "false");
	
	enquiryListWindow.focus();
}

function shoppingCart(productIDArray){
	var choosedID = new Array();
	var notChoosedID = new Array();
	
	for ( productID in productIDArray ) {
   		if(productIDArray[productID])
   			choosedID[choosedID.length] = productID;
   		else
   			notChoosedID[notChoosedID.length] = productID;
	}
	
	url = "shoppingCartList.php?choosedID=" + choosedID.join(',') + "&notChoosedID=" + notChoosedID.join(',');
	
	properties = "width=350,height=180,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes";
	shoppingCartListWindow = window.open(url, "enquiry_list" , properties, "false");
	
	shoppingCartListWindow.focus();
}

function check_validate(error_msg){
		if(document.login_form.username.value!="" && document.login_form.password.value!="")
			document.login_form.password.value = hex_md5(document.login_form.password.value);
		else{
			alert(error_msg);
			return false;
		}
}
