// Javascript MR
// Created By : Uttam Kumar
// Created on : 6th, July 2009

//var wsUrl = "http://172.16.0.5/mobile/mobilecentral/mobilerainbow/";
var wsUrl = "http://www.mobilerainbow.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" || category=="ContractC")
        window.location.href="alldeals.asp?id="+id;    
	else if(category=="12MonthsFree")
		window.location.href="12alldeals.asp?id="+id;
		else if(category=="upgrade")
	{
		document.frm1.ph_name.action="upgrade-mobile-phones.asp";
		document.frm1.submit();
	}
	else if(category=="Clearance")
		window.location.href="clearance-deals.asp?id="+id;
    else
        window.location.href="alldeals.asp?id="+id;
}

function redirectgift(gift){
   while( gift.indexOf( ' ' ) != -1 ){
   gift = gift.replace( ' ', '_' )
   }
	window.location.href="free_gifts_deal.asp?gift="+gift;
}