// JavaScript Document
//********* for checkout_shipping.php ********** 
function checkvoucher_code()
{
		if(document.frmmycart.Voucher_Code.value!='')
		{
document.getElementById("vmsg").innerHTML="<img src='images/loader.gif'> Verifying the Promotional Code.";
			http.open("GET", "./checkvoucher.php?vcode=" + escape(document.frmmycart.Voucher_Code.value), true);
			http.onreadystatechange = handleHttpResponse_1s;
			http.send(null);
		}
}


function handleHttpResponse_1s() 
{
  if (http.readyState == 4) 
  {  
	results = http.responseText.split("*");
	
	if(results[1]==900)
	{
		document.getElementById("vmsg").innerHTML="Invalid Promotional Code ("+document.frmmycart.Voucher_Code.value+").<br>Please verify the code & enter again.";
		document.frmmycart.Voucher_Code.value="";
		document.frmmycart.Voucher_Code.focus();
		return false;
	}
	if(results[1]==001)
	{
		document.getElementById("vmsg").innerHTML="You have already used "+document.frmmycart.Voucher_Code.value+" Promotional Code once.";
		document.frmmycart.Voucher_Code.value="";
		document.frmmycart.Voucher_Code.focus();
		return false;
	}
	if(results[1]==999)
	{
		document.location="?code="+results[0];
		//document.getElementById("vmsg").innerHTML="<font color=green>Promotional Code Verification OK</font>";
	}
	
	
  }
}

function getHTTPObject() 
{
  var xmlhttp;
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); 


//================ for clubcard points.........
function checkcard_points(){
	if(document.frmmycart.Club_Card.value!=""){
			if(isNaN(document.frmmycart.Club_Card.value) || parseInt(document.frmmycart.Club_Card.value)<0 ){
				document.getElementById("cardmsg").innerHTML="Invalid card point.";
				document.frmmycart.Club_Card.value=""
				document.frmmycart.Club_Card.focus();
				return false;
			}else {
				if (parseInt(document.frmmycart.Club_Card.value)>parseInt(document.frmmycart.card_points.value)){
					document.getElementById("cardmsg").innerHTML="You can use up to "+document.frmmycart.card_points.value + " card point(s)";
					document.frmmycart.Club_Card.value=""
					document.frmmycart.Club_Card.focus();
					return false;
				}else{					
					document.getElementById("cardmsg").innerHTML="<font color='green'>Your card point(s) accepted.</font>";
					document.location="?usedpoints="+document.frmmycart.Club_Card.value;
				}
			}
	}
}

