// JScript File
function showMsg(x){
	alert(x);
}

function ajaxFunction(){

 var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari 
 	xmlHttp=new XMLHttpRequest();  
  }
  catch (e)
    {    // Internet Explorer 
  try
      {   
 	 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
      }
    catch (e)
      {   
  	try
        	{   
     		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
      	}
     	 catch (e)
        	{     
 		alert("Your browser does not support AJAX!");    
    		return false;
	}

      }  
 }	

	return xmlHttp;
	
}
function show()
{  
    if(document.getElementById("ddCountry").value!="0")
    {
       /* if(document.getElementById("ddCountry").value=="220")
	    {
	        document.getElementById("chooseshipping").innerHTML="<p style='margin-top:-10px'></p>";
	        document.getElementById("chooseinsurance").innerHTML="<p style='margin-top:-10px'></p>";
	        document.getElementById("shippingoption").innerHTML="<p style='margin-top:-10px'></p>";
	        document.getElementById("insuranceoption").innerHTML="<p style='margin-top:-10px'></p>";	        
            document.getElementById("span2").innerHTML="<p style='margin-top:-10px'></p>";	        
            document.getElementById("span3").innerHTML="<p style='margin-top:-10px'></p>";
            document.getElementById("sub").innerHTML="$" + document.getElementById("txtval").value;
            document.getElementById("hiddenCountry").value = document.getElementById("ddCountry").value;
	        document.getElementById("ImageButton1").style.visibility="visible";
	        return null;
	    }
	    else
	    {*/
        xmlHttp=ajaxFunction();
        xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==1)
					{
					   document.getElementById("shippingoption").innerHTML="<img src='images/a1.gif'/><img src='images/loading.gif'/>";
                       document.getElementById("spanshippingMethod").innerHTML="<p style='margin-top:-10px'></p>";
			           document.getElementById("spanShippingOption").innerHTML= "<p style='margin-top:-10px'></p>";
				       document.getElementById("spnfedexrate").innerHTML = "<p style='margin-top:-10px'></p>";
			           document.getElementById("span2").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("span3").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("chooseinsurance").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("insuranceoption").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("spanInsurance1").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("spanInsurance2").innerHTML="<p style='margin-top:-10px'></p>";
                       document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
					}
					if(xmlHttp.readyState==4)
					{
					    var r=xmlHttp.responseText
					    //alert(r);
					    
					   if(document.getElementById("ddCountry").value!="220")
					   {
					       document.getElementById("sub").innerHTML="$ " + document.getElementById("txtval").value;
					       document.getElementById("chooseshipping").innerHTML="Select Shipping :";
					       document.getElementById("shippingoption").innerHTML=r.split("eee",1);
					       document.getElementById("chooseinsurance").innerHTML="Select Insurance :";
					       document.getElementById("insuranceoption").innerHTML="<select id=ddlinsurance onchange=showinsurnce();><option value=0>-----Select-----</option><option value=2.00>$100</option><option value=4.00>$200</option><option value=6.00>$300</option><option value=8.00>$400</option><option value=10.00>$500</option><option value=12.00>$600</option><option value=14.00>$700</option><option value=16.00>$800</option><option value=18.00>$900</option><option value=20.00>$1000</option></select>";
					       document.getElementById("spanshippingMethod").innerHTML="";
					       document.getElementById("spanShippingOption").innerHTML= "";
    					   document.getElementById("spnfedexrate").innerHTML = "";
					       document.getElementById("span2").innerHTML="";
                           document.getElementById("span3").innerHTML="";
                           document.getElementById("hiddenCountry").value = document.getElementById("ddCountry").value;
                            if(document.getElementById("hiddenShipping").value!="")
                            {                        
                                document.getElementById("ddlshipping").selectedIndex = getSelectedIndex(document.getElementById("ddlshipping"),document.getElementById("hiddenShipping").value,"txt");                                
                                //alert( document.getElementById("ddlshipping").selectedIndex); 
                                showshipping();
                            }
                            if(document.getElementById("hiddenInsurance").value!="")
                            {
                                document.getElementById("ddlinsurance").selectedIndex = getSelectedIndex(document.getElementById("ddlinsurance"),document.getElementById("hiddenInsurance").value,"");
                                showinsurnce();
                            }
                        }
                        else
                        {
                            var ab=r.split("eee",1);                           
                           document.getElementById("chooseshipping").innerHTML="Select ShipTo State :";
					       document.getElementById("shippingoption").innerHTML=ab;					      
					       document.getElementById("chooseinsurance").innerHTML="";
					       document.getElementById("insuranceoption").innerHTML="";						       
					       if(document.getElementById("hiddenState").value!="")
                            {         
                                document.getElementById("ddlState").selectedIndex = getSelectedIndex(document.getElementById("ddlState"),document.getElementById("hiddenState").value,"txt");                                
                                
                               showZip();
                            }	
					        
                        }
					}
					
        //}
       }       
        var url="system.aspx?id="+document.getElementById("ddCountry").value+"&type=ctry";
        //alert(url);
  		xmlHttp.open("GET",url,true);
        xmlHttp.send(null);	
        document.getElementById("hiddenCountry").value=document.getElementById("ddCountry").value;
      
    }
    else
    {
         document.getElementById("sub").innerHTML="$" + document.getElementById("txtval").value;           
         document.getElementById("hiddenCountry").value="";
         document.getElementById("spanshippingMethod").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spanShippingOption").innerHTML="<p style='margin-top:-10px'></p>"
		 document.getElementById("chooseinsurance").innerHTML="<p style='margin-top:-10px'></p>";
		document.getElementById("insuranceoption").innerHTML="<p style='margin-top:-10px'></p>";
		document.getElementById("spanInsurance1").innerHTML="<p style='margin-top:-10px'></p>";
	    document.getElementById("spanInsurance2").innerHTML="<p style='margin-top:-10px'></p>";
	    document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
		document.getElementById("spnfedexrate").innerHTML ="<p style='margin-top:-10px'></p>";
        document.getElementById("span2").innerHTML="<p style='margin-top:-10px'></p>";
        document.getElementById("span3").innerHTML="<p style='margin-top:-10px'></p>";
        document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
        document.getElementById("chooseshipping").innerHTML="<p style='margin-top:-10px'></p>";
		document.getElementById("shippingoption").innerHTML="<p style='margin-top:-10px'></p>";
    }
}
function show_NonUs(ab)
{
   document.getElementById("chooseshipping").innerHTML="Select ShipTo State :";
   document.getElementById("shippingoption").innerHTML=ab;
   document.getElementById("chooseinsurance").innerHTML="";
   document.getElementById("insuranceoption").innerHTML="";	
}
function showZip()
{
    var e = document.getElementById("ddlState"); // select element
    var strUser = e.options[e.selectedIndex].text; 
    if(document.getElementById("ddlState").value!="0")
    {
        xmlHttp=ajaxFunction();
        xmlHttp.onreadystatechange=function()
        {
                    if(xmlHttp.readyState==1)
					{
					 document.getElementById("insuranceoption").innerHTML="<img src='images/a1.gif'/><img src='images/loading.gif'/>";
                     document.getElementById("chooseinsurance").innerHTML="<p style='margin-top:-10px'></p>";
					 document.getElementById("insuranceoption").innerHTML="<p style='margin-top:-10px'></p>";
                     document.getElementById("spanshippingMethod").innerHTML="<p style='margin-top:-10px'></p>";
					 document.getElementById("spanShippingOption").innerHTML="<p style='margin-top:-10px'></p>";
					 document.getElementById("spnfedexrate").innerHTML = "<p style='margin-top:-10px'></p>";
					 document.getElementById("spanInsurance1").innerHTML="<p style='margin-top:-10px'></p>";
					 document.getElementById("spanInsurance2").innerHTML="<p style='margin-top:-10px'></p>";
					 document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
                     
					}
					if(xmlHttp.readyState==4)
					{
					    var r=xmlHttp.responseText					    
					    
					   document.getElementById("chooseinsurance").innerHTML="Enter ShipTo Zip Code :";
					   document.getElementById("insuranceoption").innerHTML=r.split("eee",1);					                  
					    if(document.getElementById("hiddenZip").value!="")
                        {                        
                            document.getElementById("txtZip").value = document.getElementById("hiddenZip").value;                                
                            showShippngmethod(document.getElementById("txtZip").event,document.getElementById("txtZip"));
                        }	
                       
					}
					
        }  
        document.getElementById("hiddenState").value = strUser;     
        var url="system.aspx?id="+document.getElementById("ddCountry").value+"&type=state";      
  		xmlHttp.open("GET",url,true);
        xmlHttp.send(null);	
       
      
    }
     else
    {
         document.getElementById("sub").innerHTML="$" + document.getElementById("txtval").value;               
         document.getElementById("hiddenCountry").value="";
         document.getElementById("chooseinsurance").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("insuranceoption").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spanshippingMethod").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spanShippingOption").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spnfedexrate").innerHTML = "<p style='margin-top:-10px'></p>";
		 document.getElementById("spanInsurance1").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spanInsurance2").innerHTML="<p style='margin-top:-10px'></p>";
		 document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
       
    }
}
function showShippngmethod(event,f)
{
    
   if (!/^\d*$/.test(f.value))
   {
   f.value = f.value.replace(/[^\d]/g,"");
   document.getElementById("errmsg").innerHTML="<font color='red'>Enter Only Digits</font>";
   
   }
   else
   {
       document.getElementById("errmsg").innerHTML="";
       var x = document.getElementById("txtZip").value
       if(x.length > 4)
       {        
         var strUser = document.getElementById("txtZip").value;
         xmlHttp=ajaxFunction();
        xmlHttp.onreadystatechange=function()
        {
                    if(xmlHttp.readyState==1)
					{
					 document.getElementById("errmsg").innerHTML="<img src='images/a1.gif'/><img src='images/loading.gif'/>";                   
                     
					}
					if(xmlHttp.readyState==4)
					{
					   if(x.length >= 5){
					    var r=xmlHttp.responseText
					    var abc = r.split("eee",1);
					   document.getElementById("errmsg").innerHTML="";
					   document.getElementById("spanshippingMethod").innerHTML="Shipping Method :";
					   document.getElementById("spanShippingOption").innerHTML= abc;
					   document.getElementById("hiddenZip").value = strUser;	                  			  
					   document.getElementById("spnfedexrate").innerHTML = "$ 0.00" ;
					   document.getElementById("spanInsurance1").innerHTML="Select Insurance :";
					   document.getElementById("spanInsurance2").innerHTML="<select id=ddlinsurance onchange=showinsurnce_1();><option value=0.00>-----Select-----</option><option value=2.00>$100</option><option value=4.00>$200</option><option value=6.00>$300</option><option value=8.00>$400</option><option value=10.00>$500</option><option value=12.00>$600</option><option value=14.00>$700</option><option value=16.00>$800</option><option value=18.00>$900</option><option value=20.00>$1000</option></select>";
					   document.getElementById("spanInsurance3").innerHTML="$ "+document.getElementById("ddlinsurance").value;                  
					 
					    if(document.getElementById("hiddenShipping").value != "")
                        { 
                            document.getElementById("ddlshippingMethod").selectedIndex = getSelectedIndex(document.getElementById("ddlshippingMethod"),document.getElementById("hiddenShipping").value,"txt");                             
                            fedexShippingMethod();
                        }	                       			  
                        if(document.getElementById("hiddenInsurance").value!="")
                        {
                            document.getElementById("ddlinsurance").selectedIndex = getSelectedIndex(document.getElementById("ddlinsurance"),document.getElementById("hiddenInsurance").value,"");                           
                            showinsurnce_1();
                        }	
                        }	
					}					
        }      
        document.getElementById("hiddenZip").value = strUser;   
        var url="system.aspx?id="+zipCode(document.getElementById("txtZip").value)+"&type=shipping&state="+document.getElementById("ddlState").value;    
//        var url="system.aspx?id="+document.getElementById("txtZip").value+"&type=shipping&state="+document.getElementById("ddlState").value;
        
  		xmlHttp.open("GET",url,true);
        xmlHttp.send(null);	
       }    
       else
       {
            document.getElementById("spanshippingMethod").innerHTML="<p style='margin-top:-10px'></p>";
			document.getElementById("spanShippingOption").innerHTML="<p style='margin-top:-10px'></p>";
			document.getElementById("spanInsurance1").innerHTML="<p style='margin-top:-10px'></p>";
			document.getElementById("spanInsurance2").innerHTML="<p style='margin-top:-10px'></p>";
			document.getElementById("spnfedexrate").innerHTML="<p style='margin-top:-10px'></p>";
			document.getElementById("spanInsurance3").innerHTML="<p style='margin-top:-10px'></p>";
       }    
   }
}
function zipCode(code)
{
    var checkCode = code;
    var ziped = checkCode.substring(0,3);
    //alert(ziped);
    return ziped;
}
function fedexShippingMethod()
{
      var e = document.getElementById("ddlshippingMethod"); 
    var strUser = e.options[e.selectedIndex].text; 
     var report = document.getElementById("ddlinsurance").value;
    if(document.getElementById("ddlshippingMethod").value !=-1)
    {
         document.getElementById("hdnShippingFedex").value =  strUser;
        // alert("hdnshipingfedex" + document.getElementById("hdnShippingFedex").value  );
        document.getElementById("spnfedexrate").innerHTML = "$ " + document.getElementById("ddlshippingMethod").value;
        var ddlReport = document.getElementById("ddlshippingMethod").value;        
        var tot = Math.round(calculator(ddlReport)*Math.pow(10,2))/Math.pow(10,2);
        var v = eval(tot) + eval(report);
       document.getElementById("sub").innerHTML="$ "  + v;
       document.getElementById("hiddenShipping").value = strUser;
       //alert("Shipping fedex method options :" + document.getElementById("hiddenShipping").value); 
    }
    else
    {
        document.getElementById("hdnShippingFedex").value = "";
         document.getElementById("spnfedexrate").innerHTML = "$ 0.00"
          var t = document.getElementById("txtval").value;           
          var t1 = eval(t) + eval(report); 
         document.getElementById("sub").innerHTML = "$ " + t1;
          //document.getElementById("hiddenShipping").value = "";
    }
}
function showshipping()
{
    var e = document.getElementById("ddlshipping"); // select element
    var strUser = e.options[e.selectedIndex].text; 
//alert(strUser);
    var total,total_1;
     var ddlReport = document.getElementById("ddlshipping").value;
    //alert(ddlReport);
     var report = document.getElementById("ddlinsurance").value;
    if(document.getElementById("ddlshipping").value!=0)
    { 
     document.getElementById("span2").innerHTML="$ " + Math.round(ddlReport*Math.pow(10,2))/Math.pow(10,2);
     var tot = Math.round(calculator(ddlReport)*Math.pow(10,2))/Math.pow(10,2);
     document.getElementById("sub").innerHTML="$ "  + tot;
     //document.getElementById("ImageButton1").style.visibility="visible"; 
     document.getElementById("hiddenShipping").value = strUser;
    
	}
	if(document.getElementById("ddlshipping").value==0)
    { 
        document.getElementById("span2").innerHTML="";
        var t = calculator(ddlReport)+eval(report);
        document.getElementById("sub").innerHTML="$ " + t;
        //document.getElementById("ImageButton1").style.visibility="hidden"; 
        document.getElementById("hiddenShipping").value = "";
    }
	
}
function showinsurnce()
{
    var e = document.getElementById("ddlinsurance"); // select element
    var strUser = e.options[e.selectedIndex].value;     
     var report = document.getElementById("ddlinsurance").value;
     var ddlReport = document.getElementById("ddlshipping").value;
    if(document.getElementById("ddlinsurance").value!=0)
    { 
     document.getElementById("span3").innerHTML="$ " + report;  
     var v =   eval(calculator(ddlReport)+ eval(report));
     document.getElementById("sub").innerHTML="$ " + Math.round(v*Math.pow(10,2))/Math.pow(10,2)
     document.getElementById("hiddenInsurance").value = strUser;
      document.getElementById("insurance").value = document.getElementById("ddlinsurance").value;
	}	
	else
	{
	    document.getElementById("span3").innerHTML="";
	    var r = Math.round(calculator(ddlReport)*Math.pow(10,2))/Math.pow(10,2);
	    document.getElementById("sub").innerHTML="$ " + r;
	    document.getElementById("hiddenInsurance").value="";
	    document.getElementById("insurance").value = "";
	}
}
function showinsurnce_1()
{
    var e = document.getElementById("ddlinsurance"); // select element
    var strUser = e.options[e.selectedIndex].value;     
    var report = document.getElementById("ddlinsurance").value;
    var ddlReport = document.getElementById("ddlshippingMethod").value;
    if(document.getElementById("ddlinsurance").value!=0)
    { 
      document.getElementById("spanInsurance3").innerHTML="$ " + report;  
      var v =   eval(calculator(ddlReport)+ eval(report));
      document.getElementById("sub").innerHTML="$ " + Math.round(v*Math.pow(10,2))/Math.pow(10,2)
      document.getElementById("hiddenInsurance").value = strUser;
      document.getElementById("insurance").value = document.getElementById("ddlinsurance").value;
	}	
	else
	{
	    document.getElementById("spanInsurance3").innerHTML="$0.00";
	    var r = Math.round(calculator(ddlReport)*Math.pow(10,2))/Math.pow(10,2);
	    document.getElementById("sub").innerHTML="$ " + r;
	    document.getElementById("hiddenInsurance").value="";
	    document.getElementById("insurance").value = "";
	}
}
function calculator(r)
{
     var a = r;
     var total;
     var subtotal = document.getElementById("txtval").value;   
     total = eval(a)+eval(subtotal);
     //alert(total);
     return total;
}
function show_visible()
{  
     
   //if(document.getElementById("hiddenlabel").value != "Items : 0")
   
   
   if(document.getElementById("hiddenCountry").value != "")
   {
      // alert(document.getElementById("hiddenCountry").value);
       var si=getSelectedIndex(document.getElementById("ddCountry"),document.getElementById("hiddenCountry").value,"txt");
       //alert(si);
        document.getElementById("ddCountry").selectedIndex=si;
      if(document.getElementById("ddCountry").value == "220")
      {   
        show();        
      }  
      else
      {        
        show();
      }  
    } 
    else
    { 
        if(document.getElementById("hiddenlabel").value != "Items : 0"){            
            show();
        }else{
         document.getElementById("ImageButton1").style.visibility="hidden";
         document.getElementById("GCheckoutButton1").style.visibility="hidden"; 
          //document.getElementById("lblor").style.visibility="hidden"; 
         }
    }   
    
    //check();
 }        


function paymentvalidation(x,y)
{
    var p = document.getElementById("ddPayment").value;
    if(p == 0)
    {
     y.IsValid = false;
    }
     
}
function usps_validation(x,y)
{
    var c = document.getElementById("ddCountry").value;
//    var sete = c.options[c.selectedIndex].text;
   
     //alert("Mandan "+c);
    if(c == '220')
    {
        //alert("Anij");
        var pay = document.getElementById("ddPayment").value ;
        
        if(pay == '0')
        {
        //alert("alert");
        //y.IsValid = (pay>0)
        }
        
    }    
    else
    {
        var e = document.getElementById("ddlshipping"); // select element
        var strUser = e.options[e.selectedIndex].text;
        var insu = document.getElementById("ddlinsurance").value;
        var pay = document.getElementById("ddPayment").value ;
        //alert("hello");
        if(e!=null)
        {
           if((strUser.indexOf('USPS')!=-1))
           {
               y.IsValid=(insu > 0);
           }
         }
        else
            y.IsValid=false;
        
    }
}
function getSelectedIndex(obj,v,ty)
{
    for(i=0;i<obj.length;i++)
    {
        //alert("i= "+ i);
        if(ty == "txt")
        {            
            if(obj.options[i].text==v)
            {
                      return i;
            }
        }
        else
        {
            if(obj.options[i].value==v)
            {
               //alert(obj.options[i].value);
                return i;
            }
        }
    }
}
function check()
{

    if(document.getElementById("hiddenCountry").value!="")
    {
         //alert("function check " + getSelectedIndex(document.getElementById("ddCountry"),document.getElementById("hiddenCountry").value,"txt"));
        document.getElementById("ddCountry").selectedIndex = getSelectedIndex(document.getElementById("ddCountry"),document.getElementById("hiddenCountry").value,"txt");
      //alert("anij");
        show();
    }
}
function clickClient(x,y)
{
    //alert("Hello Anij Ninan");confirm
     var pay = document.getElementById("ddPayment").value;
     var cntry = document.getElementById("ddCountry").value;
     //alert(cntry);
     if(cntry != 0){
     if(cntry == 220)
     {
         if(pay == 0){
         alert("Please Select Payment");
           y.IsValid = false;
           }else{
         var state = document.getElementById("ddlState").value;
         //alert("state" + state);
         if(state == 0)
         {
            alert("Please select state");
            y.IsValid = false;
         }
         else
         {
            var zipC = document.getElementById("txtZip").value;
            //alert("Zip " + zipC);
            if(zipC == "")
            {
                 alert("Please Enter Zip Code");
                 y.IsValid = false;
            }
            else
            {
                var shipTo = document.getElementById("ddlshippingMethod").value;
                //var strUser = shipTo.options[shipTo.selectedIndex].text; 
                //alert("ship to " + strUser);
                if(shipTo == -1)
                {
                     alert("Please select shipping method");
                     y.IsValid = false;
                }
                else
                {
                    var insuran = document.getElementById("ddlinsurance").value;
                    //alert("insurance" + insuran);
                    var e = document.getElementById("ddlshippingMethod"); // select element
                     var strUser = e.options[e.selectedIndex].text;
                     //alert("strUser" + strUser);
                     if(e!=null)
                     {
                        //alert("anij" + strUser.indexOf('First')!=-1)
                       if((strUser.indexOf('US (Post')!=-1) || (strUser.indexOf('First Class')!=-1))
                       {                            
                          if(insuran > 0)
                          {
                            y.IsValid=true;
                          }
                          else
                          {
                             alert("Please select insurance for USPS, a minimum of $100 should be selected.");
                             y.IsValid=false;
                          }
                       }  
                       else
                       {
                            y.IsValid=true;
                       }                    
                       
                     }
                    else
                        
                        y.IsValid=false;
                    /*if(insuran == 0)
                    {
                        alert("Please select Insurance");
                        y.IsValid = false;
                    }*/
                }
            }
         }
         }
     }
     else
     {
        if(pay == 0)
        {
            alert("Please Select Payment");
           y.IsValid = false;
        }
        else
        {
        var nonusShipping =  document.getElementById("ddlshipping").value;
        //alert("non us shipping " + nonusShipping);
        if(nonusShipping == 0)
        {
            alert("Please select shipping method");
            y.IsValid = false;
        }
        else
        {
            var insuran = document.getElementById("ddlinsurance").value;
            var e = document.getElementById("ddlshipping"); // select element
             var strUser = e.options[e.selectedIndex].text;
             //alert("strUser" + strUser);
             if(e!=null)
             {
                //alert("anij" + strUser.indexOf('First')!=-1)
               if((strUser.indexOf('US (Post')!=-1) || (strUser.indexOf('First Class')!=-1))
               {                            
                  if(insuran > 0)
                  {
                    y.IsValid=true;
                  }
                  else
                  {
                     alert("Please select insurance for USPS, a minimum of $100 should be selected.");
                     y.IsValid=false;
                  }
               }  
               else
               {
                    y.IsValid=true;
               }                    
               
             }
            else
                
                y.IsValid=false;
        }
     }
     }
    }
    else
    {
        alert("Please Select Country");
         y.IsValid=false;
    } 
}
function clickClientOn(x,y)
{
    var pay = document.getElementById("ddPayment").value;
     var cntry = document.getElementById("ddCountry").value;
     //alert(cntry);
     if(cntry != 0){
     if(cntry == 220)
     {
         /*if(pay == 0){
         alert("Please Select Payment");
           y.IsValid = false;
           }else{*/
         var state = document.getElementById("ddlState").value;
         //alert("state" + state);
         if(state == 0)
         {
            alert("Please select state");
            y.IsValid = false;
         }
         else
         {
            var zipC = document.getElementById("txtZip").value;
            //alert("Zip " + zipC);
            if(zipC == "")
            {
                 alert("Please Enter Zip Code");
                 y.IsValid = false;
            }
            else
            {
                var shipTo = document.getElementById("ddlshippingMethod").value;
                //var strUser = shipTo.options[shipTo.selectedIndex].text; 
                //alert("ship to " + strUser);
                if(shipTo == -1)
                {
                     alert("Please select shipping method");
                     y.IsValid = false;
                }
                else
                {
                    var insuran = document.getElementById("ddlinsurance").value;
                    //alert("insurance" + insuran);
                     var e = document.getElementById("ddlshippingMethod"); // select element
                     var strUser = e.options[e.selectedIndex].text;
                     //alert("strUser" + strUser);
                     if(e!=null)
                     {
                        //alert("anij" + strUser.indexOf('First Class'))
                       if((strUser.indexOf('US (Post')!=-1) || (strUser.indexOf('First Class')!=-1))
                       {                            
                          if(insuran > 0)
                          {
                            y.IsValid=true;
                          }
                          else
                          {
                             alert("Please select insurance for USPS, a minimum of $100 should be selected.");
                             y.IsValid=false;
                          }
                       }  
                       else
                       {
                            y.IsValid=true;
                       }                    
                       
                     }
                    else
                        
                        y.IsValid=false;
                    /*if(insuran == 0)
                    {
                        
                        y.IsValid = false;
                    }*/
                }
            }
         }
        // }
     }
     else
     {
//        if(pay == 0)
//           y.IsValid = false;
        var nonusShipping =  document.getElementById("ddlshipping").value;
        //alert("non us shipping " + nonusShipping);
        if(nonusShipping == 0)
        {
            alert("Please select shipping method");
            y.IsValid = false;
        }
        else
        {
            var insuran = document.getElementById("ddlinsurance").value;
            var e = document.getElementById("ddlshipping"); // select element
             var strUser = e.options[e.selectedIndex].text;
             //alert("strUser" + strUser);
             if(e!=null)
             {
                //alert("anij" + strUser.indexOf('First')!=-1)
              if((strUser.indexOf('US (Post')!=-1) || (strUser.indexOf('First Class')!=-1))
               {                            
                  if(insuran > 0)
                  {
                    y.IsValid=true;
                  }
                  else
                  {
                     alert("Please select insurance for USPS, a minimum of $100 should be selected.");
                     y.IsValid=false;
                  }
               }  
               else
               {
                    y.IsValid=true;
               }                    
               
             }
            else
                
                y.IsValid=false;
        }
     }
    }
    else
    {
        alert("Please Select Country");
         y.IsValid=false;
    } 
}
