var xmlHttp;
var methodName;
function remoteCall(url)
{
    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;
          }
        }
      }
      
      
       if(methodName == "stateCheckHandle"){
	      xmlHttp.onreadystatechange=stateCheckHandle;
	      }
	      else if(methodName == "defaultStateCheckHandle"){
	      	xmlHttp.onreadystatechange=defaultStateCheckHandle;
	      
	      }else if(methodName == "getShippingHandle"){
	       	xmlHttp.onreadystatechange=getShippingHandle;
	      
	      }else if(methodName == "checkUserIdHandle"){		      
		      	xmlHttp.onreadystatechange=checkUserIdHandle;
		      
		      }
       
      xmlHttp.open("POST",url,true);
      xmlHttp.send(null);
}

var stateId;
function stateCheck(url,country1,state1){
	if(url){
		if(url.length > 0){	
		stateId = state1;
		 methodName = "stateCheckHandle";
		 if(url.indexOf(';')>-1 ){
		         url = url.substring(0,url.lastIndexOf(';'));
		      }
       
       var countryCode = document.getElementById(country1).value;
       url = url +"?countryId="+countryCode;
       remoteCall(url);
       }
	  }      
}

function stateCheckHandle(){
	if(xmlHttp.readyState==4 && xmlHttp.status==200){
		jQuery("#"+stateId).empty();
			jQuery("#"+stateId).append(xmlHttp.responseText);
			     }
} 

function defaultStateCheckHandle(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
		jQuery("#"+stateId).empty();
		jQuery("#"+stateId).append(xmlHttp.responseText);
     }

}

function defaultStateCheck(url,country1,state1){
	if(url){
		if(url.length > 0){	
		stateId = state1;
		 methodName = "defaultStateCheckHandle";
		 if(url.indexOf(';')>-1 ){
		         url = url.substring(0,url.lastIndexOf(';'));
		      }
       
       var countryCode = document.getElementById(country1).value;
       url = url +"?countryId="+countryCode;
       remoteCall(url);
       }
	  }
}

jQuery(document).ready(function(){
	/* Bottom boxes expanding code */
	var h1 = jQuery("#box-1-contents").height();
	if(h1<=90){
		jQuery("#box-1-button").hide();
	}
	jQuery("#box-1-contents").css({ height:"75px", overflow:"hidden" });
	jQuery("#box-1-button").click(function () {
		//alert('Here' + $("#box-1-contents").height());
		if(jQuery("#box-1-contents").height() == "75"){
			jQuery("#box-1-contents").animate({height: h1}, 500 );
			jQuery("#box-1-button").text("Less...");
		}else{
			jQuery("#box-1-contents").animate({height:"75"}, 500 );
			jQuery("#box-1-button").text("Read more...");
		}
	});
});	