//var wsUrl = "http://172.16.0.5/mobile/dps-new/";
var wsUrl = "http://www.directphoneshop.co.uk/";  
//var wsUrl = "http://10.0.0.105/dps-deal/";  


function GetHttpObject(){
    var xmlHttpObj;
    try {   
        xmlHttpObj = new XMLHttpRequest();              
        return xmlHttpObj;
    }
    catch (e){        
        try{
            xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");                   
            return xmlHttpObj; 
        }
        catch (e){           
            try{
                xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");                      
                return xmlHttpObj;      
            }
            catch (e)
            {        
                alert("Sorry, Your browser does not support AJAX!");        
                return null;        
            }     
        }   
    }     
} 

function fillhandset_quick(spnId, ctlId, mobId){ 
	var xmlHttp;
	var url = wsUrl + "ajax/fill_quickdealfinder.asp";
	url=url + "?ctlId="+ctlId;
    url=url + "&mobId="+mobId;
	//alert(url);
    url = url + "&rnd=" + Math.random();
	xmlHttp = GetHttpObject(); 
    xmlHttp.onreadystatechange = function(){StateChanged(xmlHttp, spnId)};
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function StateChanged(xmlHttp, spnId) { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete"){
		document.getElementById(spnId).innerHTML = xmlHttp.responseText;	 
	}else{// For Loading...		
	}
} 

//function RedirectHandset(id, category){
//    if(category=="SimFree")
//	    window.location.href="showsimfreephone.asp?id="+id;
//    else if(category=="PAYG")
//	    window.location.href="showpayasyougo.asp?id="+id;
//    else if(category=="Contract" || category=="ContractC")
//        window.location.href="alldeals.asp?id="+id;    
//	else if(category=="12MonthsFree")
//		window.location.href="12alldeals.asp?id="+id;
//	else if(category=="Clearance")
//		window.location.href="clearance-deals.asp?id="+id;
//    else
//        window.location.href="alldeals.asp?id="+id;
//}
function RedirectHandset(id, category){
	if(id != "")
	{
		if(category=="simfree")
			window.location.href="showsimfreephone.asp?id="+id;
		else if(category=="payg")
			window.location.href="showpayasyougo.asp?id="+id;
		else if(category=="Contract")
			//window.location.href="dealset.asp?id="+id;   
			document.location.href = wsUrl +"comparedeals/" + id.replace(/ /g,"-").toLowerCase() +".html";
		else if(category=="12MonthsFree")
			window.location.href="12alldeals.asp?id="+id;
		else if(category=="Clearance")
			window.location.href="clearance-deals.asp?id="+id;
		else
			//window.location.href="dealset.asp?id="+id;
			 document.location.href = wsUrl +"comparedeals/" + id.replace(/ /g,"-").toLowerCase() +".html";
	}
}


function redirectgift(gift){
   while( gift.indexOf( ' ' ) != -1 ){
   gift = gift.replace( ' ', '_' )
   }
	window.location.href="free_gifts_deal.asp?gift="+gift;
}

function ChangeNames(linkId, divId){		
	for (i=65; i<91;i++){
		document.getElementById('div'+String.fromCharCode(i)).style.display= "none"; 
		document.getElementById(String.fromCharCode(i)).className= ""; 
	}	
	document.getElementById(divId).style.display= ""
	document.getElementById(linkId).className = "selected";
} 

//function fillnames(spnId, ctlId){ 
//	var xmlHttp2;
//	var url2 = wsUrl + "ajax/fill_callingNames.asp";
//	url2=url2 + "?ctlId="+ctlId;
//	alert(url)
//    url2 = url2 + "&rnd=" + Math.random();
//	xmlHttp2 = GetHttpObject(); 
//    xmlHttp2.onreadystatechange = function(){StateChanged2(xmlHttp2, spnId)};
//	xmlHttp2.open("GET", url2 , true);
//	xmlHttp2.send(null);
//}
//

//function StateChanged2(xmlHttp2, spnId) { 
//	if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == "complete"){
//		document.getElementById(spnId).innerHTML = xmlHttp2.responseText;	 
//	}else{// For Loading...		
//	}
//}
