// 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 isnumber(obj,msg)
	{
	 if(isNaN(obj.value))
	 {
	  alert(msg);
	  obj.select();
	  return false;
	 }
	}
	
	function isAmt(obj,msg)
	{
	 if(obj.value<5)
	 {
	  alert(msg);
	  obj.select();
	  return false;
	 }
	}	
	
	function notZero(obj,msg)
	{

	 if(obj.value=="0")
	 {
	  alert(msg);
	  obj.focus();
	  return false;
	 }
	}
	function checkint(obj,msg)
	{
	 if(isNaN(obj.value))
	 {
	  alert(msg);
	  obj.focus();
	  return false;
	 }
	}
	function checkImei(obj,msg)
	{
	 if(obj.value.length<15)
	 {
	  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 checkempty1(obj,msg)
	{
	 if(obj.value=="")
	 {
	  alert(msg);
	  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 chktransfer()
	{
		if (test(document.frmOrder.usr,"Information - Enter Username to whom you want to transfer credits")==false) return false;
		if (checkempty(document.frmOrder.Cr2Transfer,"Information - Enter Number of Credits")==false) return false;
		if (checkint(document.frmOrder.Cr2Transfer,"Information - Enter Number of Credits in numbers format")==false) return false;
		if (checkzero(document.frmOrder.Cr2Transfer,"Information - Enter Number of Credits greater then Zero")==false) return false;
		if(document.frmOrder.hdnCr2Transfer.value<document.frmOrder.Cr2Transfer.value){
			alert("Information - You dont have sufficient credits to transfer");
			return false;
		}
		return true;
	}
	function chktrack()
	{
		if (checkempty(document.frmtrack.Imei,"Information - Enter Imei")==false) return false;
		if (checkint(document.frmtrack.Imei,"Information - Enter Imei in Numbers")==false) return false;
		if (checkImei(document.frmtrack.Imei,"Information - Enter 15 digit Imei")==false) return false;
		return true;
	}

	function checksrchForm()
	{
		if (checkempty(document.frmsrch.key,"Search Information - Enter Search Key Word(s)")==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.cState,"Account Registration :.. Select Reseller..:")==false) return false;
		if (checkempty(document.frmOrder.ZCode,"Account Registration :.. Enter SN No of The Box..:")==false) return false;
		if (checkempty(document.frmOrder.country,"Account Registration :.. Select Country..:")==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.cState,"Account Information :.. Select Reseller..:")==false) return false;
		if (checkempty(document.frmOrder.ZCode,"Account Information :.. Enter SN No of The Box..:")==false) return false;
		if (checkempty(document.frmOrder.country,"Account Information :.. Select Country..:")==false) return false;
		return true;
	}
	function chkLogin()
	{
		if (test(document.frmLogin.user,"Login - Enter Email As User Name.")==false) return false;
		if (checkempty(document.frmLogin.pass,"Login - Enter Password")==false) return false;		
		return true;
	}
	function chkLogin2()
	{
		if (test(document.frmLogin2.user,"Login - Enter Email As User Name.")==false) return false;
		if (checkempty(document.frmLogin2.pass,"Login - Enter Password")==false) return false;		
		return true;
	}
	function chkforget()
	{
		if (test(document.frmLogin2.user,"Login - Enter Email As User Name.")==false) return false;		
		return true;
	}
	function checkfForm()
	{
		if (checkempty(document.frmfeed.name,"Contact Information - Enter Name")==false) return false;
		if (test(document.frmfeed.email,"Contact Information - Email Address Is Required")==false) return false;
//		if (checkempty(document.frmfeed.comments,"Contact Information - Enter Comments")==false) return false;
		return true;
	}
	function checkinq()
	{
		if (checkempty(document.oinq.cPerson,"Contact Information - Enter Name")==false) return false;
		if (checkempty(document.oinq.Comp,"Contact Information - Enter Company Name")==false) return false;
		if (checkempty(document.oinq.Tel,"Contact Information - Enter Phone Number")==false) return false;
		if (checkempty(document.oinq.Fax,"Contact Information - Enter Fax Number")==false) return false;
		if (test(document.oinq.email,"Contact Information - Email Address Is Required")==false) return false;
		if (checkempty(document.oinq.Address,"Contact Information - Enter Address")==false) return false;
		return true;
	}
	function checkIForm()
	{
		if (checkempty(document.frmInq.FullName,"Information - Enter your Full Name")==false) return false;
		if (test(document.frmInq.Email,"Information - Enter your Email in  correct format")==false) return false;
		if (checkempty(document.frmInq.Phone,"Information - Enter your Phone")==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";
}