// JavaScript Document
var isSel=false;
var istc=false;
	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 chkPass(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 confirmPassword(obj,obj1,msg)
	{
	 if(!(obj.value==obj1.value))
	 {
	  alert(msg);
	  obj.focus();
	  return false;
	 }
	}
	function checkinqform(){
     var theform = document.form1;
     var atleastone=false;
     for(var i=0;i<theform.elements.length;i++)
     {
          if(theform.elements[i].name=="pid" && theform.elements[i].checked)
          {
               atleastone=true;
          }
     }
     if(atleastone)
     {
          theform.submit();
     }
     else
     {
          alert("SELECT AT-LEAST One Check Box!");
		  return false;
     }
	}
	
	function selectall(){
     var theform = document.frmCart;
     var atleastone=false;
     for(var i=0;i < theform.elements.length;i++){
          if(theform.elements[i].name=="pid")
          {
		  		theform.elements[i].checked = true;
               atleastone=true;
          }
     }
	}
	function chkPqty(frm){
		if (checkempty(frm,"Information - Enter Quantity")==false) return false;
		if (checkzero(frm,"Information - Enter Quantity greater than zero")==false) return false;
		if (checkint(frm,"Information - Enter Quantity in Digits")==false) return false;
		return true;
	}
	function chkpdqty(){
		if (checkempty(document.frmPDCart.qty,"Information - Enter Quantity")==false) return false;
		if (checkzero(document.frmPDCart.qty,"Information - Enter Quantity greater than zero")==false) return false;
		if (checkint(document.frmPDCart.qty,"Information - Enter Quantity in Digits")==false) return false;
		return true;
	}
	function chknletter()
	{
		if (test(document.frmNewsletter.txtEmail,"Information - Enter your valid email")==false) return false;
		return true;
	}
	function chkrnletter()
	{
		if (test(document.frmrNewsletter.txtEmail,"Information - Enter your valid email")==false) return false;
		return true;
	}
	function chksrch()
	{
		if (checkempty(document.frmsrch.key,"Information - Enter Search keywords")==false) 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 (checkempty(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 openWin(pagename){
		microsite_window=window.open(pagename,'microsite_window','toolbar=no,location=no,borders=no,directories=no,status=no,menubar=no,scrollbars=yes,top=0,left=0,resizable=no,width=710,height=520')
	}
		function listChange(i,obj,qty1,qty2){
//		alert(document.getElementById("qtyFor"+i).value);
		if (obj=="b"){
			document.getElementById("crrQty"+i).value = document.getElementById("q_box"+i).value;
			calculatePrice(i,document.getElementById("q_box"+i).value,document.getElementById("qtyFor"+i).value);
		}else if (obj=="c"){
			document.getElementById("crrQty"+i).value = document.getElementById("q_crtn"+i).value;
			calculatePrice(i,document.getElementById("q_crtn"+i).value,document.getElementById("qtyFor"+i).value);		
		}		
	}
	function radio(i,obj){
		if (obj=="b"){
			document.getElementById("Qty"+i).disabled=false;
			document.getElementById("Q_ty"+i).disabled=true;
		}else if (obj=="c"){
			document.getElementById("Qty"+i).disabled=true;
			document.getElementById("Q_ty"+i).disabled=false;			
		}
	}
///////////////////////////////////////
function calculatePrice(i,qty,obj){
		//alert(qty);
		if (obj=="c"){
			if (!( isNaN(i) || isNaN (qty) )){
				document.getElementById("Qty1"+i).value=document.getElementById("Q_ty"+i).value * qty;
				document.getElementById("Qty2"+i).value=document.getElementById("Q_ty"+i).value * qty;
				document.getElementById("price"+i).value = document.getElementById("pricePercartoon"+i).value;				
				document.getElementById("total"+i).value=document.getElementById("Qty2"+i).value * document.getElementById("pricePercartoon"+i).value;
			}
		}else if (obj=="b")
			{
				if (!( isNaN(i) || isNaN (qty) )){
					document.getElementById("Qty1"+i).value=document.getElementById("Qty"+i).value * qty;
					document.getElementById("Qty2"+i).value=document.getElementById("Qty"+i).value * qty;
					document.getElementById("price"+i).value = document.getElementById("pricePerbox"+i).value;
					document.getElementById("total"+i).value=document.getElementById("Qty2"+i).value * document.getElementById("pricePerbox"+i).value;
				}
			}
	}
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);
	
}
function submitForm(f)
{
	document.f.textfield.value="aa";
}
//////////////////////////////////////
function GetXmlHttpObject(){ 
var objXMLHttp=null;

     if (window.XMLHttpRequest){
          objXMLHttp=new XMLHttpRequest();
     }else if (window.ActiveXObject){
          objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     return objXMLHttp;
}
//////////////////////////////////////     
var xmlHttp
function showqform(ctlName,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+"&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 chkcbn(){
	var xmlHttp = GetXmlHttpObject();
	if (checkempty(document.all.urcbName,"Information - Enter Your Name")==false) return false;
	if (test(document.all.urcbEmail,"Information - Enter Your Email")==false) return false;
	if (checkempty(document.all.urcbNumber,"Information - Enter Your Number")==false) return false;
	var url = "sendcbn.php?urcbName="+document.all.urcbName.value+"&urcbEmail="+document.all.urcbEmail.value+"&urcbNumber="+document.all.urcbNumber.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("txtcallback").innerHTML=xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
//////////////////////////////////////
