// JavaScript Document
function openWin(pagename){
		microsite_window=window.open(pagename,'microsite_window','toolbar=no,location=no,borders=no,directories=no,status=no,menubar=no,scrollbars=no,top=0,left=0,resizable=no,width=10,height=10')
}
	
function openWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = "height="+h+", width="+w+", top="+wint+", left="+winl+", scrollbars="+scroll+", resizable=no";
	window.open(mypage, "CurencyConverter", winprops);
}

//////////////////////////////////////     
var xmlHttp
function showpage(ctlName,page){
//	alert(ctlName+"\n"+page);
	var xmlHttp = GetXmlHttpObject();
	var url = page+"&sid="+Math.random();
	if (!xmlHttp){
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById(ctlName).innerHTML=xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function chkreffer(){
	var xmlHttp = GetXmlHttpObject();
	if (checkempty(document.all.urName,"Information - Enter Your Name")==false) return false;
	if (test(document.all.urEmail,"Information - Enter Your Valid Email")==false) return false;
	if (checkempty(document.all.frName,"Information - Enter Your Friends Name")==false) return false;
	if (test(document.all.frEmail,"Information - Enter Your Friends Email")==false) return false;
	var url = "sendrefer.php?urName="+document.all.urName.value+"&urEmail="+document.all.urEmail.value+"&frName="+document.all.frName.value+"&frEmail="+document.all.frEmail.value+"&IDZ="+document.all.IDZ.value+"&sid="+Math.random();
	
	if (!xmlHttp){
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById("txtref").innerHTML=xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function chkqInq(){
	var xmlHttp = GetXmlHttpObject();
	if (checkempty(document.all.txtFirstname,"Information - Enter Your Name")==false) return false;
	if (checkempty(document.all.cCompany,"Information - Enter Your Company Name")==false) return false;
	if (test(document.all.ctxtEmail,"Information - Enter Your Email")==false) return false;
	if (checkempty(document.all.country,"Information - Select Country")==false) return false;
	if (checkempty(document.all.txtMessage,"Information - Enter Your Message")==false) return false;
	var url = "sqry.php?txtFirstname="+document.all.txtFirstname.value+"&cCompany="+document.all.cCompany.value+"&txtPhone="+document.all.txtPhone.value+"&ctxtEmail="+document.all.ctxtEmail.value+"&country="+document.all.country.value+"&Address="+document.all.Address.value+"&txtMessage="+document.all.txtMessage.value+"&ItmID="+document.all.product_id.value+"&sid="+Math.random();
	
	if (!xmlHttp){
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById("txtqry").innerHTML=xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function GetXmlHttpObject(){ 
var objXMLHttp=null;

     if (window.XMLHttpRequest){
          objXMLHttp=new XMLHttpRequest();
     }else if (window.ActiveXObject){
          objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     return objXMLHttp;
}
//////////////////////////////////////
function test(obj,msg){
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (regex.test(obj.value)){
		return true;
	}else{
		alert(msg);
		obj.focus();
		return false;
	}
}

function checkint(obj,msg){
	if(isNaN(obj.value)){
		alert(msg);
		obj.focus();
		return false;
	}
}
	
function confirmPassword(obj,obj1,msg){
	if(obj.value!=obj1.value){
		alert(msg);
		obj.focus();
		return false;
	}
}

function checkempty(obj,msg){
	if(obj.value==""){
		alert(msg);
		obj.focus();
		return false;
	}
}
function checkzero(obj,msg){
	if(obj.value==0){
		alert(msg);
		obj.focus();
		return false;
	}
}
function checkiblkordr(obj,msg){
	if(obj.value<0){
		alert(msg);
		obj.focus();
		return false;
	}
}
/////////////////////////////////////////////////////////
function chknlemail(){
	if (test(document.frmNewsletter.txtEmail,"Information - Enter Your Valid Email")==false) return false;
}
function chksrch(){
	if(document.frmsrch.key.value=='Enter Key Word(s)'){
		alert("Enter Search Keyword(s)");
		document.frmsrch.key.value='';
		document.frmsrch.key.focus();
		return false;
	}
	if (checkempty(document.frmsrch.key,"Information - Enter Search Keyword(s)")==false) return false;
}
function IsNumeric(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++){
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1){
		 blnResult = false;
		}
	}
	return blnResult;
}
function validate(f){
	if(f.textfield.value==""){
		alert("Please fill the card holder name");
		f.textfield.focus();
		return false;
	}else if(!IsNumeric(f.textfield2.value)){
		alert("Please fill Numeric");
		f.textfield2.focus();
		return false;
	}else if((f.textfield2.value).length!=16){
		alert("Please fill 16 Digits");
		f.textfield2.focus();
		return false;
	}else if(!IsNumeric(f.textfield3.value)){
		alert("Please fill Numeric");
		f.textfield3.focus();
		return false;
	}else if((f.textfield3.value).length!=3){
		alert("Please fill 3 Digits");
		f.textfield3.focus();
		return false;
	}else if(!IsNumeric(f.textfield4.value)){
		alert("Please fill Numeric");
		f.textfield4.focus();
		return false;
	}
	return true;
}
function chkInq(){
	if (checkempty(document.frmSend.txtFirstname,"Information - Enter Your Name")==false) return false;
	if (checkempty(document.frmSend.cCompany,"Information - Enter Your Company Name")==false) return false;
	if (test(document.frmSend.ctxtEmail,"Information - Enter Your Email")==false) return false;
	if (checkempty(document.frmSend.country,"Information - Select Your Country")==false) return false;
	if (checkempty(document.frmSend.txtMessage,"Information - Enter Your Message")==false) return false;
	return true;
}
function chkLogin(){
	if (test(document.frmLogin.user,"Information - Enter Your Username")==false) return false;
	if (checkempty(document.frmLogin.pass,"Information - Enter Your Password")==false) return false;
	return true;
}
function chkLogin2(){
	if (test(document.frmLogin2.user,"Information - Enter Your Username")==false) return false;
	if (checkempty(document.frmLogin2.pass,"Information - Enter Your Password")==false) return false;
	return true;
}
function CheckRegUser(){
	if (test(document.frmOrder.Email,"Account Registration :.. Enter User's Email..:")==false) return false;
	if (checkempty(document.frmOrder.password,"Account Registration :.. Enter User's Password..:")==false) return false;
	if (confirmPassword(document.frmOrder.password,document.frmOrder.repassword,"Account Registration :.. Password & Confirm Password Fields must be same..:")==false) return false;
	if (checkempty(document.frmOrder.FName,"Account Registration :.. Enter User Full Name..:")==false) return false;
	if (checkempty(document.frmOrder.cAddress,"Account Registration :.. Enter Address..:")==false) return false;
	if (checkempty(document.frmOrder.country,"Account Registration :.. Select Country..:")==false) return false;
	if (checkempty(document.frmOrder.cdayph,"Account Registration :.. Enter Phone Number..:")==false) return false;
	if (checkempty(document.frmOrder.uGrp,"Account Registration :.. Select Account Type..:")==false) return false;
	return true;
}
function CheckeRegUser(){
	if (checkempty(document.frmOrder.password,"Account Information :.. Enter User's Password..:")==false) return false;
	if (confirmPassword(document.frmOrder.password,document.frmOrder.repassword,"Account Information :.. Password & Confirm Password Fields must be same..:")==false) return false;
	if (checkempty(document.frmOrder.FName,"Account Information :.. Enter User Full Name..:")==false) return false;
	if (checkempty(document.frmOrder.cAddress,"Account Information :.. Enter Address..:")==false) return false;
	if (checkempty(document.frmOrder.country,"Account Information :.. Select Country..:")==false) return false;
	if (checkempty(document.frmOrder.cdayph,"Account Registration :.. Enter Phone Number..:")==false) return false;
	return true;
}
function chkforget(){
	if (test(document.frmLogin2.user,"Login - Enter Email As User Name.")==false) return false;		
	return true;
}