﻿// Rupiz Compare Javascript Document
// Created By   : Raman Sachin Omar
// Created On   : 25th Sep, 2008
// Description  : Merging of all javascript files

/*******************************************
                Tag.js
*******************************************/

var wsUrl = "http://www.rupizcompare.co.uk/";    
//var wsUrl = "http://172.16.15.42/rupizcompare.co.uk/";
//var wsUrl = "http://localhost:4121/www.rupizcompare.co.uk/";
//var wsUrl = "http://localhost:1223/rupizcompare.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 ValidateWriteReview(title, review, rating){
    var _title = document.getElementById(title);
    var _review = document.getElementById(review);
    var _rating = document.getElementById(rating);
    if (_title.value == ""){
        alert("Please enter the review title.");
        _title.focus();
        return false;
    }
    else if (_review.value == ""){
        alert("Please enter the review.");
        _review.focus();
        return false;
    }
    else if (_rating.value == "0"){
        alert("Please rate this review.");        
        return false;
    }
    else
        return true;
}

/* Customer's Section */

function CheckLogin(login, pass){  
    if (document.getElementById(login).value ==""){
        alert ("Kindly enter your login id");
        document.getElementById(login).focus();
        return false;
    }

    else if (document.getElementById(pass).value ==""){
        alert ("Kindly enter your password");
        document.getElementById(pass).focus();
        return false;
    }
}

function CheckRegistration(login, pass, confirm, name, email, terms){  
    chk = document.getElementsByTagName("input");
    val = 0;
    for(var i = 0; i < chk.length; i++){          
        if (chk[i].type == "checkbox"){           
            if (chk[i].id == "chkTerms"){                
                if (chk[i].checked == true){
                    val = 1;
                }    
            }
       }
    }
    if (document.getElementById(login).value ==""){
        alert ("Kindly enter your desired login id");
        document.getElementById(login).focus();
        return false;
    }
    else if (document.getElementById(pass).value ==""){
        alert ("Kindly enter the password");
        document.getElementById(pass).focus();
        return false;
    }
    else if (document.getElementById(confirm).value ==""){
        alert ("Kindly re-enter the password.");
        document.getElementById(confirm).focus();
        return false;
    }
    else if (document.getElementById(confirm).value != document.getElementById(pass).value){
        alert ("Kindly enter same password..");
        document.getElementById(confirm).focus();
        return false;
    }
    else if (document.getElementById(name).value ==""){
        alert ("Kindly enter your name.");
        document.getElementById(name).focus();
        return false;
    }
    else if (document.getElementById(email).value ==""){
        alert ("Kindly enter your email.");
        document.getElementById(email).focus();
        return false;
    }
    else if (document.getElementById(email).value !="" && !checkemail(document.getElementById(email).value)){
        alert ("Kindly enter correct email id");
        document.getElementById(email).focus();
        return false;
    }    
    else if (val == 0){
        alert("Please agree to the our Terms & Conditions");
        return false;
    }
    else
        return true;  
}

/**************************** Shopping Feed ***********************************/
function CompareProducts(){
    var chk = document.getElementsByTagName("input");
    var val = 0;
    var products="";
    for(var i = 0; i < chk.length; i++){          
        if (chk[i].type == "checkbox"){           
            if (chk[i].id == "products"){                
                if (chk[i].checked == true){
                    products += chk[i].value + "~";
                    val += 1;
                }    
            }
       }
    }
    if (val > 4 ){
        alert("Sorry, You can compare four products at a time");
        return false;
    }      
    else if (val < 2){
        alert ("Please select atleast two products to compare")
        return false;
    }
    else{
        products = products.substring(0,products.length - 1)
        var redurl = "compare.aspx?pid=" + products;
        window.location = redurl;
        window.location.replace(redurl);
        return true;
    }
}

function CheckCount(){      
    chk = document.getElementsByTagName("input");
    val = 0;     
    for(var i = 0; i < chk.length; i++){          
        if (chk[i].type == "checkbox"){           
            if (chk[i].id == "products"){                
                if (chk[i].checked == true){                    
                    val += 1;
                }    
            }
        }
    }

    if (val > 4 ){         
        alert("Sorry, You can compare four products at a time");
        return false;
    }      
    else{      
        return true;
    }
}  
/**************************  Shopping JS end *****************************/

    function t(img, productid, productsource, referrer, log){
        if(!log){
            window.location = wsUrl + "customers/login.aspx?producttagged=" + window.location.href;
        }

        var ajax = GetHttpObject();
        if(ajax != null){
            ajax.onreadystatechange = function(){ProcessResult(ajax, img)}
            action = img.src.substr((img.src.lastIndexOf("/") + 1)); 
            ajax.open("GET", MakeUrl(productid, productsource, referrer, "c", action), true);
            ajax.send(null);
        }    
    }

    function ct(img, productid, productsource, referrer, log){
        if(log){
            img.onload = null;
            var ajax = GetHttpObject();
            if(ajax != null){
                ajax.onreadystatechange = function(){ProcessResult(ajax, img);}        
                ajax.open("GET", MakeUrl(productid, productsource, referrer, "l", null), true);
                ajax.send(null);    
            }
        }    
    }

    function ProcessResult(ajax, img){
        if(ajax.readyState == 4 && ajax.status == 200){
            var doc = ajax.responseXML;
            var error = doc.getElementsByTagName("error")[0].childNodes[0].nodeValue;
            if(parseInt(error) != -1){            
                var comment = doc.getElementsByTagName("comment")[0].childNodes[0].nodeValue;
                var src = doc.getElementsByTagName("img")[0].childNodes[0].nodeValue;        
                img.src = src;            
                img.title = comment;
                img.alt = comment;             
            }        
        }    
    } 

    function MakeUrl(productid, productsource, referrer, action, status){  
        var url = wsUrl + "tag.aspx";
        if(referrer != null){       
            if(status != null){           
                url += "?r="+referrer+"&p="+productid+"&ps="+productsource+"&a="+action+"&s="+status;
            }
            else{            
                url += "?r="+referrer+"&p="+productid+"&ps="+productsource+"&a="+action;
            }
        }
        else{
            if(status != null){            
                url += "?p="+productid+"&ps="+productsource+"&a="+action+"&s="+status;
            }
            else{
                url += "?p="+productid+"&ps="+productsource+"&a="+action;
            }
        }
        return url;                
    }

    // Toggling
    function tog_me(obj){
        var ref=document.getElementById(obj);
        (ref.style.display == "none") ? ref.style.display="block" : ref.style.display="none";
    }

    // Write Flash on HTML Page
    var write1Flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" WIDTH="190" HEIGHT="60" id="myFlasher" ALIGN=""> <PARAM NAME=movie VALUE="images/logo.swf"><param name=quality value=high><PARAM NAME=quality VALUE=high><EMBED src="images/banner.swf" quality="high" WIDTH="190" HEIGHT="60" NAME="myFlasher" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>'
    function show1Flash () {
        document.write(write1Flash);
    }

    // Check Email
    function checkemail(emailadd){
        var result = false;
        var theStr = new String(emailadd);
        var index = theStr.indexOf("@");
        if (index > 0){  	
            var pindex = theStr.indexOf(".",index);
            if ((pindex > index+1) && (theStr.length > pindex+2))
                result = true;
        }  		
        return result;
    }

    // Click Button
    function clickButton(e, buttonid){
        //alert (e);
        var evt = e ? e : window.event;
        var bt = document.getElementById(buttonid);
        if(evt.which || evt.keyCode) {
    	    if ((evt.which == 13) || (evt.keyCode == 13)){
    		    bt.click();
    		    evt.returnValue=false;
                evt.cancel = true;
    	    }
        }
        else{
    	    return true
        }
    }

    // Book-Mark
    function bookmark(){
        if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
            window.external.AddFavorite(window.location,document.title);
        }
        else if (navigator.appName == "Netscape"){
            window.sidebar.addPanel(document.title,window.location,"");
        }
        else {
            alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
        }  
    }

    function openPasswordDiv(){
        document.getElementById("profileDiv").style.display = "none";
        document.getElementById("passDiv").style.display = "";
        document.getElementById("profile").style.display = "";
        document.getElementById("pass").style.display = "none";
    }

    function openProfileDiv(){
        document.getElementById("profileDiv").style.display = "";
        document.getElementById("passDiv").style.display = "none";
        document.getElementById("profile").style.display = "none";
        document.getElementById("pass").style.display = "";
    }

    function showCategories(){
        document.getElementById('divCats').style.display = "block";    
    }

    function hideCategories(){
        document.getElementById('divCats').style.display = "none";    
    }

    function GetProviders(loginId,loginProvider) {
        if(loginId != "Manually"){          
            document.getElementById("manully").style.display='none';
            document.getElementById("auto").style.display='block';
            document.getElementById("ctl00_cnt_lblLogin").innerHTML='';
            document.getElementById("ctl00_cnt_lblLoginId").innerHTML='';
            document.getElementById("ctl00_cnt_lblLoginpass").innerHTML='';
            document.getElementById("ctl00_cnt_lblLoginprovid").innerHTML='';
            document.getElementById("ctl00_cnt_lblLogin").innerHTML='Login to '+loginId;
            document.getElementById("ctl00_cnt_lblLoginId").innerHTML=loginId;
            document.getElementById("ctl00_cnt_lblLoginpass").innerHTML=loginId;
            document.getElementById("ctl00_cnt_lblLoginprovid").innerHTML=loginProvider;
            document.getElementById("ctl00_cnt_provider").value=loginProvider;
            document.getElementById("ctl00_cnt_etype").value=loginId;
        }else{
            document.getElementById("ctl00_cnt_lblLogin").innerHTML='';
            document.getElementById("ctl00_cnt_lblLogin").innerHTML=' Email your Friends';
            document.getElementById("auto").style.display='none';
            document.getElementById("manully").style.display='block';
        }
    }

    //For Tabbing In Home Page :: Added By Raman
    function ChangeHomeTab(tabName,tabId){
        document.getElementById("tab1").style.display = "none";
        document.getElementById("tab2").style.display = "none";
        document.getElementById("tab3").style.display = "none";
        document.getElementById("tab4").style.display = "none";
        document.getElementById("tab5").style.display = "none";
        document.getElementById("tab6").style.display = "none";       
        document.getElementById("tab7").style.display = "none";  
        document.getElementById(tabName).style.display = "";

        document.getElementById("t1").className = "f_link";
        document.getElementById("t2").className = "f_link";
        document.getElementById("t3").className = "f_link";
        document.getElementById("t4").className = "f_link";
        document.getElementById("t5").className = "f_link";
        document.getElementById("t6").className = "f_link";  
        document.getElementById("t7").className = "f_link";         
        document.getElementById(tabId).className = "onselected";
    }   
    
    //Tabbing in Mortgages Page
    function ChangeMortgages(tabName,tabId){
        document.getElementById("tv1").style.display = "none";
        document.getElementById("tv2").style.display = "none";
        document.getElementById("tv3").style.display = "none";
        document.getElementById("tv4").style.display = "none";
        document.getElementById("tv5").style.display = "none";          
        document.getElementById(tabName).style.display = "";

        document.getElementById("t1").className = "f_link";
        document.getElementById("t2").className = "f_link";
        document.getElementById("t3").className = "f_link";
        document.getElementById("t4").className = "f_link";
        document.getElementById("t5").className = "f_link";           
        document.getElementById(tabId).className = "tab_menu_selected";
    } 

    function KeyHandlingDate(event) {   
        if(navigator.appName == "Microsoft Internet Explorer"){        
            if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) && !(window.event.keyCode == 47)){
                window.event.keyCode = null;
            }
        }
        else {
            if (!((event.which >= 48) && (event.which <= 57) || (event.which == 8) ||(event.keyCode == 46) || (event.which == 39) || (event.keyCode == 9) || (event.which == 47))){
                event.preventDefault();
            }
        }		
    }

    function fn_oncheck(val){
        if(document.getElementById('ctl00_cnt_CheckBoxList1_1').checked ==true && val=='1')
            document.getElementById('ctl00_cnt_CheckBoxList1_2').checked=false;
        else if(document.getElementById('ctl00_cnt_CheckBoxList1_2').checked==true && val=='2')
            document.getElementById('ctl00_cnt_CheckBoxList1_1').checked=false;
    }

    function fn_oncheckterm(){
        if(document.getElementById('ctl00_cnt_CheckBox1').checked==false){
            alert('Please agree to the Terms & Conditions.'); 
            return false;
        }
    }

    function ValidUserName(that)    {
        var dtStr=document.getElementById(that).value;
        var check = new RegExp();    
        check.compile("^[a-zA-Z0-9|-|_|.|, ]+$"); 
        if (!check.test(dtStr)){  
            return false; 
        }
        else{
            return true; 
        }
    }

    var dtCh= " "; // data separater
    var minYear=1900;
    var maxYear=2100;

    function isDate(that){
        var dtStr=document.getElementById(that).value;
        var daysInMonth = DaysArray(12);
        var pos1=dtStr.indexOf(dtCh);
        var pos2=dtStr.indexOf(dtCh,pos1+1);
        var strMonth=dtStr.substring(0,pos1); // index for month  in numaric
        var monthindex='00';

        switch(strMonth.toUpperCase()){
            case 'JAN': strMonth='01';break;
            case 'FEB': strMonth='02';break;    
            case 'MAR': strMonth='03';break;
            case 'APR': strMonth='04';break;
            case 'MAY': strMonth='05';break;
            case 'JUN': strMonth='06';break;
            case 'JUL': strMonth='07';break;
            case 'AUG': strMonth='08';break;
            case 'SEP': strMonth='09';break;
            case 'OCT': strMonth='10';break;
            case 'NOV': strMonth='11';break;
            case 'DEC': strMonth='12';break;
        }

        var strDay=dtStr.substring(pos1+1,pos2); //index for Day in numeric
        var strYear=dtStr.substring(pos2+1);
        strYr = strYear;
        if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
        if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
        for (var i = 1; i <= 3; i++) {
            if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
        }
        month=parseInt(strMonth)
        day=parseInt(strDay)
        year=parseInt(strYr)

        if (pos1==-1 || pos2==-1){        
            alert("The date format should be : MM dd yyyy")
            return false
        }

        if (strMonth.length<1 || month<1 || month>12 || isInteger(strMonth)==false){ //isInteger(strMonth)==false if format=MM dd yyyy
            alert("Please enter a valid month")
            return false
        }

        if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){        
            alert("Please enter a valid day")		
            return false
        }
        if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
            alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
            return false
        }
        if (dtStr.indexOf(dtCh,pos2+1)!=-1 ){
            alert("Please enter a valid date")
            return false
        }
        return true
    }
    
    function daysInFebruary (year){
        // February has 29 days in any year evenly divisible by four,
        // EXCEPT for centurial years which are not also divisible by 400.
        return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
    }

    function DaysArray(n){
	    for (var i = 1; i <= n; i++){
		    this[i] = 31;
		    if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		    if (i==2) {this[i] = 29;}
       } 
       return this
    }

    function isInteger(s)    {
        var i;
        for (i = 0; i < s.length; i++){   
            // Check that current character is number.
            var c = s.charAt(i);
            if (((c < "0") || (c > "9"))) return false;
        }
        // All characters are numbers.
        return true;
    }

    /**********************************************************
                            More.js
    **********************************************************/
    var args, stopTime;    
    function getposOffset(overlay, offsettype){
        var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
        var parentEl=overlay.offsetParent;
        while (parentEl!=null){
            totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
            parentEl=parentEl.offsetParent;
        }
        return totaloffset;
    }

    function overlay_home(curobj, subobjstr, opt_position){
        var cntl = document.getElementById('ctl00_ucgs_ddlCategory');
        if(cntl != null){
            cntl.style.display = 'none';    
        }
        if (document.getElementById){        
            var subobj=document.getElementById(subobjstr)
            subobj.style.display=(subobj.style.display!="block")? "block" : "none"            
            var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
            var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
            subobj.style.left = xpos - 87 + "px";
            subobj.style.top = ypos + 50+ "px"; 
            
            document.getElementById("ifrm").style.left = subobj.style.left;
            document.getElementById("ifrm").style.top = subobj.style.top;
            
            return false
        }
        else
        return true
    }
    
    function overlay(curobj, subobjstr, opt_position){
         var cntl = document.getElementById('ctl00_ucgs_ddlCategory');
         if(cntl != null){
            cntl.style.display = 'none';    
        }
        if (document.getElementById){        
            var subobj=document.getElementById(subobjstr)
            subobj.style.display=(subobj.style.display!="block")? "block" : "none"
            
            var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
            var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
            subobj.style.right = xpos - 825 + "px";
            subobj.style.top = ypos + 34 + "px";

            //if (subobj.style.display == "block"){
                GetMoreCategories();
            //}
            return false
        }
        else
            return true
    }

    function overlayclose(subobj){
        document.getElementById(subobj).style.display="none";
        var cntl = document.getElementById('ctl00_ucgs_ddlCategory');    
        if(cntl != null){    
            cntl.style.display = 'block';    
        }
    }

    function mouseOver(arg){
        clearTimeout(stopTime);
        arg.style.display='block';
        var cntl = document.getElementById('ctl00_ucgs_ddlCategory');
        if(cntl != null)    {
            cntl.style.display = 'none';    
        }    
    }

    function mouseOut(arg){   
        args = arg;
        if (args.style.display != 'none'){
            stopTime = setTimeout('mouseOutTimed()',100);
        }
    }

    function mouseOutTimed(){ 
        clearTimeout(stopTime);
        args.style.display='none'; 
        var cntl = document.getElementById('ctl00_ucgs_ddlCategory');
        if(cntl != null)    {
            cntl.style.display = '';    
        }      
    }

    function GetFooterLinks(){
        if(document.all)    {
            document.write('<a href="javascript:history.go(0);" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.rupizcompare.co.uk\')" title="Click to set as home page">Set as Home Page</a>');
        }
        else{
            document.write('<a href="http://www.rupizcompare.co.uk" title="drag this link onto your Home button to make www.rupizcompare.co.uk as your home page">Set as Home Page</a>');
        }
    }

    function GetMoreCategories(){
        var xmlHttp = GetHttpObject();
        if (xmlHttp != null){
            var url = wsUrl + "getmorecategories.aspx";                 
            xmlHttp.open("GET", url, true);  
            xmlHttp.onreadystatechange = function() {
                if(xmlHttp.readyState == 4 ){ 
                    document.getElementById("more").innerHTML = xmlHttp.responseText;		         	       
                }            
            }    
            xmlHttp.send(null);    
        }    
    }

    function ValidateEmail(EmailId){
        var EmailId2;  
        EmailId2 = document.getElementById(EmailId);        
        if(EmailId2.value == ""){    
            alert('Kindly enter your email id.');
            EmailId2.focus();
            return false;
        }
        else if (EmailId2.value!= "" && !checkemail(EmailId2.value)){
            alert("Kindly enter a valid email id.")
            EmailId2.focus();
            return false;
        }
        else{       
            return true;
        }       
    }   

    function textCounter(field, countfield, maxlimit) {
        if (field.value.length > maxlimit) // if the current length is more than allowed
            field.value = field.value.substring(0, maxlimit); // don't allow further input
        else
            document.getElementById(countfield).innerHTML = maxlimit - field.value.length;
    } 
     
    //For Tabbing In Mobile Home Page :: Added By Raman
    function ChangeMobileTab(tabName, tabId){       
        document.getElementById("tab1").style.display = "none";
        document.getElementById("tab2").style.display = "none";
        document.getElementById("tab3").style.display = "none";
        document.getElementById("tab4").style.display = "none";       
        document.getElementById(tabName).style.display = "";

        document.getElementById("t1").className = "n_link";
        document.getElementById("t2").className = "n_link";
        document.getElementById("t3").className = "n_link";
        document.getElementById("t4").className = "n_link";        
        document.getElementById(tabId).className = "onselection";
    }        

   function SelectAll(AllChk){                       
        var bxType;
        //Check if the [object] type is checkbox
        if(AllChk.type=="checkbox")    {                
            bxType = AllChk;
        }
        else{                
            bxType = AllChk.children.item[0];
        }
        //Check if the checkbox status is checked
        status = bxType.checked;
        //Get the elements of checkbox type and iterate through the elements
        elmts = bxType.form.elements;
        for(i=0; i<elmts.length; i++)
            if(elmts[i].type=="checkbox" && elmts[i].id != bxType.id) {
                if(elmts[i].checked!=status)
                    elmts[i].click();
            }
    }

 function URLescape(text)
{
 
	var SAFECHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";	
	var HEX = "0123456789ABCDEF";
 
	var plaintext = text; //document.EscapeURL.F1.value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";	
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} 
    return encoded;
	//document.EscapeURL.F2.value = encoded;
	//return false;
};
 
function URLDecode(text)
{
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = text;//document.EscapeURL.F2.value;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
   //document.EscapeURL.F1.value = plaintext;
   //return false;
};

function BrowserName(){
    var nVer = navigator.appVersion;
    var nAgt = navigator.userAgent;
    var browserName  = navigator.appName;
    var fullVersion  = ''+parseFloat(navigator.appVersion); 
    var majorVersion = parseInt(navigator.appVersion,10);
    var nameOffset,verOffset,ix;

    // In MSIE, the true version is after "MSIE" in userAgent
    if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
        browserName = "Microsoft Internet Explorer";
        fullVersion = nAgt.substring(verOffset+5);
    }
    // In Opera, the true version is after "Opera" 
    else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
        browserName = "Opera";
        fullVersion = nAgt.substring(verOffset+6);
    }
    // In Chrome, the true version is after "Chrome" 
    else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
        browserName = "Chrome";
        fullVersion = nAgt.substring(verOffset+7);
    }
    // In Safari, the true version is after "Safari" 
    else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
        browserName = "Safari";
        fullVersion = nAgt.substring(verOffset+7);
    }
    // In Firefox, the true version is after "Firefox" 
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
        browserName = "Firefox";
        fullVersion = nAgt.substring(verOffset+8);
    }
    // In most other browsers, "name/version" is at the end of userAgent 
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
    {
        browserName = nAgt.substring(nameOffset,verOffset);
        fullVersion = nAgt.substring(verOffset+1);
        if (browserName.toLowerCase()==browserName.toUpperCase()) {
            browserName = navigator.appName;
        }
    }
    // trim the fullVersion string at semicolon/space if present
    if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
    if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);

    majorVersion = parseInt(''+fullVersion,10);
    if (isNaN(majorVersion)) {
        fullVersion  = ''+parseFloat(navigator.appVersion); 
        majorVersion = parseInt(navigator.appVersion,10);
    }
    return browserName; 
}

function ChangeBroadbandTab(link, rowId){        
    if (document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_0')){
        document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_0').style.display= "none"; 
        document.getElementById('link0').className = "";
    } 

    if (document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_1')){
        document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_1').style.display= "none"; 
        document.getElementById('link1').className = "";
    }

    if (document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_2')){
        document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_2').style.display= "none"; 
        document.getElementById('link2').className = "";
    }

    if (document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_3')){
        document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_3').style.display= "none"; 
        document.getElementById('link3').className = "";
    }

    if (document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_4')){
        document.getElementById('ctl00_cnt_repLinks_ctl04_gvTopBroadbandDeals_row_4').style.display= "none"; 
        document.getElementById('link4').className = "";
    }   

    document.getElementById(rowId).style.display= ""; 
    document.getElementById(link).className = "selected";  
}
