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 http1 = createRequestObject_com();
var http_bb_model_orders = createRequestObject_com();
var http_manual = createRequestObject_com();
var http_bymep = createRequestObject_com();
var http_refresh_api = createRequestObject_com();
var http_notification_retail_new = createRequestObject_com();
var http_notification_wholesale_new = createRequestObject_com();
var http_notification_feedback = createRequestObject_com();
var http_coupon = createRequestObject_com();
var http_com2 = createRequestObject_com();
var http_com_sp = createRequestObject_com();
var http_com_manufac = createRequestObject_com();
var http_com_modsp = createRequestObject_com();
var http_com_imei_check = createRequestObject_com();
var http3 = createRequestObject_com();
var http2 = createRequestObject_com();
var http_home_modellist = createRequestObject_com();
var http_home_modellist1 = createRequestObject_com();
var pass_id1 = "";
var pass_id_com2 = "";
var submit_imei_check = "";
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;
	
	if(document.frmorder && document.frmorder.category && document.frmorder.category.value=='')
	{
		//alert ("In Module for Making serivice Provider Null");
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Select Service Provider)</b></font>';	
	}
	else
	{
		http1.open('get', url1);
		http1.onreadystatechange = handleResponse_comm;
		//alert(para);
		http1.send(null);
	}
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_com_orderbymodel(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_orderbymodel;
	//alert(para);
	http.send(null);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}

function sndReq_com_homepage(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_homepage;
	//alert(para);
	//alert (document.getElementById('price_dis').innerHTML);
	http.send(null);
	//alert (document.getElementById('price_dis').innerHTML);
	//setTimeout("sndReq()", 60000); // Recursive JavaScript function calls sndReq() every 2 seconds
}
function sndReq_com_bb_model_orders(url,para,pass_id) {
	//pass_id1 = pass_id;
	
	//url="http://www.unlock2go.com/_getprice.php";
	var url1=url+para;
	http_bb_model_orders.open('get', url1);
	http_bb_model_orders.onreadystatechange = handleResponse_comm_bb_model_orders;
	//alert(para);
	http_bb_model_orders.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_retail_new.open('get', url1);
	http_notification_retail_new.onreadystatechange = handleResponse_comm_notification_new;
	http_notification_retail_new.send(null);
}

function sndReq_com_notification_whole(url,para) {

	var url1=url+para;
	if(notification_new_status==0)
		notification_new_status=1;
	notification_new_url=url;
	http_notification_wholesale_new.open('get', url1);
	http_notification_wholesale_new.onreadystatechange = handleResponse_comm_notification_whole;
	http_notification_wholesale_new.send(null);
}


function sndReq_com_notification_feedback(url,para) {
	
	var url1=url+para;
	if(notification_new_status==0)
		notification_new_status=1;
	notification_new_url=url;
	http_notification_feedback.open('get', url1);
	http_notification_feedback.onreadystatechange = handleResponse_comm_notification_feedback;
	http_notification_feedback.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) {
	//alert ("sndReq_com2");
	pass_id_com2 = pass_id2;
	//url="http://www.unlock2go.com/_getprice.php";
	var url1=url2+para2;
	if(document.frmorder && document.frmorder.category && document.frmorder.category.value=='')
	{
		//alert ("sp=0");
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Select Service Provider)</b></font>';
	}
	else
	{
		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_com_sp(url2,para2,pass_id2) {
	pass_id_com_sp = pass_id2;
	var url1=url2+para2;
	http_com_sp.open('get', url1);
	http_com_sp.onreadystatechange = handleResponse_comm_sp;
	http_com_sp.send(null);
}
function sndReq_com_modsp(url1,para1,pass_id1,url2,para2,pass_id2) {
	pass_id_com_modsp = pass_id1;
	var url1=url1+para1;
	http_com_modsp.open('get', url1);
	http_com_modsp.onreadystatechange = handleResponse_comm_modsp;
	http_com_modsp.send(null);
}
function sndReq_com_imei_check(url1,para1,submit) {
	submit_imei_check=submit;
	var url1=url1+para1;
	http_com_imei_check.open('get', url1);
	http_com_imei_check.onreadystatechange = handleResponse_comm_imei_check;
	http_com_imei_check.send(null);
}
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("&");
	//alert (para1_data_arr1[1]);
	para1_data_arr2 = para1_data_arr1[0].split("=");
	if(para1_data_arr1[1]=='cat_id=')
	{
		//alert ("frst");
		document.getElementById('model_id_dis').style.display='none';
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Select Service Provider)</b></font>';
		
		//document.getElementById('price_dis').innerHTML = '';
		return true;	
	}
	if(para1_data_arr2[0]=='?sp_id' && para1_data_arr2[1]==1)
	{
		//alert ("scnd");
		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')
	{
		//alert ("thrd");
		sndReq_com(url1,para1,pass_id1);
		showmodel(1);
	}
	else
	{
		//alert ("4th");
		sndReq_com(url2,para2,pass_id2);
		hidemodel();
	}
}
function model_list_new(url1,para1,pass_id1,url2,para2,pass_id2) {
	var manu_obj = document.frmorder.manu_id;
	para1_data_arr1 = para1.split("&");
	para1_data_arr2 = para1_data_arr1[0].split("=");
	if(para1_data_arr2[0]=='?manu_id' && para1_data_arr2[1]==1)
	{
		document.getElementById('sp_id_dis').style.display='none';
		document.getElementById('imei_id_dis').style.display='none';
		sndReq_com(url1,para1+"&auto=1",pass_id1);
		showmodel(1);
	}
	else
	{
		sndReq_com_sp(url2,para2,pass_id2);
		hidemodel();
	}
}

function home_show_service_privier(url1,para1,pass_id1,url2,para2,pass_id2) {
	
	
	
}


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 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 if(model_obj.value=='')
	{
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>Select Phone Model</b></font>';
	}
	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(http1.readyState == 4){
		var response = http1.responseText;
		document.getElementById(pass_id1).innerHTML = http1.responseText;
		var obj = document.getElementById("unlock_manu_id");
		var obj_manual = document.getElementById("manual");
		if(obj && !obj_manual)
		{
			//alert(obj);
			unlock_tooltip(obj);
		}
		var obj = document.getElementById("model_id");
		if(obj)
			unlock_tooltip(obj);
	}
}

function handleResponse_comm_homepage() {
	//alert(pass_id1+'anythinganything');
	document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http.readyState == 4){
		var response = http.responseText;
		if(document.getElementById('category').value=='')
		{
			document.getElementById(pass_id1).innerHTML ='<font color="#00000"><b>(Select Service Provider)</b></font>';
		}
		if(document.getElementById('category').value)
		{
			document.getElementById(pass_id1).innerHTML = http.responseText;
		}
		var obj = document.getElementById("unlock_manu_id");
		var obj_manual = document.getElementById("manual");
		if(obj && !obj_manual)
		{
			//alert(obj);
			unlock_tooltip(obj);
		}
	}
}

function handleResponse_comm_bb_model_orders() {
	//alert(pass_id1+'anythinganything');
	document.getElementById('price_dis').innerHTML = 'Loading...'; 
	if(http_bb_model_orders.readyState == 4){
		//alert ("where");
		var response = http_bb_model_orders.responseText;
		//alert (response);
		document.getElementById('price_dis').innerHTML = http_bb_model_orders.responseText;
		var obj = document.getElementById("unlock_manu_id");
		var obj_manual = document.getElementById("manual");
		if(obj && !obj_manual)
		{
			//alert(obj);
			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_retail_new.readyState == 4){
		
		var responsetxt = http_notification_retail_new.responseText;
		//alert(responsetxt);
		if(responsetxt=='block')
		{
			document.getElementById('notification_new').style.display='block';
			document.getElementById('notify_order').focus();
		}
		if(responsetxt=='block' || responsetxt=='none')
		{
			setTimeout("sndReq_com_notification_new(notification_new_url,'?type=notification_new');",5000);
		}
	}
}
function handleResponse_comm_notification_whole() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_notification_wholesale_new.readyState == 4){
		var responsewholesale = http_notification_wholesale_new.responseText;
		//alert(responsewholesale);
		if(responsewholesale=='block')
		{
			document.getElementById('notification_whole').style.display='block';
			document.getElementById('notify_whole').focus();
		}
		if(responsewholesale=='block' || responsewholesale=='none')
		{
			setTimeout("sndReq_com_notification_whole(notification_new_url,'?type=notification_whole');",5000);
		}
	}
}



function handleResponse_comm_notification_feedback() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...'; 
	if(http_notification_feedback.readyState == 4){
		
		var responsetxt = http_notification_feedback.responseText;
		//alert(responsetxt);
		var response_arr = responsetxt.split("|");
		if(response_arr[0]=='block' && document.getElementById('notification_feedback').style.display!='block')
		{
			if(document.getElementById('notification_feedback'))
			{
				if(response_arr[1])
					document.getElementById('notify_feedback').innerHTML="New Feedback has arrived for: "+response_arr[1];
				document.getElementById('notification_feedback').style.display='block';
			}
		}
		setTimeout("sndReq_com_notification_feedback(notification_new_url,'?type=notification_feedback');",30000);
	}
}
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 handleResponse_comm_sp() {
	document.getElementById(pass_id_com_sp).innerHTML = 'Loading...';
	if(http_com_sp.readyState == 4){
		var response_com_sp = http_com_sp.responseText;
		document.getElementById(pass_id_com_sp).innerHTML = http_com_sp.responseText;
		if(http_com_sp.responseText.length>1){
			document.getElementById('sp_id_dis').style.display = '';
			document.getElementById('imei_id_dis').style.display = '';
		}
		else{
			document.getElementById('sp_id_dis').style.display = 'none';
			document.getElementById('imei_id_dis').style.display = 'none';
			document.getElementById('phone_modal_dis').style.display = 'none';
		}
		var obj = document.getElementById("unlock_sp_id");
		if(obj)
		{
			unlock_tooltip(obj);
		}
	}
}
function handleResponse_comm_modsp() {
	document.getElementById(pass_id_com_modsp).innerHTML = 'Loading...';
	if(http_com_modsp.readyState == 4){
		var response_com_modsp = http_com_modsp.responseText;
		document.getElementById(pass_id_com_modsp).innerHTML = http_com_modsp.responseText;
	}
}


function handleResponse_comm_imei_check() {
	document.getElementById('price_dis').innerHTML = 'Loading...';
	if(http_com_imei_check.readyState == 4){
		var str_arr = http_com_imei_check.responseText.split("::",3);
		if(str_arr[0]=='1')
		{
			document.getElementById('ubase_tool').value = str_arr[1];
			if(document.frmorder.category.value=='20' || document.frmorder.category.value=='23')
				str_arr[2] = str_arr[2].replace('5 To 15 minutes','1 To 5 Hours');
			document.getElementById('price_dis').innerHTML = str_arr[2];
			document.getElementById('htc_api').value = "Y";
			if(submit_imei_check=='submit')
				document.frmorder.submit();
		}
		else if(str_arr[0]=='0')
		{
			//document.getElementById('price_dis').innerHTML = '';
			document.getElementById('htc_api').value = 'N';
			//if(submit_imei_check=='submit')
				alert('Your code is not available yet, try again in 10 days!');
				document.getElementById('price_dis').innerHTML = '';
				
		}
	}
}
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="list-style: square outside none;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="list-style: square outside none;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="list-style: square outside none;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;
}


/*
* function used to show the service privider based on manufacturer selected
* for homepage functionality
*/

function home_sndReq_com_sp(url2,para2,pass_id2){
	document.getElementById('price_dis').innerHTML = '<font color="#000"><b>(Select Service Provider) </b></font>';
	if(para2 != '?manu_id=more')
	{
		var manu_obj = document.frmorder.manu_id;
		if(manu_obj.value!=''){
			//alert (manu_obj.value);
			if(manu_obj.value=='1')
			{
				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="list-style: square outside none;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>';
					//alert (document.getElementById('price_dis').innerHTML);
				//document.getElementById('price_dis').innerHTML = 'Select Modal';
			}
			else
			{
				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="list-style: square outside none;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('price_dis').innerHTML = 'Select Modal';
			}
			pass_id_com_sp = pass_id2;
			var url1=url2+para2;
			http_com_sp.open('get', url1);
			http_com_sp.onreadystatechange = handleResponse_comm_sp_home;
			http_com_sp.send(null);
		}
		else{
			document.getElementById('sp_id_dis').style.display = 'none';
			document.getElementById('imei_id_dis').style.display = 'none';
			document.getElementById('phone_modal_dis').style.display = 'none';
			document.getElementById('prd_no_dis').style.display = 'none';
			document.getElementById('model_id_dis').style.display = 'none';
			document.getElementById('price_dis').innerHTML = '<font color="#000"><b>(Select Manufacturer) </b></font>';	
		}
	}
	// alert (url2);
	 else
	{
		document.getElementById('manu_id').innerHTML="<option value=''>Loading...</option>";
		document.getElementById('sp_id_dis').style.display = 'none';
		document.getElementById('imei_id_dis').style.display = 'none';
		document.getElementById('phone_modal_dis').style.display = 'none';
		document.getElementById('prd_no_dis').style.display = 'none';
		document.getElementById('model_id_dis').style.display = 'none';
		document.getElementById('price_dis').innerHTML = '<font color="#000"><b>(Select Manufacturer) </b></font>';	
		http_com_manufac.open("get","_ajaxprocess.php?action=more",true);
		http_com_manufac.onreadystatechange = function(){
			$('#manu_id').html(http_com_manufac.responseText);
		//document.getElementById('manu_id').innerHTML= http_com_manufac.responseText;
		}
		http_com_manufac.send(null);
		alert("Manufacturer list has been updated");
	}
}


function populate_manu_list(manu_value,cat_value)
{
	if(manu_value == "more" )
	{	
		http_com_manufac.open("get","_ajaxprocess.php?action=more_order_page&cat_value="+cat_value,true);
		http_com_manufac.onreadystatechange = function(){
			$('#manu').html(http_com_manufac.responseText);
		//document.getElementById('manu_id').innerHTML= http_com_manufac.responseText;
		}
		http_com_manufac.send(null);
		alert("Manufacturer list has been updated");
	}
}

function handleResponse_comm_sp_home(){
	if(document.getElementById('sp_id_dis').style.display=='none')
		document.getElementById('sp_id_dis').style.display='';
	document.getElementById(pass_id_com_sp).innerHTML = 'Loading...';
	var manu_obj = document.frmorder.manu_id;
	//document.getElementById('price_dis').innerHTML = '';
	if(manu_obj.value!=1){
		document.getElementById('phone_modal_dis').style.display = '';
		document.getElementById('phone_modal').value = '';
		document.getElementById('model_id_dis').style.display = 'none';
		document.getElementById('prd_no_dis').style.display = 'none';
	}
	else{
		document.getElementById('phone_modal_dis').style.display = 'none';
	}
	
	if(http_com_sp.readyState == 4){
		var response_com_sp = http_com_sp.responseText;
		document.getElementById(pass_id_com_sp).innerHTML = http_com_sp.responseText;
		if(http_com_sp.responseText.length>1){
			document.getElementById('sp_id_dis').style.display = '';
			document.getElementById('imei_id_dis').style.display = '';
		}
		else{
			document.getElementById('sp_id_dis').style.display = 'none';
			document.getElementById('imei_id_dis').style.display = 'none';
		}
		var obj = document.getElementById("category");
		if(obj)
		{
			unlock_tooltip(obj);
		}
	}

}

/*function home_model_list(url1,para1,pass_id1,url2,para2,pass_id2) {
	//alert (document.getElementById('manu_id').value);
	if(document.getElementById('category') && document.getElementById('category').value)
	{
		//alert ("in here");
		document.getElementById('price_dis').innerHTML='';
	}
	if(document.getElementById('manu_id') && document.getElementById('manu_id').value=='4')
	{
		//alert ("in here");
		if(document.getElementById('imei_no').value=='')
		{
			document.getElementById('price_dis').innerHTML='<font color="#000"><b>(Enter IMEI Number) </b></font>';
		}
	}
	

	var manu_obj = document.frmorder.manu_id;
	var sp_obj	 = document.frmorder.category;
	//document.getElementById('price_dis').innerHTML = '';
	var para = "?manu_id="+manu_obj.value+"&sp_id="+sp_obj.value+'&auto=1';
	//alert (manu_obj.value);
	if(manu_obj.value==1 && sp_obj.value!=''){
		//alert ("vikash");
		//alert ("blackberry and service provider any thing");
		home_modellist_request(url1,para,pass_id1);
		showmodel(1);
		//alert (document.getElementById('price_dis').innerHTML);
	}else{
		document.getElementById('model_id_dis').style.display = 'none';
		document.getElementById('prd_no_dis').style.display = 'none';
	}
	if(document.getElementById('category') && document.getElementById('category').value=='')
	{
		//alert ("should work");
		//alert (document.getElementById('price_dis').innerHTML);
		document.getElementById('price_dis').innerHTML='<font color="#000"><b>(Select Service Provider) </b></font>';
		//alert (document.getElementById('price_dis').innerHTML);
	}
}
function home_modellist_request(url,para,pass_id) {
	pass_id1 = pass_id;
	var url1=url+para;
	http_home_modellist.open('get', url1);
	http_home_modellist.onreadystatechange = handleResponse_modellist;
	http_home_modellist.send(null);
}

function handleResponse_modellist() {
	//document.getElementById(pass_id1).innerHTML = 'Loading...67'; 
	if(http_home_modellist.readyState == 4){
		var response = http_home_modellist.responseText;
		document.getElementById('model_dis').innerHTML = http_home_modellist.responseText;
		var obj = document.getElementById("model_id");
		var obj_manual = document.getElementById("manual");
		if(obj && !obj_manual)
		{
			unlock_tooltip(obj);
		}
	}
}*/



function reset_price()
{
	if(document.getElementById('price_dis'))
		document.getElementById('price_dis').innerHTML = '';
}



//order page change
function model_list2(url1,para1,pass_id1,url2,para2,pass_id2,pagename) {
	/*vivek*/
	var manu_obj = document.frmorder.manu;
	var para3='';
	if(pagename!=null && pagename!=undefined && pagename!='')
		para3="&pagename="+pagename;
		
	document.getElementById('phone_modal').value = '';
	if(manu_obj.options[manu_obj.selectedIndex].text=='Blackberry')
	{
		//commented this as we need to load the price as well for blackberry selected.
		//sndReq_com(url1,para1+'&page=2',pass_id1);
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Select Phone Model)</b></font>';
		
		http_home_modellist.open('get', url2+para2+para3);
		http_home_modellist.onreadystatechange = function(){
			if(http_home_modellist.readyState == 4){
				var response = http_home_modellist.responseText;
				document.getElementById(pass_id2).innerHTML = http_home_modellist.responseText;
			}
		};
		http_home_modellist.send(null);
		
		
		
		http_home_modellist1.open('get', url1+para1+para3+'&page=2');
		http_home_modellist1.onreadystatechange = function(){
			if(http_home_modellist1.readyState == 4){
				var response = http_home_modellist1.responseText;
				document.getElementById(pass_id1).innerHTML = http_home_modellist1.responseText;
			}
		};
		http_home_modellist1.send(null);
		showmodel(document.frmorder.manu.value);
	}
	else if(manu_obj.value==4)
	{
			//this condition is for HTC
			
		//sndReq_com(url2,para2,pass_id2);
		if(document.frmorder.imei_no.value=='')
		{
			document.getElementById('price_dis').innerHTML = '<font color="#00000"><b>(Enter IMEI Number)</b></font>';
		}
		else
		{
			document.getElementById('price_dis').innerHTML = '<font color="#00000"><b>(Enter Phone Modal)</b></font>';
		}
		
		//document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Enter IMEI Number)</b></font>';	
		hidemodel();
	}
	else if(manu_obj.value=='')
	{
		document.getElementById('price_dis').innerHTML='<font color="#00000"><b>(Select Manufacturer)</b></font>';	
		hidemodel();
	}
	else
	{
		sndReq_com(url2,para2,pass_id2);
		hidemodel();
	}
}

//ordebymodel change
function ask_imei_number(ask_imei)
{
	var current_manu = document.getElementById('current_manu_name').value;
	if(ask_imei!="" && current_manu==1)
	{
		imei_onfocus();	
		/*if(document.frmorder.imei_no.value=='')
		{
			document.getElementById('price_dis').innerHTML = '<font color="#00000"><b>(Enter IMEI Number)</b></font>';
		}
		else
		{
			imei_onfocus();	
		}*/
	}
	else if(ask_imei!="" && current_manu==4)
	{
		if(document.frmorder.imei_no.value=='')
		{
			document.getElementById('price_dis').innerHTML = '<font color="#00000"><b>(Enter IMEI Number)</b></font>';
		}
		else
		{
			alert('Your code is not available yet, try again in 10 days!');
		}
	}
	else if(ask_imei!="" && current_manu!=1 && current_manu!=4)
	{
		imei_onfocus();
	}
	else
	{
		document.getElementById('price_dis').innerHTML = '<font color="#000"><b>(Select Service Provider) </b></font>';	
	}
}

