function createRequestObject_com() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject_com();
var http_manual = createRequestObject_com();
var http_bymep = createRequestObject_com();
var http_refresh_api = createRequestObject_com();
var http_notification_new = createRequestObject_com();
var http_coupon = createRequestObject_com();
var http_com2 = createRequestObject_com();
var http3 = createRequestObject_com();
var http2 = createRequestObject_com();
var pass_id1 = "";
var pass_id_com2 = "";
var notification_new_url="";
var notification_new_status=0;
function sndReq_com(url,para,pass_id) {
	pass_id1 = pass_id;
	
	//url="http://www.unlock2go.com/_getprice.php";
	var url1=url+para;
	
	http.open('get', url1);
	http.onreadystatechange = handleResponse_comm;
	//alert(para);
	http.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_com_manual(url,para,pass_id) {
	pass_id1 = pass_id;
	
	//url="http://www.unlock2go.com/_getprice.php";
	var url1=url+para;
	
	http_manual.open('get', url1);
	http_manual.onreadystatechange = handleResponse_comm_manual;
	//alert(para);
	http_manual.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_com_bymep(url,para) {
	var url1=url+para;
	
	http_bymep.open('get', url1);
	http_bymep.onreadystatechange = handleResponse_comm_bymep;
	http_bymep.send(null);
}
function sndReq_com_refresh_api(url,para) {
	var url1=url+para;
	
	http_refresh_api.open('get', url1);
	http_refresh_api.onreadystatechange = handleResponse_comm_refresh_api;
	http_refresh_api.send(null);
}
function sndReq_com_notification_new(url,para) {
	var url1=url+para;
	if(notification_new_status==0)
		notification_new_status=1;
	notification_new_url=url;
	http_notification_new.open('get', url1);
	http_notification_new.onreadystatechange = handleResponse_comm_notification_new;
	http_notification_new.send(null);
}
function sndReq_com_coupon(url,para) {
	var url1=url+para;
	
	http_coupon.open('get', url1);
	http_coupon.onreadystatechange = handleResponse_comm_coupon;
	http_coupon.send(null);
}
function sndReq_com2(url2,para2,pass_id2) {
	pass_id_com2 = pass_id2;
	//url="http://www.unlock2go.com/_getprice.php";
	var url1=url2+para2;
	
	http_com2.open('get', url1);
	http_com2.onreadystatechange = handleResponse_comm2;
	//alert(para);
	http_com2.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_mep(url,para,pass_id) {
	pass_id1 = pass_id;
	
	//url='http://www.unlock2go.com/_getprice.php';
	var url1=url+para;
	http2.open('get', url1);
	http2.onreadystatechange = handleResponse_mep;
	//alert(para);
	http2.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_mep2(url,para,pass_id) {
	pass_id1 = pass_id;
	//url='http://www.unlock2go.com/_getprice.php';
	var url1=url+para;

	http2.open('get', url1);
	http2.onreadystatechange = handleResponse_mep2;
	//alert(para);
	http2.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_unlock(url,para) {
	//url='http://www.unlock2go.com/_getprice.php';
	var url1=url+para;
	
	http3.open('get', url1);
	http3.onreadystatechange = handleResponse_unlock;
	//alert(url1);
	http3.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function model_list(url1,para1,pass_id1,url2,para2,pass_id2) {
	var manu_obj = document.frmorder.manu_id;
	//alert(manu_obj.options[manu_obj.selectedIndex].text);
	para1_data_arr1 = para1.split("&");
	para1_data_arr2 = para1_data_arr1[0].split("=");
	if(para1_data_arr2[0]=='?sp_id' && para1_data_arr2[1]==1)
	{
		sndReq_com(url1,para1+"&auto=1",pass_id1);
		sndReq_com2(url2,para2,pass_id2);
		showmodel(1);
	}
	else if(manu_obj!=undefined && manu_obj.options[manu_obj.selectedIndex].text=='Blackberry')
	{
		sndReq_com(url1,para1,pass_id1);
		showmodel(1);
	}
	else
	{
		sndReq_com(url2,para2,pass_id2);
		hidemodel();
	}
}
function model_list_manual(url1,para1,pass_id1) {
	var manu_obj = document.frmorder.manu_id;
	sndReq_com(url1,para1,pass_id1);
	showmodel_manual(1);
}
function model_list2(url1,para1,pass_id1,url2,para2,pass_id2) {
	var manu_obj = document.frmorder.manu;
	//alert(manu_obj.options[manu_obj.selectedIndex].text);
	if(manu_obj.options[manu_obj.selectedIndex].text=='Blackberry')
	{
		sndReq_com(url1,para1+'&page=2',pass_id1);
		showmodel(document.frmorder.manu.value);
	}
	else
	{
		sndReq_com(url2,para2,pass_id2);
		hidemodel();
	}
}
function mep_list(url1,para1,pass_id1,url2,para2,pass_id2) {
	var manu_obj = document.frmorder.manu_id;
	var model_obj = document.frmorder.model_id;
	//alert(manu_obj.options[manu_obj.selectedIndex].text);
	if(manu_obj.options[manu_obj.selectedIndex].text=='Blackberry' && model_obj.value!='')
	{
		sndReq_mep(url1,para1,pass_id1);
		setTimeout("showmep("+document.frmorder.manu_id.value+",'"+url2+"')",800);
	}
	else
	{
		sndReq_com(url2,para2,pass_id2);
		hidemep();
	}
}
function mep_list2(url1,para1,pass_id1,url2,para2,pass_id2) {
	var manu_obj = document.frmorder.manu;
	var model_obj = document.frmorder.model_id;
	//alert(manu_obj.options[manu_obj.selectedIndex].text);
	if(manu_obj.options[manu_obj.selectedIndex].text=='Blackberry' && model_obj.value!='')
	{
		sndReq_mep2(url1,para1+'&page=2',pass_id1);
		setTimeout("showmep2("+document.frmorder.manu.value+",'"+url2+"')",800);
	}
	else
	{
		sndReq_com(url2,para2,pass_id2);
		hidemep();
	}
}

function handleResponse_unlock() {
	document.getElementById('unlock').value = 'Loading...'; 
	if(http3.readyState == 4){
		var response = http3.responseText;
		document.getElementById('unlock').value = http3.responseText;
		document.frmorder.submit();
	}
}
function handleResponse_mep() {
//	document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http2.readyState == 4){
		//alert("got ajax response");
		var response = http2.responseText;
		//alert(document.getElementById(pass_id1)+"5"+response);
		document.getElementById('mep_dis').innerHTML = response; 
		//alert(document.getElementById(pass_id1).innerHTML);
		//document.getElementById(pass_id1).innerHTML = response;
		//alert("damn"+document.getElementById(pass_id1).innerHTML);
		//alert(document.frmorder.http_host.value+'/_getprice.php','?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu_id.value,'price_dis');
		sndReq_com(document.frmorder.http_host.value+'/_getprice.php','?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu_id.value,'price_dis');
	}
}
function handleResponse_mep2() {
	document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http2.readyState == 4){
		var response = http2.responseText;
		document.getElementById(pass_id1).innerHTML = http2.responseText;
		//alert(document.frmorder.http_host.value+'/_getprice.php','?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu_id.value,'price_dis');
		sndReq_com(document.frmorder.http_host.value+'/_getprice.php','?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu.value,'price_dis');
	}
}
function handleResponse_comm() {
	//alert(pass_id1+'anythinganything');
	document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById(pass_id1).innerHTML = http.responseText;
		var obj = document.getElementById("unlock_manu_id");
		var obj_manual = document.getElementById("manual");
		if(obj && !obj_manual)
		{
			unlock_tooltip(obj);
		}
	}
}
function handleResponse_comm_manual() {
	//alert(pass_id1+'anythinganything');
	document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_manual.readyState == 4){
		var response = http_manual.responseText;
		document.getElementById(pass_id1).style.display = 'none';
		document.getElementById('manu_id_dis').style.display = 'none';
		document.getElementById(pass_id1).innerHTML = http_manual.responseText;
		var host=document.getElementById('http_host').value;
		model_list_manual(host+'/_getmodelcombo.php','?sp_id=1&cat_id='+document.frmorder.category.value+'&auto=1','model_dis');
	}
}
function handleResponse_comm_bymep() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_bymep.readyState == 4){
		var response = http_bymep.responseText;
		if(response=='success')
		{
			document.unlockForm.submit();
		}
		else
		{
			var r=confirm(response);
			if(r)
				document.unlockForm.submit();
			else
				alert("You decided to stop processing of your request!");
		}
	}
}
function handleResponse_comm_refresh_api() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_refresh_api.readyState == 4){
		document.getElementById('refresh_api').innerHTML='[ Refresh API ]';
	}
}
function handleResponse_comm_notification_new() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_notification_new.readyState == 4){
		var responsetxt = http_notification_new.responseText;
		if(responsetxt=='block')
		{
			document.getElementById('notification_new').style.display='block';
			document.getElementById('notify').focus();
		}
		if(responsetxt=='block' || responsetxt=='none')
		{
			setTimeout("sndReq_com_notification_new(notification_new_url,'?type=notification_new');",5000);
		}
	}
}
function handleResponse_comm_coupon() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_coupon.readyState == 4){
		document.getElementById('refresh_api').innerHTML=http_coupon.responseText;
	}
}
function handleResponse_comm2() {
	//alert(pass_id1+'anythinganything');
	document.getElementById(pass_id_com2).innerHTML = 'Loading...'; 
	if(http_com2.readyState == 4){
		var response_com2 = http_com2.responseText;
		document.getElementById(pass_id_com2).innerHTML = http_com2.responseText;
	}
}
function showmep(val,url){
	if(val!=""){
		if(document.frmorder.mep_id && document.frmorder.mep_id.value!='')
		{
			//document.getElementById('mep_id_dis').style.display = '';
		}
		else
		{
			document.getElementById('mep_id_dis').style.display = 'none';
			sndReq_com(url,'?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu_id.value,'price_dis');
		}
	}else{
		document.getElementById('mep_id_dis').style.display = 'none';
	}
}
function showmep2(val,url){
	if(val!=""){
		if(document.frmorder.mep_id && document.frmorder.mep_id.value!='')
		{
			//document.getElementById('mep_id_dis').style.display = '';
		}
		else
		{
			document.getElementById('mep_id_dis').style.display = 'none';
			sndReq_com(url,'?sp_id='+document.frmorder.category.value+'&manu_id='+document.frmorder.manu.value,'price_dis');
		}
	}else{
		document.getElementById('mep_id_dis').style.display = 'none';
	}
}
function showmodel(val){
	if(val!=""){
		document.getElementById('model_id_dis').style.display = '';
		document.getElementById('prd_no_dis').style.display = '';
		if(document.getElementById('digits_msg'))
			document.getElementById('digits_msg').innerHTML = '(15 Digits) ';
		if(document.getElementById('imei_hint'))
			document.getElementById('imei_hint').innerHTML = 'Use one of the following options to get the IMEI number: <ol style="padding-left:20px;"><li>Go to Menu>Options>Status</li><li>Go to Menu>Settings>Options>Status</li><li>Press *#06# on keypad</li><li>Look at the white sticker at the back of the phone behind the battery.</li></ol>';
		document.getElementById('phone_modal_dis').style.display = 'none';
		document.getElementById('phone_modal').value = 'model';
	}else{
		document.getElementById('model_id_dis').style.display = 'none';
		document.getElementById('prd_no_dis').style.display = 'none';
		if(document.getElementById('digits_msg'))
			document.getElementById('digits_msg').innerHTML = '(15-17 Digits) ';
		if(document.getElementById('imei_hint'))
			document.getElementById('imei_hint').innerHTML = 'Use one of the following options to get the IMEI number: <ol style="padding-left:20px;"><li>Press *#06# on keypad</li><li>Look at the white sticker at the back of the phone behind the battery.</li></ol>';
		document.getElementById('mep_id_dis').style.display = 'none';
		document.getElementById('phone_modal_dis').style.display = '';
		document.getElementById('phone_modal').value = '';
	}
}
function showmodel_manual(val){
		document.getElementById('model_id_dis').style.display = '';
		document.getElementById('phone_modal_dis').style.display = 'none';
		document.getElementById('phone_modal').value = 'model';
}
function hidemodel(){
	document.getElementById('model_id_dis').style.display = 'none';
	document.getElementById('prd_no_dis').style.display = 'none';
	if(document.getElementById('digits_msg'))
		document.getElementById('digits_msg').innerHTML = '(15-17 Digits) ';
	if(document.getElementById('imei_hint'))
		document.getElementById('imei_hint').innerHTML = 'Use one of the following options to get the IMEI number: <ol style="padding-left:20px;"><li>Press *#06# on keypad</li><li>Look at the white sticker at the back of the phone behind the battery.</li></ol>';
	document.getElementById('model_dis').innerHTML='';
	document.getElementById('mep_id_dis').style.display = 'none';
	document.getElementById('mep_dis').innerHTML='';
	document.getElementById('phone_modal_dis').style.display = '';
	document.getElementById('phone_modal').value = '';
}
function hidemep(){
	document.getElementById('mep_id_dis').style.display = 'none';
	document.getElementById('mep_dis').innerHTML='';
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}