﻿// JScript File

// JScript File

    var theform;	
	    if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) 
		    theform = document.forms["aspnetForm"];
	    else
		    theform = document.aspnetForm;
			
    function RemoveFromCart(getID)
    {
        document.location.href="DeleteCartItem.aspx?ProductId=" + getID ;        
        return false;
    }
    
    function CopyBillingAdressToShippingAdress()
    {        
        
        if(theform.ctl00$cphMainBody$chkChoose.checked == true)
        {
            theform.ctl00$cphMainBody$txtDelFirstName.value   = theform.ctl00$cphMainBody$txtFirstName.value;
            theform.ctl00$cphMainBody$txtDelMiddleName.value  = theform.ctl00$cphMainBody$txtMiddleName.value;
            theform.ctl00$cphMainBody$txtDelLastName.value    = theform.ctl00$cphMainBody$txtLastName.value;
            theform.ctl00$cphMainBody$txtDelAddress.value     = theform.ctl00$cphMainBody$txtAddress.value;
            theform.ctl00$cphMainBody$txtDelCity.value        = theform.ctl00$cphMainBody$txtCity.value;
            theform.ctl00$cphMainBody$txtDelState.value       = theform.ctl00$cphMainBody$txtState.value;
            theform.ctl00$cphMainBody$txtDelCountry.value   = theform.ctl00$cphMainBody$txtCountry.value;
            /*theform.ctl00$cphMainBody$drpShipping.options[theform.ctl00$cphMainBody$drpShipping.selectedIndex].value   = theform.ctl00$cphMainBody$drpCountry.options[theform.ctl00$cphMainBody$drpShipping.selectedIndex].value;*/
            theform.ctl00$cphMainBody$txtDelZip.value         = theform.ctl00$cphMainBody$txtZip.value;
            theform.ctl00$cphMainBody$txtDelPhone.value       = theform.ctl00$cphMainBody$txtPhone.value;
            theform.ctl00$cphMainBody$txtDelEmail.value       = theform.ctl00$cphMainBody$txtEmail.value;
        }
        else
        {
            theform.ctl00$cphMainBody$txtDelFirstName.value   = "";
            theform.ctl00$cphMainBody$txtDelMiddleName.value  = "";
            theform.ctl00$cphMainBody$txtDelLastName.value    = "";
            theform.ctl00$cphMainBody$txtDelAddress.value     = "";
            theform.ctl00$cphMainBody$txtDelCity.value        = "";
            theform.ctl00$cphMainBody$txtDelState.value       = "";
            theform.ctl00$cphMainBody$txtDelCountry.value     = "";
            /*theform.ctl00$cphMainBody$drpCountry.value        ="0";*/
            theform.ctl00$cphMainBody$txtDelZip.value         = "";
            theform.ctl00$cphMainBody$txtDelPhone.value       = "";
            theform.ctl00$cphMainBody$txtDelEmail.value       = "";       
        }               
    }
    
    
    
    function ValidateNewForm()
	{
		var postback = true;	
             
        if (Validate_FirstName() == false)
            postback = false;  
            
        if (Validate_LastName() == false)
            postback = false;         
            
        if (Validate_Address() == false)
            postback = false;                  
            
        if (Validate_Country() == false)
            postback = false; 

        if (Validate_Email() == false)
            postback = false; 
            
        if (Validate_DelFirstName() == false)
            postback = false;  
            
        if (Validate_DelLastName() == false)
            postback = false;                
            
        if (Validate_DelAddress() == false)
            postback = false; 
            
        if (Validate_DelCountry() == false)
            postback = false; 
            
        if (Validate_Del_Email() == false)
            postback = false; 
   
             
		if(postback == true)
		    return true;
		else
		    return false;		
	}
	
		
	function Validate_FirstName()
	{
        var postback = true;	
        
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtFirstName,'Please Enter First Name','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}		
	
	function Validate_LastName()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtLastName,'Please Enter Last Name','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}		
		
	function Validate_Address()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtAddress,'Please Enter Address','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}	
	
	function Validate_Country()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtCountry,'Please Enter Country','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}
	
	function Validate_Email()
	{
        var postback = true;	
        
       if (DivEmailFieldValidation(theform.ctl00$cphMainBody$txtEmail,'Please Enter Email','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  
             
		if(postback == true)
		    return true;
		else
		    return false;
	}
	
	
	function Validate_DelFirstName()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtDelFirstName,'Please Enter First Name','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}		
	
	function Validate_DelLastName()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtDelLastName,'Please Enter Last Name','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}
	
	
	function Validate_DelAddress()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtDelAddress,'Please Enter Address','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}	
	
	function Validate_DelCountry()
	{
        var postback = true;	
        
       if (DivEmptyFieldValidation(theform.ctl00$cphMainBody$txtDelCountry,'Please Enter Country','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  	
             
		if(postback == true)
		    return true;
		else
		    return false;
	}
	
	function Validate_Del_Email()
	{
        var postback = true;	
        
       if (DivEmailFieldValidation(theform.ctl00$cphMainBody$txtDelEmail,'Please Enter Email','cart_error_div') == false)
            postback = false;
        else
             ClearErrorMessage('cart_error_div');  
             
		if(postback == true)
		    return true;
		else
		    return false;
	}
	
	
	function ValidateRecalculate(getProductID)
    {   
        
       var theform;	
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) 
		theform = document.forms["aspnetForm"];
	else
		theform = document.aspnetForm;
        var postback = true;   
        
        var arrProdid;
        var txtQuantity;
        var cartitem = "";
        
        arrProdid = getProductID.split(",");
        if(arrProdid.length > 0)
        {
            for(var arrNum = 0; arrNum< arrProdid.length;arrNum++)
            {
                txtQuantity = eval("theform.txtQuantity_" + arrProdid[arrNum]);                              
                if (Validate_RecalculateQuantity(txtQuantity) == false)
                {
                    postback = false;  
                    arrNum   = arrProdid.length; 
                }
                if(cartitem != "")
                {
                    cartitem = cartitem + "^" + arrProdid[arrNum] + "~" + txtQuantity.value;
                }
                else
                {
                    cartitem = arrProdid[arrNum] + "~" + txtQuantity.value;
                 }
                theform.ctl00$cphMainBody$jsCartItem.value = cartitem;
            }
        }       
                 
        if(postback == true)
		    return true;
		else
		    return false; 
    }
    
    function Validate_RecalculateQuantity(objTextField)
	{   	    
        var postback = true;	       
       if (DivEmptyFieldValidation(objTextField,'Please Enter Quantity','ctl00_cphMainBody_cart_error_div') == false) /*div_View_Cart_PageError*/
       {            
            postback = false;
       }
       else if (DivNumericFieldValidation(objTextField,'Please Enter Numeric Quantity','ctl00_cphMainBody_cart_error_div') == false)
       {            
            postback = false;
       }
       else if(DivZeroFieldValidation(objTextField,'Please Enter Quantity Greater Than 0','ctl00_cphMainBody_cart_error_div')== false)
       {           
            postback = false;
       }
      else
       {          
            FullClearErrorMessage('ctl00_cphMainBody_cart_error_div');  
       }
             
		if(postback == true)	    
		    return true;
    	else
		    return false;
	}
	
