// JavaScript Document
function startAjax() {
	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!");
  		}
		
	return xmlhttp;
}

function GetNetworks(value,divID) {
	var xmlhttp;
	xmlhttp = startAjax();
	xmlhttp.onreadystatechange=function() { 
		if (xmlhttp.readyState==4) {
				document.getElementById(divID).innerHTML = xmlhttp.responseText;
			
		}	
	
	}
	xmlhttp.open("GET","getnetwork_list.php?ID="+divID+"&make="+value,true);
	xmlhttp.send(null);			
}

function GetNetworkPrice(retailname,divID) {
	var retailname;
	var divID;
	var xmlhttp;
	retailname = escape(retailname);
	xmlhttp = startAjax();
	xmlhttp.onreadystatechange=function() { 
		if (xmlhttp.readyState==4) {
				document.getElementById(divID).innerHTML = xmlhttp.responseText;
				//alert(xmlhttp.responseText);
		}	
	}
	xmlhttp.open("GET","getnetwork_list.php?ID="+divID+"&retailname="+retailname,true);
	xmlhttp.send(null);		
	
}

function CheckEmail() {
	email_first = document.paypalform.os3.value;
	email_second = document.paypalform.confirm_email.value;
	if (email_first == "" || email_second == "") {
		alert("Please enter a valid E-mail address");
		document.paypalform.os3.value = "";
		document.paypalform.confirm_email.value = "";
		document.paypalform.os3.focus();
	}
	else if (email_first != email_second) {
		alert("Emails do not match please try again");
		document.paypalform.os3.value = "";
		document.paypalform.confirm_email.value = "";
		document.paypalform.os3.focus();
		
	}
	else {
		document.paypalform.os3.style.backgroundColor = "#c4ffcc";
		document.paypalform.confirm_email.style.backgroundColor =" #c4ffcc";
	}
	
;
}

function Signup_Select(value) {
	if (value == "reseller") {
		document.getElementById('signup_content').style.display = "block";
	}
	else if (value == "individual") {
		window.location = "buy_unlockcode_now.php";
	}
}

function check_form() {
	//Check paypalform 
	var email = document.paypalform.os3.value;
	var imei = document.paypalform.os0.value;
	var make = document.paypalform.os1.value;
	var model = document.paypalform.os2.value;
	var network = document.paypalform.network.value;
	
	//begin form check
	
	if (email == "" || email == null) {
		alert("Invalid E-mail");
		return false;
	}
	else if (imei == "" || imei == null) {
		alert ("You need a valid IMEI number");
		return false;
	}
	else if (make == "0") {
		alert ("You need to specify the make of your device.");
		return false;
	}	
	else if (model == "" || model == null) {
		alert ("Please specify the model of your device");
		return false;
	}	
	else if (network == "0") {
		alert ("You need to specify the network of your device");
		return false;
	}	
	else {
		return true;
	}
	
	
}


	
