// JavaScript Document

function check_email(value) {
	var email = document.paypalform.os3.value;
	var confirm_email = document.paypalform.confirmemail.value;
	
	if (email != confirm_email) {
			alert("E-mails do not match!  Please try again!");
			return false;
	}
	else if ((email == "") && (confirm_email == "")) {
			alert("E-mail cannot be blank!  Please try again!");
			return false;
	}
	else {
			return true;
	}
	
}

function isNumeric(value) {
	var numericExpression = /^[0-9]+$/;
	if (value.match(numericExpression)) {
		return true;
	}

}
function checkform () {
	var imeinum = document.orderform.imeinum.value;
	
	if (document.orderform.phonenetwork.value == "0") {
		alert("You need to specify the phone's network!");
		return false;
	}
	else if (document.orderform.phonemake.value == "0") {
		alert("You need to specify the make of your device!");
		return false;
	}
	else if (document.orderform.phonemodel.value == "") {	
		alert("You need to specify the model of your phone!");
		return false;
	}
	else if ((imeinum.length < 15) || (!isNumeric(imeinum))) {
		alert("You need to enter a valid IMEI number! Please make sure it only you enter 15-17 numeric characters!");
		return false;		
	}
	else if ((imeinum.charAt(0) == "3") || (imeinum.charAt(0) == "0") || (imeinum.charAt(0) == "9")) {
		return true;
	}
	else {
		alert("Your IMEI you have provided is not valid! Please make sure the first digit begins with a 3,0 or 9!");
		return false;
	}
}
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   document.orderform.submit();
   return false;
   }
else
   return true;
}


function ajaxFunction(ID,Param)
   {
	var xmlhttp;
	
	if (window.XMLHttpRequest)
  		{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
	    }
	else if (window.ActiveXObject)
  		{
  		// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			if (!xmlhttp)
			{
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
 		 }
	else
  		{
  			alert("Your browser does not support AJAX!");
  		}


      
      xmlhttp.onreadystatechange=function()
      {
         if(xmlhttp.readyState==4)
           {

                      
			
			document.getElementById(ID).innerHTML = xmlhttp.responseText;
			
           }
      }
       xmlhttp.open("GET","getinfo.php?ID="+ID+"&param="+Param,true);
       xmlhttp.send(null);
   }