// JavaScript Document

var xmlHttp

var xmlHttp2

var site_path = "http://www.cheap-mobile-deals.com";

//======================== REVIEW ===========================>>

function FillReview(productName)

{ 

	xmlHttp2=GetXmlHttpObject()

	

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	//if (compid!="" && dealtype !="")

	//{

		var url=site_path+"/ajax/addreviews.php"

		url=url+"?compid="+productName;

				

		xmlHttp2.onreadystatechange = function stateChanged()

		{

			document.getElementById("systemWorking").style.display="block";

			if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

			{ 

				document.getElementById("tcontent3").innerHTML=xmlHttp2.responseText;

				document.getElementById("systemWorking").style.display="none";

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp2.open("GET",url,true)

		xmlHttp2.send(null)

//	}

}

function writeReview()

{ 

	xmlHttp2=GetXmlHttpObject()

	var desc = document.getElementById('desc').value;

	var rating = document.getElementById('rateval').value;

	var modelid = document.getElementById('modelid').value;

	if(desc == ""){

		alert("Please enter description!!");

		return false;

	}

	

	if(rating == ""){

		alert("Please select your rate!!");

		return false;

	}

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	//if (compid!="" && dealtype !="")

	//{

		var url=site_path+"/ajax/writereviews.php"

		url=url+"?rate="+rating;

		url=url+"&desc="+desc;

		url=url+"&modelid="+modelid;

			

		xmlHttp2.onreadystatechange = function stateChanged()

		{

			document.getElementById("systemWorking").style.display="block";

			if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

			{ 

				document.getElementById("tcontent3").innerHTML=xmlHttp2.responseText;

				document.getElementById("systemWorking").style.display="none";

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp2.open("GET",url,true)

		xmlHttp2.send(null)

//	}

}





function ratingVal(val)

{ 

	 

	document.getElementById("myrating").innerHTML="<input type='hidden' name='rateval' id='rateval' value="+val+" />";				

			

}

//====================== END REWIEW========================>>

function FillModels(compid,dealtype)

{ 



	xmlHttp2=GetXmlHttpObject()

	

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	//if (compid!="" && dealtype !="")

	//{

		var url=site_path+"/ajax/phone-models.php"

		url=url+"?compid="+compid

		url=url+"&dealtype="+dealtype

		//alert(url);

		xmlHttp2.onreadystatechange = function stateChanged()

		{

			document.getElementById("systemWorking").style.display="block";

			if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

			{ 

				document.getElementById("spModel").innerHTML=xmlHttp2.responseText;

				document.getElementById("systemWorking").style.display="none";

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp2.open("GET",url,true)

		xmlHttp2.send(null)

//	}

}



function FillNetwork(modelid,dealtype)

{ 



	xmlHttp2=GetXmlHttpObject()

	

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	

//	if (modelid!="" && dealtype !="")

//	{

		var url=site_path+"/ajax/Network.php"

		url=url+"?modelid="+modelid

		url=url+"&dealtype="+dealtype

	

		xmlHttp2.onreadystatechange = function stateChanged()

		{

			document.getElementById("systemWorking").style.display="block";

			if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

			{ 

				document.getElementById("spNetwork").innerHTML=xmlHttp2.responseText;

				document.getElementById("systemWorking").style.display="none";

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp2.open("GET",url,true)

		xmlHttp2.send(null)

//	}

}



function FillCompNetwork(modelid,dealtype)

{ 

var xmlHttp22

	xmlHttp22=GetXmlHttpObject()

	

	if (xmlHttp22==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	

	if (modelid!="" && dealtype !="")

	{

		var url=site_path+"/ajax/Comp_Network.php"

		url=url+"?modelid="+modelid

		url=url+"&dealtype="+dealtype

		

		xmlHttp22.onreadystatechange = function stateChanged()

		{

			if (xmlHttp22.readyState==4 || xmlHttp22.readyState=="complete")

			{ 

				document.getElementById("spNetwork").innerHTML=xmlHttp22.responseText 

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp22.open("GET",url,true)

		xmlHttp22.send(null)

	}

}

function FillCompMnt(modelid,dealtype,cmp)

{ 

var xmlHttp33

	xmlHttp33=GetXmlHttpObject()

	

	if (xmlHttp33==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	

	if (modelid!="" && dealtype !="")

	{

		var url=site_path+"/ajax/Comp_Minute.asp"

		url=url+"?modelid="+modelid

		url=url+"&dealtype="+dealtype+"&cmp="+cmp

		

		xmlHttp33.onreadystatechange = function stateChanged()

		{

			if (xmlHttp33.readyState==4 || xmlHttp33.readyState=="complete")

			{ 

				document.getElementById("spCompMnt").innerHTML=xmlHttp33.responseText 

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp33.open("GET",url,true)

		xmlHttp33.send(null)

	}

}

function FillModMnt(modelid,dealtype,cmp)

{ 

var xmlHttp44

	xmlHttp44=GetXmlHttpObject()

	

	if (xmlHttp44==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	

	if (modelid!="" && dealtype !="")

	{

		var url=site_path+"/ajax/Mod_Minute.php"

		url=url+"?modelid="+modelid

		url=url+"&dealtype="+dealtype+"&cmp="+cmp

		

		xmlHttp44.onreadystatechange = function stateChanged()

		{

			if (xmlHttp44.readyState==4 || xmlHttp44.readyState=="complete")

			{ 

				document.getElementById("spCompMnt").innerHTML=xmlHttp44.responseText 

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp44.open("GET",url,true)

		xmlHttp44.send(null)

	}

}

function FillTypeMnt(modelid,dealtype)

{ 

var xmlHttp55

	xmlHttp55=GetXmlHttpObject()

	

	if (xmlHttp55==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	

	if (modelid!="" && dealtype !="")

	{

		var url=site_path+"/ajax/Type_Minute.php"

		url=url+"?modelid="+modelid

		

		xmlHttp55.onreadystatechange = function stateChanged()

		{

			if (xmlHttp55.readyState==4 || xmlHttp55.readyState=="complete")

			{ 

				document.getElementById("spCompMnt").innerHTML=xmlHttp55.responseText 

			} 

			//else

	//		{

	//			document.getElementById("spModel").innerHTML="Please wait...."

	//		}

		}

		xmlHttp55.open("GET",url,true)

		xmlHttp55.send(null)

	}

}

function FillDealType(modelid)

{ 



	xmlHttp2=GetXmlHttpObject()

	

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}		

	if(modelid!="")

	{

	var url=site_path+"/ajax/deal-type.php"

	url=url+"?modelid="+modelid

	

	xmlHttp2.onreadystatechange = function stateChanged()

	{

		if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

		{ 

			document.getElementById("spDealType").innerHTML=xmlHttp2.responseText 

		} 

//		else

//		{

//			document.getElementById("spDealType").innerHTML="Please wait...."

//		}

	}

	xmlHttp2.open("GET",url,true)

	xmlHttp2.send(null)

	}

}





function FillManufacturer(DealType)

{

	xmlHttp2=GetXmlHttpObject()

	

	if (xmlHttp2==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}

	if(DealType!="")

	{

	var url=site_path+"/ajax/search-manufacturer.php"

	url=url+"?dealtype="+DealType

	//alert(site_path);

	xmlHttp2.onreadystatechange = function stateChanged()

	{

		document.getElementById("systemWorking").style.display="block";		

		if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

		{ //alert(xmlHttp2.responseText);

			if (xmlHttp2.status == 200){

				document.getElementById("spManufacturer").innerHTML=xmlHttp2.responseText;

				document.getElementById("systemWorking").style.display="none";

			}else {

          		alert("There was a problem while using XMLHTTP:\n" + xmlHttp2.statusText);

			}



		}

	}

	xmlHttp2.open("GET",url,true)

	xmlHttp2.send(null)

	}

}

function FillContractPAYG(DealType)

{ 

	var xmlHttp3

	xmlHttp3=GetXmlHttpObject()

	

	if (xmlHttp3==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}

	if(DealType!="")

	{

	var url=site_path+"/ajax/search-ContractPAYG.php"

	url=url+"?dealtype="+DealType

	//alert(url)       

	xmlHttp3.onreadystatechange = function stateChanged()
	{
        document.getElementById("systemWorking").style.display="block";

		if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
		{ 
           if (xmlHttp2.status == 200){ 
           
			    document.getElementById("spNetwork").innerHTML=xmlHttp3.responseText 
            
                document.getElementById("systemWorking").style.display="none";
            
            }else {

                alert("There was a problem while using XMLHTTP:\n" + xmlHttp2.statusText);

            }    

		} 

//		else

//		{

//			document.getElementById("spDealType").innerHTML="Please wait...."

//		}

	}

	xmlHttp3.open("GET",url,true)

	xmlHttp3.send(null)

	}

}



function FillHandset(DealType)
{ 

	var xmlHttp4

	xmlHttp4=GetXmlHttpObject()

	

	if (xmlHttp4==null)

	{

		alert ("Browser does not support HTTP Request")

		return false

	}

	if(DealType!="")

	{

	var url=site_path+"/ajax/search-Handset.php"

	url=url+"?dealtype="+DealType

	//alert(url);

	xmlHttp4.onreadystatechange = function stateChanged()
	{
        document.getElementById("systemWorking").style.display="block";

		if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")
		{ 
        if (xmlHttp2.status == 200){ 
             
            document.getElementById("spModel").innerHTML=xmlHttp4.responseText 

			document.getElementById("spHidden").innerHTML="<input type=hidden name=searchBy value="+DealType+">";
            
            document.getElementById("systemWorking").style.display="none";
            
            }else {

                alert("There was a problem while using XMLHTTP:\n" + xmlHttp2.statusText);

            } 

		} 

//		else

//		{

//			document.getElementById("spDealType").innerHTML="Please wait...."

//		}

	}

	xmlHttp4.open("GET",url,true)

	xmlHttp4.send(null)

	}

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function GetXmlHttpObject()

{ 

	var objXMLHttp=null

	if (window.XMLHttpRequest)

	{

		objXMLHttp=new XMLHttpRequest()

	}

	else if (window.ActiveXObject)

	{

		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")

	}

	return objXMLHttp

}

function validate(frm)

{

	if (frm.ddlComp.value=="0")

	{

		alert('Please select manufacturer')

		frm.ddlComp.focus()

		return false;

	}

	if (frm.ddlModel.value=="")

	{

		alert('Please select phone model')

		frm.ddlModel.focus()

		return false;

	}

	if (frm.ddlDeal.value=="")

	{

		alert('Please select type of deal')

		frm.ddlDeal.focus()

		return false;

	}

	if (frm.ddlNetwork.value=="" && frm.ddlDeal.value!="Simfree" && frm.ddlDeal.value!="Automatic Cashback")

	{

		alert('Please select network')

		frm.ddlNetwork.focus()

		return false;

	}

return true;

}

