﻿// JScript File

	
function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal)
	{
	     re = new RegExp(':' + aspCheckBoxID + '$')
	          //generated control name starts with a colon
        if (aspCheckBoxID != null)
			{
				for(i = 1; i <  document.form1.elements.length; i++)
				{
					var elm =  document.form1.elements[i]
					if (elm.type == 'checkbox')
						{
						 	if (re.toString(elm.name))
								{
								elm.checked = checkVal
								}
						}
				}
			}
    }
    function numberValid(strObj)
{       
	var len=strObj.value.length;
	if(strObj.value.length==0){
	alert("The Quantity value should not be empty");
	strObj.focus();
	return false;
	}
	
	numVal="0123456789";
	for(i=0;i<len;i++)
	{	if(numVal.indexOf(strObj.value.charAt(i))==-1)
		{
			alert("The Quantity value should be in number format");
			strObj.focus();
			return false;
		}
		else if(numVal.indexOf(strObj.value.charAt(0))== 0)
		{
			alert("The Quantity value should not be 0");
			strObj.focus();
			return false;
		}
	}
	return true;
}
function rollbg(chosen, objectID) {
if(chosen == "roll") {
document.getElementById(objectID).className="roll";
}
else {
document.getElementById(objectID).className="over";
}
}


function ShowHideMenu(GetKey,MenuTop,MenuLeft,objectID){
		if (GetKey == "Hide"){
			document.getElementById(objectID).style.display="none";
		}
		else{
			if (MenuTop != '0px' && MenuLeft != '0px'){
				document.getElementById(objectID).style.top=MenuTop;
				document.getElementById(objectID).style.left=MenuLeft;
			}
				document.getElementById(objectID).style.display="";
		}
	}
	var WindowObjectReference = null; // global variable

function openRequestedPopup(strUrl, strWindowName)
{
  if(WindowObjectReference == null || WindowObjectReference.closed)
  {
  WindowObjectReference = window.open(strUrl, strWindowName, "menubar=No,resizable=yes,scrollbars=yes,status=yes,fullscreen=yes");
  }
  else
  {
   WindowObjectReference.focus();
 };
}

function openEcardPopup(strUrl, strWindowName)
{
  if(WindowObjectReference == null || WindowObjectReference.closed)
  {
  WindowObjectReference = window.open(strUrl, strWindowName, "menubar=No,resizable=No,scrollbars=No,status=yes,fullscreen=No,width=380,height=520");
  }
  else
  {
   WindowObjectReference.focus();
 };
}
function phonenumberValid(strObj)
{       
	var len=strObj.value.length;
	numVal="0123456789(-)";
	for(i=0;i<len;i++)
	{	if(numVal.indexOf(strObj.value.charAt(i))==-1)
		{
			alert("The Phone Number value should be in number format");
			strObj.focus();
			return false;
		}
		
	}
	return true;
}

function taxcalculate(Objdd)
  {
      var shipState=document.getElementById("ctl33_cboState").options[document.getElementById("ctl33_cboState").options.selectedIndex].text;
      document.getElementById("ctl33_hdnshipstate").value =shipState
     var subtotal = document.getElementById("ctl33_hdnsubtotal").value;
     var tax = document.getElementById("ctl33_hdntax").value;
     var state=Objdd.options[Objdd.options.selectedIndex].text;
      total=parseFloat(tax) + parseFloat(subtotal);
      if(state=="NC")
      {
      document.getElementById("ctl33_txttotalpurchaseprice").value="$"+total;
      document.getElementById("ctl33_txttax").value="$"+tax;
      document.getElementById("ctl33_txttaxtext").value="Sales Tax :";
      }
      else
      {
      document.getElementById("ctl33_txttax").value="";
      document.getElementById("ctl33_txttaxtext").value="";
      document.getElementById("ctl33_txttotalpurchaseprice").value="$"+subtotal;
      }
   }
      
   function copyshipping(Objchk)
  {
 
     if (Objchk.checked){
      document.getElementById("ctl33_txtShippingFName").value=document.getElementById("ctl33_txtFName").value;
     document.getElementById("ctl33_txtShippingLName").value=document.getElementById("ctl33_txtLName").value;
      document.getElementById("ctl33_txtShippingAddress").value=document.getElementById("ctl33_txtAddress").value;
      document.getElementById("ctl33_txtShippingCity").value=document.getElementById("ctl33_txtCity").value;
      document.getElementById("ctl33_txtShippingZipcode").value=document.getElementById("ctl33_txtZipCode").value;
      document.getElementById("ctl33_txtShippingPNumber").value=document.getElementById("ctl33_txtPhoneNumber").value;
      document.getElementById("ctl33_cboShippingState").options[document.getElementById("ctl33_cboShippingState").options.selectedIndex].text=document.getElementById("ctl33_cboState").options[document.getElementById("ctl33_cboState").options.selectedIndex].text;
      var shipState=document.getElementById("ctl33_cboShippingState").options[document.getElementById("ctl33_cboShippingState").options.selectedIndex].text;
      document.getElementById("ctl33_hdnshipstate").value =shipState
       }
      else
      {
      document.getElementById("ctl33_txtShippingFName").value="";
      document.getElementById("ctl33_txtShippingLName").value="";
      document.getElementById("ctl33_txtShippingAddress").value="";
      document.getElementById("ctl33_txtShippingCity").value="";
      document.getElementById("ctl33_txtShippingZipcode").value="";
      document.getElementById("ctl33_txtShippingPNumber").value="";
      document.getElementById("ctl33_cboShippingState").options[document.getElementById("ctl33_cboShippingState").options.selectedIndex].text="AK";
      
      }
   }
   
   
  
   
function validateshipping1()
  {
    var shipfname=document.getElementById("ctl33_txtShippingFName").value;
    var shiplname=document.getElementById("ctl33_txtShippingLName").value;
    var shipaddress=document.getElementById("ctl33_txtShippingAddress").value;
    var shipcity=document.getElementById("ctl33_txtShippingCity").value;
    var shipzip=document.getElementById("ctl33_txtShippingZipcode").value;
    var shipph=document.getElementById("ctl33_txtShippingPNumber").value;
    
    var fname=document.getElementById("ctl33_txtFName").value;
    var lname=document.getElementById("ctl33_txtLName").value;
    var address=document.getElementById("ctl33_txtAddress").value;
    var city=document.getElementById("ctl33_txtCity").value;
    var zip=document.getElementById("ctl33_txtZipCode").value;
    var phone=document.getElementById("ctl33_txtPhoneNumber").value;
    var email=document.getElementById("ctl33_txtEmailAddress").value;
    
     if(shipfname=="" || shiplname=="" || shipaddress=="" || shipcity=="" || shipzip=="" || shipph=="" || fname=="" || lname=="" || address=="" || city=="" || zip=="" || phone=="" || email=="")
     {
     alert("Please fill the shipping address form before adding a new one");
     return false;
     }
     else
     {
     return true;
     }
  }
  
  function validateshipping2()
  {
    var shipfname=document.getElementById("ctl33_txtShippingFName2").value;
    var shiplname=document.getElementById("ctl33_txtShippingLName2").value;
    var shipaddress=document.getElementById("ctl33_txtShippingAddress2").value;
    var shipcity=document.getElementById("ctl33_txtShippingCity2").value;
    var shipzip=document.getElementById("ctl33_txtShippingZipcode2").value;
    var shipph=document.getElementById("ctl33_txtShippingPNumber2").value;
       
     if(shipfname=="" || shiplname=="" || shipaddress=="" || shipcity=="" || shipzip=="" || shipph=="" )
     {
     alert("Please fill the shipping address form before adding a new one");
     return false;
     }
     else
     {
     return true;
     }
  }
  
  function validateshipping3()
  {
    var shipfname=document.getElementById("ctl33_txtShippingFName3").value;
    var shiplname=document.getElementById("ctl33_txtShippingLName3").value;
    var shipaddress=document.getElementById("ctl33_txtShippingAddress3").value;
    var shipcity=document.getElementById("ctl33_txtShippingCity3").value;
    var shipzip=document.getElementById("ctl33_txtShippingZipcode3").value;
    var shipph=document.getElementById("ctl33_txtShippingPNumber3").value;
       
     if(shipfname=="" || shiplname=="" || shipaddress=="" || shipcity=="" || shipzip=="" || shipph=="" )
     {
     alert("Please fill the shipping address form before adding a new one");
     return false;
     }
     else
     {
     return true;
     }
  }
  
  function validateshipping4()
  {
    var shipfname=document.getElementById("ctl33_txtShippingFName4").value;
    var shiplname=document.getElementById("ctl33_txtShippingLName4").value;
    var shipaddress=document.getElementById("ctl33_txtShippingAddress4").value;
    var shipcity=document.getElementById("ctl33_txtShippingCity4").value;
    var shipzip=document.getElementById("ctl33_txtShippingZipcode4").value;
    var shipph=document.getElementById("ctl33_txtShippingPNumber4").value;
       
     if(shipfname=="" || shiplname=="" || shipaddress=="" || shipcity=="" || shipzip=="" || shipph=="" )
     {
     alert("Please fill the shipping address form before adding a new one");
     return false;
     }
     else
     {
     return true;
     }
  }
  
  function validateshipping5()
  {
    var shipfname=document.getElementById("ctl33_txtShippingFName5").value;
    var shiplname=document.getElementById("ctl33_txtShippingLName5").value;
    var shipaddress=document.getElementById("ctl33_txtShippingAddress5").value;
    var shipcity=document.getElementById("ctl33_txtShippingCity5").value;
    var shipzip=document.getElementById("ctl33_txtShippingZipcode5").value;
    var shipph=document.getElementById("ctl33_txtShippingPNumber5").value;
       
     if(shipfname=="" || shiplname=="" || shipaddress=="" || shipcity=="" || shipzip=="" || shipph=="" )
     {
     alert("Please fill the shipping address form before adding a new one");
     return false;
     }
     else
     {
     return true;
     }
  }
