// Javascript MR
// Created By : Uttam Kumar
// Created on : 16th, July 2009

//var wsUrl = "http://172.16.0.5/mobile/mobilecentral/bpsnew/";
var wsUrl = "http://www.bestphoneshop.co.uk/";   
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 FillDeal(spnId,ctlId, mobId,netid){ 

	var xmlHttp;
	var url = wsUrl + "ajax/fillDeal.asp";
	url=url + "?ctlId="+ctlId;
	url=url + "&mobId="+mobId+"&netid="+netid;
    url = url + "&rnd=" + Math.random();
	//alert(url);
	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(Ph, category){
    if(category=="SimFree")
	    window.location.href="simfree-deals.asp?ph="+Ph;
    else if(category=="PAYG")
	    window.location.href="payg-deals.asp?ph="+Ph;
    else if(category=="Contract")
        window.location.href="contract-deals.asp?ph="+Ph;    
	else if(category=="12MonthsFree")
		window.location.href="12months-deals.asp?ph="+Ph;
	else if(category=="Clearance")
		window.location.href="clearance-deals.asp?ph="+Ph;
    else
        window.location.href="contract-deals.asp?ph="+Ph; 
}
var popp=0;
function popUp(URL)
{
	//alert(URL);
	if(popp)
	{
		if(!popp.closed)
		{
			popp.close();
		}
	}
	popp=open(URL,'','width=420,height=390,menubar=no,resizable=1,dependent=1,toolbar=no,top=90,left=240,scrollbars=1');
}