function bb_trwizard(url)
{
  window.open(url,"win_wizard","width=495, height=359, resizable=no, titlebar=no");
  return false;

}

var straName=new Array();
var straID=new Array();
var straHow=new Array();
var intaCost=new Array();
var straHover=new Array();

var intChannelCount=0;

function store(strID, strName, strHow, intCost, strHover)
{

intChannelCount=intChannelCount+1;

straID[intChannelCount]=strID;
straName[intChannelCount]=strName;
straHow[intChannelCount]=strHow;
intaCost[intChannelCount]=intCost;
straHover[intChannelCount]=strHover;


}

function drawtile(intX, ynImages)
{
var longimage="'styles/images/logos/"+straID[intX]+".png'";
var strS="<li><a href=\"showchannel.php?id="+straID[intX]+"\">"; //<div class=\"tile\">";

//if (straHover[intX]=="") {strS=strS+"<a href=\"#\" onmouseover=\"idhelper.src="+longimage+";return false;\">";}
//  else { strS=strS+"<a href=\"#\" onmouseover=\""+straHover[intX]+"\">";};

  //onmouseover=\"$dohow\"

//if (ynImages) strS=strS+"<img src="+longimage+" class=tvlogo>";
strS=strS+straName[intX]+"</a> <i class=\"lite\">"+straHow[intX]+"<\/i><br>";
//strS=strS+"<div class=\"line3\">"+straID[intX]+"<\/div>";
//strS=strS+"<\/div>";
document.write (strS);

}

function drawtilesmall(intX)
{
//var longimage="'styles/images/logos/"+straID[intX]+".png'";
var strS; //="<div class=\"tile\">";

//if (straHover[intX]=="") {strS=strS+"<a href=\"#\" onmouseover=\"idhelper.src="+longimage+";return false;\">";}
  //else {
  strS="<a href=\"#\" onmouseover=\""+straHover[intX]+"\">";
  //};

  //onmouseover=\"$dohow\"

//strS=strS+"<img src="+longimage+" class=tvlogo></a>";
//strS=strS+"<div class=\"line1\">"+straName[intX]+"<br><span class=\"lite\">"+straHow[intX]+"<\/span><\/div>";
strS=strS+""+straName[intX]+"</a><br><span class=\"vsmall\">"+straHow[intX]+"<\/span><br>";

//strS=strS+"<div class=\"line3\">"+straID[intX]+"<\/div>";
//strS=strS+"<\/div>";
document.write (strS);



}





function countcost(intValue)
{
var intTotal=0;

for (var intLoopCounter=1; intLoopCounter<=intChannelCount; intLoopCounter++)
 {
  	if (intaCost[intLoopCounter]==intValue) intTotal=intTotal+1;
 };

return intTotal;

}


function drawcost(intValue, intWidth, ynImages)
{

var strOthers="";
document.write ("<ul>"); //<table border=0 cellpadding=0 cellspacing=0>");
var intRC=0;
var intOC=0;


for (var intLoopCounter=1; intLoopCounter<=intChannelCount; intLoopCounter++)
 {
  	if (intaCost[intLoopCounter]==intValue) {
     if (straID[intLoopCounter]=="") {
       strOthers=strOthers+straName[intLoopCounter]+" - ";
       intOC=intOC+1;
     }
     else
     {
//       if (intRC==0) {document.write ("<tr class=\"tile\"><td class=\"tile\">")} else {document.write ("<td class=\"tile\">")};
      	drawtile(intLoopCounter, ynImages);
//       intRC=intRC+1;
//       if (intRC==intWidth) {document.write ("<\/td><\/tr>"); intRC=0} else document.write ("<\/td>");
     };
   };

 };

//document.write ("<\/table>");
document.write ("</ul>");

if (strOthers!="") document.write ("<p class=\"others\">Plus "+intOC+" other TV channels: "+strOthers+"<\/p>");

document.write ("<hr>");


}

function drawcostsmall(intValue)
{

var strOthers="";
//document.write ("<table border=0 cellpadding=0 cellspacing=0>");
var intRC=0;
var intOC=0;

for (var intLoopCounter=1; intLoopCounter<=intChannelCount; intLoopCounter++)
 {
  	if (intaCost[intLoopCounter]==intValue) {
     if (straID[intLoopCounter]=="") {
       strOthers=strOthers+straName[intLoopCounter]+" - ";
       intOC=intOC+1;
     }
     else
     {
//       if (intRC==0) {document.write ("<tr class=\"tile\"><td class=\"tile\">")} else {document.write ("<td class=\"tile\">")};
      	drawtilesmall(intLoopCounter);
       intRC=intRC+1;
//       if (intRC==3) {document.write ("<\/td><\/tr>"); intRC=0} else document.write ("<\/td>");
     };
   };

 };

//document.write ("<\/table>");

//if (strOthers!="") document.write ("<p class=\"others\">Plus "+intOC+" other TV channels: "+strOthers+"<\/p>");

}




var intTempA=0;
var aa=new Array();

function bycost(ynImages)
{
intTempA=0;


for (var inti=1; inti<=intChannelCount; inti++)
 {
  	byinsert(intaCost[inti]);
  	//document.write (intaCost[inti]);
 };

//document.write ("intTempA="+intTempA);
// !!!!!!!!!!!!! STILL NEEDS SORTING..... !!!!!!!!!!!

var ynMore=true;
var intSwap;
var intC;
var strFullIndex="<b>Your choices<b><hr>";

if (intTempA>1) {
do
  {
  ynMore=false;
  for (var inti=1; inti<intTempA; inti++)
   {
     if (aa[inti]<aa[inti+1]) {intSwap=aa[inti+1]; aa[inti+1]=aa[inti]; aa[inti]=intSwap; ynMore=true;};
   }

  }
while (ynMore==true);
};


for (var inti=intTempA; inti>0; inti--)
 {
 intC=aa[inti];
 strNews="";
 //alert ("<p>hello!!!!</p>"+intTempA+","+inti+","+intC+" "+aa[inti]+aa[0]);

 if (aa[inti]!=9999) {
  document.write ("<a name=\"for"+aa[inti]+"\">");
  document.write ("<h3>You get these "+countcost(aa[inti])+" channels ");
  if (aa[inti]!=0) {strNews="for £"+aa[inti];} else strNews="now"
  document.write (" "+strNews+"<\/h3></a>");
  if (strWhy[intC]!="") document.write("<p class=\"why\">"+strWhy[intC]+"<\/p>");
  drawcost(aa[inti], 1, ynImages);

  strFullIndex=strFullIndex+"<br><a href=\"#for"+aa[inti]+"\">"+countcost(aa[inti])+" "+strNews+"</a>";

 };



};

 return strFullIndex;

function byinsert(intValue)
{

var ynNew=true;

if (intTempA!=0)
 {
 for (var intc=1; intc<=intTempA; intc++)
   {
   if (aa[intc]==intValue) ynNew=false;
   }
 }

if (ynNew) {
  intTempA=intTempA+1;
  aa[intTempA]=intValue;
  };

}
}




