/*firstName
lastName
creditCardType
creditCardNumber
expDateMonth
expDateYear
address1
address2
city
state	
zip
amount
paymentType
*/

var xmlobject=null;
var resultwin="";
var form;

function doCheckOut(forme,firstName,lastName,creditCardType,creditCardNumber,expDateMonth,expDateYear,address1,address2,city,state,zip,amount,paymentType,cvv2Number,shipaddress1,shipcity)
{
	try
	{
		form=forme;
		xmlobject=new XMLHttpRequest();	// firefox
	}
	catch(ex)
	{
		xmlobject= new ActiveXObject("Microsoft.XMLHTTP");	// MSIE
	}
	try
	{	
		str="";
		str="firstName="+firstName;
		str+="&lastName="+lastName;
		str+="&creditCardType="+creditCardType;
		str+="&creditCardNumber="+creditCardNumber;
		str+="&expDateMonth="+expDateMonth;
		str+="&expDateYear="+expDateYear;
		str+="&address1="+address1;
		str+="&address2="+address2;
		str+="&city="+city;
		str+="&state="+state;
		str+="&zip="+zip;
		str+="&amount="+amount;
		str+="&paymentType="+paymentType;
		str+="&cvv2Number="+cvv2Number;
		str+="&shipaddress1="+shipaddress1;
		str+="&shipcity="+shipcity;
		status=(location.host);
		xmlobject.open("GET","http://"+location.host+"/paysdk/index.php?"+str,true);
		//xmlobject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlobject.onreadystatechange=manageCheckOut;
		xmlobject.send(null);
		divloading=document.getElementById("loading");
		divloading.style.display="block";
	}
	catch(ex2)
	{
		alert(ex2);			
	}
}


function manageCheckOut()
{
	if(xmlobject.readyState==4)
	{
		divloading=document.getElementById("loading");
		divloading.style.display="none";
		responseCode=xmlobject.responseText;
		//document.write(responseCode);
		//return ;
		
		if(responseCode=="1")
		{
			alert("Your Card information is incorrect. Please enter the details correctly");
			history.go(-1);
		}
		else
		{
			alert("Your Card has been accepted Click  OK to continue");
			form.submit();
		}	
	}	
}