// Broadband JS
//
// Purpose: Functions for Broadband JS, setup events for buttons
//
// Author: TheEWord (www.theeword.co.uk)
// Developer: Alan Mackin (alan at theeword.co.uk)


var xmlHttp2=GetXmlHttpObject(); //for search boxes
var xmlHttp3=GetXmlHttpObject(); //for extra search box
var xmlHttp6=GetXmlHttpObject(); //for clearing sorts/filters
var xmlHttp4=GetXmlHttpObject(); //for click stats
var xmlHttp5=GetXmlHttpObject(); //for filters



var pwo=0; //used to fade in/out wait box
var fwo=100; //used to fade out filter box

var sxstate=0; //var to hold state of animated drop down filters (Used to control delay)
AttachEvent(this,"load",doAtt); //master function to load once document has loaded

//function called at load time
function doAtt(){

  preload_sorts();
  //setup filters box functionality
  obj=document.getElementById("spb2");
  if (obj) {
  
  //preload 
  
  AttachEvent(obj,"click",function(){reload_broadband(5,2);sortc(2);});
  AttachEvent(obj,"mouseover",function(){spbi(2)});
  AttachEvent(obj,"mouseout",function(){spbo(2);sxstate=0;});
  }

  obj=document.getElementById("spb4");
  if (obj) {
  AttachEvent(obj,"click",function(){reload_broadband(2,4);sortc(4);});
  AttachEvent(obj,"mouseover",function(){spbi(4)});
  AttachEvent(obj,"mouseout",function(){spbo(4);sxstate=1;});
  }


  obj=document.getElementById("spb5");
  if (obj) {
  AttachEvent(obj,"click",function(){reload_broadband(3,5);sortc(5);});
  AttachEvent(obj,"mouseover",function(){spbi(5)});
  AttachEvent(obj,"mouseout",function(){spbo(5);sxstate=1;});
  }

  obj=document.getElementById("spb6");
  if (obj) {
  AttachEvent(obj,"click",function(){reload_broadband(4,6);sortc(6);});
  AttachEvent(obj,"mouseover",function(){spbi(6)});
  AttachEvent(obj,"mouseout",function(){spbo(6);sxstate=1;});
  }

  obj=document.getElementById("spb7");
  if (obj) {
    AttachEvent(obj,"click",function(){reload_broadband(1,7);sortc(7);});
    AttachEvent(obj,"mouseover",function(){spbi(7)});
    AttachEvent(obj,"mouseout",function(){spbo(7);sxstate=1;});
  }

  
  //load in spbp box (if there)
  obj=document.getElementById("spbp");
  if (obj) {
    url="/apps/extra-search2.php?type=2";
    xmlHttp3=GetXmlHttpObject();
    xmlHttp3.onreadystatechange=function(){bbld()};
    xmlHttp3.open("GET",url,true);
    xmlHttp3.send(null);
  }
  
  //load in spbp box (if there)
  obj=document.getElementById("spbo");
  if (obj) {
    url="/apps/extra-search2.php?type=2";
    xmlHttp3=GetXmlHttpObject();
    xmlHttp3.onreadystatechange=function(){bbld()};
    xmlHttp3.open("GET",url,true);
    xmlHttp3.send(null);
     
  
  //setup mouseovers
  result_setup();  
  }
  
  //setup button for mobile broadband guides
  obj=document.getElementById("mbb-guide");
  if (obj) {AttachEvent(obj,"click",function(){load_mbb_guide();});}
  
  //load in spbp box (if there)
  obj=document.getElementById("rc2");
  if (obj) {
  transfer_totals();
  }
  
  //setup search arrows
  sortall();
  
  
   //setup filteranim
//  obj=document.getElementById("filtanim");
//  if (obj) {
  
    // obj.style.visibility="visible";
    //obj.style.display="block";
    //obj.src = "/images/broadband-filters-anim.gif";
    //AttachEvent(obj,"mouseover",function(){filtanim()});
    //obj.style.left=(zxcPos("spb1")[0]-20)+"px";
    //obj.style.top=(zxcPos("spb1")[1]-130)+"px";
    
//  }
 
    
}


//function
function load_mbb_guide(){ 
  window.open('http://www.comparebroadbanduk.com/dongle.html', 'HowToUse', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=340,left=690,top=375');
}


//changes image in search title
//also changes title

function sortc(id) {

  clear_sessions();

  obj=document.getElementById("spb"+id);
    
  title=obj.title;
  end=title.length;
  final=title.charAt(end-1);
  
  //firstly lets clear all the current images and titles
  for (n=1;n<8;n=n+1){
      
    if (n!=id) {
      obj2=document.getElementById("spb"+n);
      if (obj2) { 
        title2=obj2.title;
        end2=title2.length;
        final2=title2.charAt(end2-1);
        if (final2==".") {obj2.title=title2.substr(0,end2-1);}
        obj2.style.backgroundImage="url('/images/filters/m"+n+"a.png')"; 
      
      }
    }
  
  }
  
  //sort ascending
  if (final!="." && final!="!") {
  obj.title=obj.title+".";
  obj.style.backgroundImage="url('/images/filters/m"+id+"c.png')";
  }
  
  //sort descending
  if (final==".") {
  obj.title= title.substring(0,end-1)+".";
  obj.style.backgroundImage="url('/images/filters/m"+id+"c.png')";
  }
  
  //whilst were at it, lets see if we need to show the 'remove searches' text.
  showremove=0;
  for (n=1;n<7;n=n+1){
  
    obj2=document.getElementById("spb"+n);
    if (obj2) {
    
      title=obj2.title;
      end=title.length;
      final=title.charAt(end-1);
  
      if (final=="." || final=="!") {
      showremove=1;
   
    }
  }
  }
  
  obj2=document.getElementById("spb1");
  if (obj2) {
    if (showremove==1) {
    
    if (obj2.innerHTML=="filter and sort your results") {
      obj2.innerHTML=obj2.innerHTML+'<br><a href="#" id=srem onclick="remove_sortsfilters()"></a>'; 
    }
  
  } else {//reset to standard text
    obj2.innerHTML="filter and sort your results";
  
  }
  }
  
  //show new filter box
  if (id!=2)  { 
    objb=document.getElementById("filtbox");
    objb.innerHTML='<center><img src="/images/filt-load2.gif" style="margin:20px 20px 20px 20px;filter:alpha(opacity=70);-moz-opacity:.70;opacity:.70;"></center>';
    
    //load in content for filter box
    filt_load(id);
    } else {
    slide_filters(1);
    }
  
}

function filt_load(id){

  if (id!=2) {
     
  objb.style.visibility="visible";
  objb.style.display="block";
  width=document.getElementById("spb"+id).offsetWidth;
  
  objb.style.width=(width-20)+"px";
  objb.style.left=zxcPos("spb"+id)[0]+"px";
  objb.style.top=(zxcPos("spb"+id)[1]+20)+"px";
  //objb.style.backgroundImage="url('/images/filters/base-"+id+"b.gif')";    
      
  objb=document.getElementById("spb");
  height=objb.offsetHeight;
      
  //if required, slide down
  if (height>59){
    slide_filters(0);
  }
  
  url="/apps/extra-search2.php?type=2&id="+id;
  xmlHttp3=GetXmlHttpObject();
  xmlHttp3.onreadystatechange=function(){bblf()};
  xmlHttp3.open("GET",url,true);
  xmlHttp3.send(null);
    
  //var newWidth = currWidth + parseInt(addToWidth);
  }

}

function slide_filters(mode){

  objb=document.getElementById("spb");
  height=objb.offsetHeight;
  
  if (mode==0) {
  
    if (height<170) {
      height=height+5;
      objb.style.height=height+"px";
      setTimeout("slide_filters(0)",50);
  } else {
      objb.style.height="170px";
      objc=document.getElementById("txtad");
      if (objc) {
        objc.style.display="block";
        objc.style.visibility="visible";  
      }
      
  }
  
  }
  
  if (mode==1) {
  
      
      clear_sessions();
      setTimeout("slide_filters(2)",500);
      
      objc=document.getElementById("txtad");
      if (objc) {
        objc.style.display="none";
        objc.style.visibility="hidden";  
      }
  }
      
      
  if (mode==2) {
      
      objb.style.height="60px";
      objb=document.getElementById("filtbox");
      objb.style.visibility="hidden";
      objb.style.display="none";
      objb.innerHTML="";
            
      reload_broadband();
      
  }
  
  
  
  

}

//checks all images in search titles, make sure everything looks good
function sortall(){

  for (n=1;n<8;n=n+1){
  
  
    obja=document.getElementById("spb"+n);
    if (obja) {
    title=obja.title;
    end=title.length;
    final=title.charAt(end-1);
    if (final==".") {
      obja.style.backgroundImage="url('/images/filters/m"+n+"c.png')";
    }
    }
  
  
  
    
  }
}

function remove_sortsfilters(){

  //firstly lets reset all titles AND images
  
    for (n=2;n<7;n=n+1){
  
    if (n!=3) {
    obj=document.getElementById("spb"+n);
    
    title=obj.title;
    end=title.length;
    final=title.charAt(end-1);
    if (final=="." || final=="!") {
    obj.title= title.substring(0,end-1);
    
    }
      
    obj.style.backgroundImage="url(/images/sortb.gif)";
    
  }
  
  
    
  }
  
       for (n=0;n<30;n=n+1){
  
    obj=document.getElementById("pls"+n);
  if (obj) {    obj.style.color="#eebd00";}
    
  }
  
  clear_sessions(1);
  
}

function clear_sessions(mode){
//now lets clear all session variables 
  url="/apps/clear_all_sorts.php";
  xmlHttp6=GetXmlHttpObject();
  if (mode==1) {  xmlHttp6.onreadystatechange=function(){bble(1)};} 
  else {xmlHttp6.onreadystatechange=function(){bble()};}
  xmlHttp6.open("GET",url,true);
  xmlHttp6.send(null);
}

//mouseover for search button
function spbi(i) {
  
  //get rid of anim
  //filtanim();
  
  obj=document.getElementById("spb"+i);
  title=obj.title;
  end=title.length;
  final=title.charAt(end-1);
  
  if (final!="." && final!="!") {
    obj.style.color="#666666";
    obj.style.backgroundImage="url('/images/filters/m"+i+"b.png')";
  }
  obj.style.cursor="pointer";
  

}


//mouseout for search button
function spbo(i) {
  obj=document.getElementById("spb"+i);
  title=obj.title;
  end=title.length;
  final=title.charAt(end-1);
  
  if (final!="."  && final!="!") {
    obj.style.color="";
    obj.style.backgroundImage="url('/images/filters/m"+i+"a.png')";;
  }

}

//function to reload broadband for sorts, filters when doing a simple search
function reload_broadband(sortorder,id,filterid){
     
  obj=document.getElementById("broadband-search");
  obj.innerHTML="";
  obj.style.height="800px";
  
  please_wait2(1);
      
  sorttype=0;
    
  if (id) {
  obj2=document.getElementById("spb"+id);
  //lets see if this sort is ascending or descending
  title=obj2.title;
  end=title.length;
  final=title.charAt(end-1);
  
  //ascending
  done=0;
    
  //if (final==".") { sorttype=2;done=1;} 
  //if (final=="!") { sorttype=1;done=1;}
  //if (done==0) {sorttype=1;}
  //} else { sortype=0;sortorder=0;}
  }
  if (sorttype==0)  {sorttype=1;}
  
  //xpc=setTimeout(function(){failsafe_fader()}, 3000);
  
  //deal with queryX
  obj=document.getElementById("queryX");
  if (obj) { queryX="&queryX="+obj.value;} else {queryX="";}
     
  url="/apps/broadband3.php?incdb=1&sortorder="+sortorder+"&sorttype="+sorttype+"&type=2"+queryX;
  
  if (filterid) {url=url+"&filterid="+filterid;}
  pwo=0;
         
  xmlHttp2=GetXmlHttpObject();
  xmlHttp2.onreadystatechange=function(){bblc()};
  xmlHttp2.open("GET",url,true);
  xmlHttp2.send(null);
    
    
  
}


//ok now get total returned in search and drop in to main page
function transfer_totals(){
  obj=document.getElementById("rc2");
    if (obj){
    obj.innerHTML=document.getElementById("rch").innerHTML;
    }
}

function transfer_searchtext(){
//now build up a text string with filters/sorts etc
  
  //now cycle through all the available filters to mark down any in the current group
  found=1;
  i=0;
    
  string="";
  while (found==1) {
  obj3=document.getElementById('pls'+i);
  obj4=document.getElementById('plt'+i);
  
  
  
  if (obj3) {
    
    group=obj3.title.split("!")[0];
    
    //translate groups to titles
    if (group==1) { groupb=7;}
    if (group==2) { groupb=4;}
    if (group==3) { groupb=6;}
    if (group==4) { groupb=5;}
    if (group==5) { groupb=3;}
        
    color=obj3.style.color;
        
    if (color=="#ff0000") {
    
      if (string) {string=string+", ";}
      
      string=string+obj4.innerHTML+" "+document.getElementById('spb'+groupb).innerHTML;
      
      
    
    }
          
  } else {
  
  found=0;
    
  }
   
  i=i+1;
  }
  
  
  if (string) {string="You searched for "+string.toLowerCase()+" broadband";}
    //document.getElementById('rct').innerHTML=string;
  
  
  


}


function bblc(){if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
{obj=document.getElementById("broadband-search");
obj.innerHTML=xmlHttp2.responseText;
obj.style.backgroundImage="";
obj.style.height="100%";
//transfer over the total results from this search
transfer_totals();


//load up nice text equivalent of searching
//transfer_searchtext();

//setup please wait point
//pwo=75;
please_wait2(2);

//load up failsafe fader

}}



function bbld(){if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
{obj=document.getElementById("spbp");
obj.innerHTML=xmlHttp3.responseText;
obj.style.backgroundImage="";
}}

function bble(mode){if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
{obj=document.getElementById("spb1");
//obj.innerHTML="filter and sort your results";
//reload page
if (mode==1) {reload_broadband();}
}}

function bblf(){if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
{obj=document.getElementById("filtbox");
obj.innerHTML=xmlHttp3.responseText;}}


//functions to control slidedown of filter box
function setup_slidedown(){
mfp=window.setTimeout("do_slidedown()",2000);
sxstate=1;}

function do_slidedown(){
if (sxstate==1) {broadbandsrch.slidedown()}
}


//function 
function fin(id){

//  filtanim();

  obj=document.getElementById('pls'+id);
  
    //check to see if this item has been selected already
  alert(obj.style.color);
  if (obj.style.color!="#ff0000") {
  
  obj.style.color='#eebd00';
  obj2=document.getElementById('plt'+id);
  obj2.style.textDecoration="underline";
  obj2.style.color="#FF0000";
  
  }
}

function fout(id){

  //check to see if this item has been selected already
  //alert(obj.style.color);
  
  //FireFOX NEED TO CONVERT RGB VALUES TO A NICE HEX
  if (obj.style.color!="#ff0000") {
  
  obj.style.color='#eebd00';
  obj2=document.getElementById('plt'+id);
  
  obj2.style.textDecoration="none";
  obj2.style.color="#666666";
    
  }
  
}

function fclik(type,id,filterid){
  
  //get title of this object (and thus get 'group') 
  //alert (obj.title);
  
  obj=document.getElementById('pls'+id);
  obj4=document.getElementById('plt'+id);
  title2=obj.title.split("!")[0];
    
  id2=obj.title.split("!")[1];
    
  //now cycle through all the available filters to mark down any in the current group
  found=1;
  i=0;
  
  while (found==1) {
  obj3=document.getElementById('pls'+i);
  
  if (obj3) {
  
    title3=obj3.title.split("!")[0];
  //  alert(title3);
    if (title3==title2) {
  
    obj3.style.color='#ff0000';
    obj2=document.getElementById('plt'+i);
    obj2.style.textDecoration="none";
    obj2.style.color="#666666";
    }  
  } else {
  
  found=0;
    
  }
   
  i=i+1;
  }
  
  obj4.style.color='#ff0000';
  obj4.style.textDecoration='underline';
  obj4.style.fontWeight='bold';
    
  //now lets store this click in the db 
  url="/apps/click_tracking.php?type=1&id="+id2;
  xmlHttp4=GetXmlHttpObject();
  xmlHttp4.open("GET",url,true);
  xmlHttp4.send(null);
  
  //deal with 
  
  url="/apps/extra-search3.php?type=1&id="+filterid;
  xmlHttp4=GetXmlHttpObject();
  xmlHttp4.open("GET",url,true);
  xmlHttp4.send(null);
    
  //reload page with filter      
  reload_broadband(0,'',filterid);
  //hide the nav now
  
  
  //obj=document.getElementById("spb1");
  //if (obj.innerHTML=="filter and sort your results") {
//      obj.innerHTML=obj.innerHTML+'<br><a href="#" id=srem onclick="remove_sortsfilters()"></a>'; 
//    }

}






//function for animated search bar expansion
// (external)

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength){ //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
	}
	else{ //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Please wait until document has fully loaded then click again")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value){
		document.cookie = name+"="+value
}

function filtanim(){

  obj2=document.getElementById("filtanim");
  if (obj2) {

  obj2.style.filter = "Alpha(Opacity="+fwo+")";
  obj2.mozopacity = "."+fwo;
	obj2.style.opacity = "."+fwo;
  fwo=fwo-25;
  	
	if (fwo>0) { mfg=window.setTimeout("filtanim()",15);}
  if (fwo<0) { fwo=0;}
  if (fwo==0) { obj2.style.display="none";
                obj2.style.visibility="hidden";
                
     
  }
  
  }
  

}
function failsafe_fader(){

  obj=document.getElementById("wait");
  //obj2=document.getElementById("wait2");
  obj.style.display="none";
  obj.style.visibility="hidden";
  //obj2.style.display="none";
  //obj2.style.visibility="hidden";

}


function please_wait2(mode) {

if (mode==1) {

  l=zxcPos("broadband-search");
  obj2=document.getElementById("wait2");
  obj2.style.top="500px";
  obj2.style.left=(l[0])+"px";
  obj2.style.display="block";
  obj2.style.visibility="visible";

}

if (mode==2) {

  l=zxcPos("broadband-search");
  obj2=document.getElementById("wait2");
  obj2.style.top=l[1]+"px";
  obj2.style.left=(l[0])+"px";
  obj2.style.display="none";
  obj2.style.visibility="hidden";


}




}

function please_wait(mode){
  obj=document.getElementById("wait");

//fade in
if (mode==1) {

if (pwo==0) {
  
  l=zxcPos("broadband-search");
  obj.style.display="block";
  obj.style.visibility="visible";
  obj.style.filter = "Alpha(Opacity=0)";
  obj.style.top=l[1]+"px";
  obj.style.left=l[0]+"px";
      
  //obj2=document.getElementById("wait2");  
  //obj2.style.top=l[1]+"px";
  //obj2.style.left=(l[0])+"px";
  //obj2.style.zIndex="100";
  //obj2.style.display="block";
  //obj2.style.visibility="visible";
  //obj2.style.filter = "Alpha(Opacity=100)";
  //obj2.mozopacity = ".99";
	//obj2.style.opacity = ".99";
  }
   
  obj.style.filter = "Alpha(Opacity="+pwo+")";
  obj.MozOpacity = "."+(pwo-1);
	obj.style.opacity = "."+(pwo-1);
	pwo=pwo+25;
	//alert(pwo);
	if (pwo<75) {   mfq=window.setTimeout("please_wait(1)",15);}
	}

//fade out
if (mode==2){

  clearTimeout(mfq);

  //obj2=document.getElementById("wait2");

  if (pwo==0) {
  obj.style.display="block";
  obj.style.visibility="visible";
  }
  //obj2.style.filter = "Alpha(Opacity="+pwo+")";
  //obj2.mozopacity = "."+(pwo-1);
	//obj2.style.opacity = "."+(pwo-1);
  
  obj.style.filter = "Alpha(Opacity="+pwo+")";
  obj.MozOpacity = "."+(pwo-1);
	obj.style.opacity = "."+(pwo-1);
	pwo=pwo-25;
		
	if (pwo>0) {   mfh=window.setTimeout("please_wait(2)",15);}
  if (pwo<0) { pwo=0;}
  if (pwo==0) { obj.style.display="none";
                obj.style.visibility="hidden";
                   //       obj2.style.display="none";
           //     obj2.style.visibility="hidden";
     
  }

}

}

//function sets up mouseovers on result blocks
function result_setup(){

}

function rsrowo(row){

var tbl = document.getElementById("rst"+row);
var tr = tbl.getElementsByTagName("td");

for(var i=0, limit=tr.length; i < limit; ++i )
{
  currcol=tr[i].className;
  tr[i].className=tr[i].className+" bbs0";
}

}

function rsrowt(row){
var tbl = document.getElementById("rst"+row);
var tr = tbl.getElementsByTagName("td");

for(var i=0, limit=tr.length; i < limit; ++i )
{
  currcol=tr[i].className.replace("bbs0","");
  tr[i].className=currcol;
}

}

function rsrowc(mid) {window.open("/broadband/cheap-"+mid+".php","cbbuk");
buyclik(mid)

}

function preload_sorts() {
  pic1= new Image();pic1.src="http://www.comparebroadbanduk.com/images/filters/m2a.png";
  pic2= new Image();pic2.src="http://www.comparebroadbanduk.com/images/filters/m2b.png";
  pic3= new Image();pic3.src="http://www.comparebroadbanduk.com/images/filters/m2c.png";
  pic4= new Image();pic4.src="http://www.comparebroadbanduk.com/images/filters/m4a.png";
  pic5= new Image();pic5.src="http://www.comparebroadbanduk.com/images/filters/m4b.png";
  pic6= new Image();pic6.src="http://www.comparebroadbanduk.com/images/filters/m4c.png";
  pic7= new Image();pic7.src="http://www.comparebroadbanduk.com/images/filters/m5a.png";
  pic8= new Image();pic8.src="http://www.comparebroadbanduk.com/images/filters/m5b.png";
  pic9= new Image();pic9.src="http://www.comparebroadbanduk.com/images/filters/m5c.png";
  pic10= new Image();pic10.src="http://www.comparebroadbanduk.com/images/filters/m6a.png";
  pic11= new Image();pic11.src="http://www.comparebroadbanduk.com/images/filters/m6b.png";
  pic12= new Image();pic12.src="http://www.comparebroadbanduk.com/images/filters/m6c.png";
  pic13= new Image();pic13.src="http://www.comparebroadbanduk.com/images/filters/m7a.png";
  pic14= new Image();pic14.src="http://www.comparebroadbanduk.com/images/filters/m7b.png";
  pic15= new Image();pic15.src="http://www.comparebroadbanduk.com/images/filters/m7c.png";
}
