// Javascript DPS
// Created By : Uttam Kumar
// Created on : 20th, Aug 2009

//var wsUrl = "http://172.16.0.5/mobile/mobilecentral/dpsnew/";
var wsUrl = "http://www.directphoneshop.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 fillhandset(spnId, ctlId, mobId){ 
	var xmlHttp;
	var url = wsUrl + "ajax/fill.asp";
	url=url + "?ctlId="+ctlId;
    url=url + "&mobId="+mobId;

    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")
        window.location.href="dealset.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="dealset.asp?id="+id;
}

function redirectnetdeal(id,net)
{
//alert("hi");
	if(id!=0)
	{window.location="Netset.asp?id="+id+"&NetId="+net}
}
function redirectPage(id,MobID)
{
	if(id!="")
	{
	if (id=='SimFree')
	{
	window.location="showsimfreephone.asp?id="+MobID}
	if (id=='PAYG')
	{
	window.location="showpayasyougo.asp?id="+MobID}
	if (id=='Contract')
	{
	window.location="dealset.asp?id="+MobID}
	if (id=='Clearance')
	{
	window.location="clearance-deals.asp?id="+MobID}
	}
}

function popUp(URL,PopWidth,PopHeight) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+PopWidth+",height="+PopHeight+",left =240,top=90');");
}