// 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 showqform(ctlName,page,str){

	var xmlHttp = GetXmlHttpObject();

	var url = page+"?"+str+"&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 addblkodr(ctlName,page,str,chkitm,ItmID){

//	alert('Show in '+ctlName+'\n'+page+'\n'+str);

	var xmlHttp = GetXmlHttpObject();

	if (checkempty(chkitm,"Information - Enter Quantity")==false) return false;

	if (checkzero(chkitm,"Information - Enter Quantity Greater then 0")==false) return false;

	if (checkint(chkitm,"Information - Enter Quantity in Digits")==false) return false;

	

	var url = page+"?"+str+"&sid="+Math.random();

//	alert(url);

	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);

	showqform('txtshcart','itmcart.php','ItmID='+ItmID);

}

function GetXmlHttpObject(){ 

var objXMLHttp=null;



     if (window.XMLHttpRequest){

          objXMLHttp=new XMLHttpRequest();

     }else if (window.ActiveXObject){

          objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");

     }

     return objXMLHttp;

}

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.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+"&psize="+document.all.pSize.value+"&pweight="+document.all.pweight.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 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("txtqry").innerHTML=xmlHttp.responseText;

		}

	};

	xmlHttp.open("GET", url, true);

	xmlHttp.send(null);

}

//////////////////////////////////////

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 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.txtMessage,"Information - Enter Your Message")==false) return false;

	return true;

}

function chknlemail(){

	if (test(document.frmNewsletter.txtEmail,"Information - Enter Your Valid Email")==false) return false;

}

function chkcqty(){

	if(document.frmCart.qty.value=="Bulk Order"){

		if(checkempty(document.frmCart.BulkQty,"Information - Enter Bulk Quantity")==false) return false;

		if(checkint(document.frmCart.BulkQty,"Information - Enter Bulk Quantity in Digits")==false) return false;

		if(checkiblkordr(document.frmCart.BulkQty,"Information - Enter Bulk Quantity Minimum 15")==false) return false;

	}

}

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 chkSrchFrm(){
	if (checkempty(document.frmSrch.key,"Information - Enter Search Keywords")==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 Category..:")==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;

}