function getElement(aID){ 
	return (document.getElementById) ? document.getElementById(aID) : document.all[aID];
} 

function getHTTPObject() { 
	var xmlhttp = false ; 
	if(window.XMLHttpRequest){ 
		xmlhttp = new XMLHttpRequest(); 
	} 
	else if (window.ActiveXObject){ 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		if (!xmlhttp){ 
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		} 
	} 
	return xmlhttp; 
} 

function AjaxGet(phpscript,divtag,vars,show, mode) {  
   var http = false ;
    http = getHTTPObject();
	http.open("GET", phpscript, mode); // true is to  not wait for results
  		http.onreadystatechange = function() { 
        if (http.readyState == 4) {
        	if(http.status==200) { 
	    		var results = "" ;
          		results = http.responseText ;
	     		getElement(divtag).innerHTML = results ;
        	} else {
				var msg = "Error: "+http.status+" Function/r/n script="+phpscript+" divtag=";
				msg += divtag+" vars="+vars+" show="+show;
          		alert(msg); //404 not found
          	} // end status 
	    } // end ready state 
     }   // function 
   http.send(null); 
   return;
 } 
 
 function AjaxGetCart(phpscript,divtag,vars,show, mode) {  
   var http = false ;
    http = getHTTPObject();
	http.open("GET", phpscript, mode); // true is to  not wait for results
  		http.onreadystatechange = function() { 
        if (http.readyState == 4) {
        	if(http.status==200) { 
	    		var results = "" ;
          		results = http.responseText ;
	     		getElement(divtag).innerHTML = results ;
					var AJAXtotalurl="ajax/Ajax_show_cart_totals.php";
					AjaxGet(AJAXtotalurl,"total",1,true,true);
        	} else {
				var msg = "Error: "+http.status+" Function/r/n script="+phpscript+" divtag=";
				msg += divtag+" vars="+vars+" show="+show;
          		alert(msg); //404 not found
          	} // end status 
	    } // end ready state 
     }   // function 
   http.send(null); 
   return;
 } 
 
 
function AjaxGetRefresh(phpscript,divtag,vars,show) {  
   var http = false ;
    http = getHTTPObject();
	http.open("GET", phpscript, true);  
  		http.onreadystatechange = function() { 
        if (http.readyState == 4) {
        	if(http.status==200) { 
		    	window.location.reload();
        	} else {
				var msg = "Error: "+http.status+" Function/r/n script="+phpscript+" divtag=";
				msg += divtag+" vars="+vars+" show="+show;
          		alert(msg); //404 not found
          	} // end status 
	    } // end ready state 
     }   // function 
   http.send(null); 
 }
 
function AjaxGetPayment(phpscript,divtag,vars,show,mode,successurl) {  
   var http = false ;
    http = getHTTPObject();
	http.open("GET", phpscript, mode);  
  		http.onreadystatechange = function() { 
        if (http.readyState == 4) {
        	if(http.status==200) { 
		  			var results = "" ;
          	results = http.responseText ;
				
	     			if (results=="This transaction has been approved." ) { //  if success 
							window.location = successurl;
						} else {
							getElement(divtag).innerHTML = results ;
						}
	      	} else {
				var msg = "Error: "+http.status+" Function/r/n script="+phpscript+" divtag=";
				msg += divtag+" vars="+vars+" show="+show;
          		alert(msg); //404 not found
          	} // end status 
	    } // end ready state 
     }   // function 
   http.send(null); 
 }
//==============================================================================================================
function add_to_cart(productid,qtyfld) {
	var ordqty = getElement(qtyfld).value;
	var stat = "qty_info_"+productid;
	var AJAXurl="ajax/Ajax_add_to_order.php?productid="+productid+"&qty="+ordqty;
	//alert(AJAXurl);
	AjaxGetCart(AJAXurl,stat,1,true,true);

}

function check_discount() {
	var code = getElement('discount_code').value;
	var AJAXurl="ajax/Ajax_add_discount.php?code="+code;
	//alert(AJAXurl);
	AjaxGetRefresh(AJAXurl,'discount_msg',1,true,true);

}

function sendpayment() {
	var ccnum =  getElement("CCNumber").value;
	var ccverify =  getElement("CCVerify").value;
	var ccexpmon =  getElement("CCExpireMonth").value;
	var ccexpyear =  getElement("CCExpireYear").value;
	var ccfname =  getElement("CCFirstNameOnCard").value;
	var cclname =  getElement("CCLastNameOnCard").value;
	var ccaddress =  getElement("BillingAddress").value;
	var cccity =  getElement("BillingCity").value;
	var ccstate =  getElement("BillingState").value;
	var cczip =  getElement("BillingZip").value;
	
	var AJAXurl="ajax/Ajax_payment.php?ccnum="+ccnum+"&ccverify="+ccverify+"&ccexpmon="+ccexpmon+"&ccexpyear="+ccexpyear+"&ccfname="+ccfname+"&cclname="+cclname+"&ccaddress="+ccaddress+"&cccity="+cccity+"&ccstate="+ccstate+"&cczip="+cczip;
	AjaxGetPayment(AJAXurl,"payment",1,true,true,"checkout_success.php");
}
//==============================================================================================================
//==============================================================================================================

function checkout() {
	window.location = "https://www.liquidplanetwaterpark.com/login.php?method=tickets";
}

function checkout_payment() {
	window.location = "https://www.liquidplanetwaterpark.com/checkout_payment.php";
}







function AjaxGetLogin(phpscript,divtag,vars,show,successurl) {  
   var http = false ;
    http = getHTTPObject();
	http.open("GET", phpscript, true);  
  		http.onreadystatechange = function() { 
        if (http.readyState == 4) {
        	if(http.status==200) { 
		  			var results = "" ;
          	results = http.responseText ;
	     			if (results=="ok" ) { //  if success 
		
							window.location = successurl;
						} else {
							getElement(divtag).innerHTML = results ;
						}
	      	} else {
				var msg = "Error: "+http.status+" Function/r/n script="+phpscript+" divtag=";
				msg += divtag+" vars="+vars+" show="+show;
          		alert(msg); //404 not found
          	} // end status 
	    } // end ready state 
     }   // function 
   http.send(null); 
 }
 
//==============================================================================================================
function login(destination) {
	var email = getElement("email").value;
	var pass = getElement("password").value;
	if (email=="" || pass=="") {
		alert("Email and Password is required");
	} else {
	
	var AJAXurl="ajax/Ajax_validate.php?email="+email+"&pass="+pass;
	AjaxGetLogin(AJAXurl,"notice",1,true,destination);
	}
}

function admin_login() {
	var user = getElement("admin_user").value;
	var pass = getElement("admin_password").value;
	var AJAXurl="http://www.liquidplanetwaterpark.com/ajax/Ajax_validate_admin.php?user="+user+"&pass="+pass;
	AjaxGetLogin(AJAXurl,"notice",1,true,"https://www.liquidplanetwaterpark.com");
}



function delete_item(orderdetailsid) {

	var AJAXurl="ajax/Ajax_delete_from_order.php?orderdetailsid="+orderdetailsid;
	AjaxGetRefresh(AJAXurl,"deleted",1,true,true);
//   window.location.reload();
}
function mypopup(pageid)
 {
  var mywindow;
   mywindow = window.open ("admin/edit.php?page="+pageid,"mywindow","location=1,status=0,scrollbars=1,width=800,height=600");
    mywindow.moveTo(10,10);
	return;
 } 
 
 