var image_close = '<img src="/images/meta/close.gif" width="18" height="16" align="right" alt="Close" border="0" vspace="0" hspace="0"></img>';
var image_restore = '<img src="/images/meta/restore.gif" width="18" height="16" align="right" alt="Restore" border="0" vspace="0" hspace="0"></img>';

var site = 'http://www.topdownloads.net'; // to be sure there is a link (backup url);

var windowtype = "0";
if(getCookie("input") != '*')
	windowtype=getCookie('input');
if(getCookie("blokken") != '*')
	blokkenString = getCookie("blokken");
else blokkenString = ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;";
if (navigator.appName!="Microsoft Internet Explorer" || parseInt(navigator.appVersion) >= 4)
	var blokArray = blokkenString.split(";");
d=document;

function click()
{
  if (navigator.appName=="Microsoft Internet Explorer")
  {
    if (event.button==2)
      alert('Copyright Topdownloads © 1999-2005')
  }
}
document.onmousedown=click
var kolom = new Array();
var kolAant;
var bgKleur;
//var blKleur;
//var tipKleur;
//var kopKleur=new Array();

function windowWidth(method) {
	if (parseInt(navigator.appVersion) < 4) return (600);
	else {
		if (windowtype==0) return(screen.width*0.8);
		if (windowtype==2) return(screen.width*0.99);
	}
}
function windowHeight(method) {
	if (parseInt(navigator.appVersion) < 4) return (280);
	else {
		if (windowtype==0) return((screen.height*0.85)-200);
		if (windowtype==2) return(screen.height*0.80);
	}
}
function c(naam) {
	startDate= new Date();
	tmpWin = window.open(naam, startDate.getTime(),'toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,menubar=no,width=720,height=380');
}

function go(kolnum,bloknum,linknum,site) {
	scrText1="toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width=";
	scrText2="toolbar=no,location=no,resizable=no,status=no,scrollbars=no,menubar=no,width="
	naamDate= new Date();
	naam= naamDate.getTime();
	
	with (kolom[kolnum].blok[bloknum].hlinks[linknum]) {
	
	   if ((openMethod=='n' || openMethod=='s') && parseInt(navigator.appVersion) >= 4) {
			fromTop=(screen.height/100)* 14;
			fromLeft=(screen.width/100)* 9;
	   }
	   else {
			fromTop=0;
			fromLeft=0;
	   }
	   if (site!=null) adres=site;
	   if (openMethod=='n')
	   {    
		if (windowtype==1) top.location.href=adres.replace('@@','?');
		else
			tmpWin2=window.open(adres.replace('@@','?'),naam,scrText1 +
			(windowWidth('n')+",height="+windowHeight('n')+
			",left=" +fromLeft+",top="+fromTop));
	   }
	   else
		if (openMethod=='r')
			top.location.href=adres.replace('@@','?');
		else
			tmpWin2=window.open(adres.replace('@@','?'),naam,scrText2 +
			(scrWidth + ",height="+scrHeight+",left="+fromLeft+",top="+fromTop));
	}
}
function n(naam){
	startDate= new Date();
	if (windowtype==0){
		if (parseInt(navigator.appVersion)>=4){
			tmpWin2=window.open(naam,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width="+
			((screen.width/100)*80)+",height="+(((screen.height/100)*85)-200)+",left="+((screen.width/100)*9)+",top="+((screen.height/100)*14));}
		else {tmpWin2=window.open(naam,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width=600,height=280");}}
	if (windowtype==1)top.location.href=naam;
	if (windowtype==2){ 
		if(parseInt(navigator.appVersion)>=4){
			tmpWin2=window.open(naam,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width="+
			((screen.width/100)*99)+",height="+(((screen.height/100)*107)-200)+",left=0,top=0");}
		else{tmpWin2=window.open(naam,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width=600,height=280");}}
}
function r()
{
	window.alert('opmerking: indien u problemen ondervindt met de volgende functionaliteit moet u de realplayer downloaden. Klik hiertoe op help (bovenin de startpagina).')
}
function mo(a,b,c)
{
	window.status=kolom[a].blok[b].hlinks[c].adres.replace('@@','?');
}
function co()
{
	window.status="";
}
function doSearch(kolNum,blokNum)
{
   var words;
   words = document.searchforit.query.value;
   var searchitems=addplus(words);
   var index = document.searchforit.service.selectedIndex;
   var site = document.searchforit.service.options[index].value;
   site+=searchitems;
   if (notEmpty(searchitems))
   {
	   go(kolNum,blokNum,index,site);
   }
}
function notEmpty(word)
{
   if (word==""||word==null)
   {
      self.status="ENTER SEARCH searchitems";
      alert("\n Please enter a keyword\n\n and press on Go !");
      document.searchforit.query.focus();
      return false;
   }
   else
   {
	self.status="SEARCHING FOR:  "+word;
	return true;
   }
}
function addplus(items)
{
   var plussed ="";
   for (var t =1 ; t <= items.length ;  t++)
      {
	if (items.substring(t-1,t)=="")
	  plussed+="+";
	else
	{
	     if (items.substring(t-1,t)=="+")
		plussed+="%2B";
	     else
		plussed+=items.substring(t-1,t);
	}
      }
   return plussed;

}

function addLink(adres,oms,opties,special,scrW,scrH) {
	this.hlinks[this.nextLink]=new hlink(adres,oms,opties,special,scrW,scrH);
	this.nextLink++;
}
function addBlok(bloknaam,hideNum,kopKleur,blokType) {
	this.blok[this.nextBlok]= new bloktype(bloknaam,hideNum,kopKleur,blokType);
	this.nextBlok++;
}
function hlink(adres,oms,opties,special,scrW,scrH) {
	//if (opties.substring(1,2)!='2') this.adres='HTTP://';
	//else 
	this.adres='';
	//if (opties.substring(1,2)=='1')
	//	this.adres+='www.'+adres;
	//else
	this.adres+=adres;
	this.oms=oms; this.meerRegel=false
	this.openMethod=opties.substring(0,1);
	if (this.openMethod=='s')
	   { this.scrWidth=scrW; this.scrHeight=scrH;}
	this.extra=''; optie3=opties.substring(1,2);
if (optie3=='0')
		this.extra='</A><BR>'
	if (optie3=='1')
		this.extra='</A><FONT SIZE="1" COLOR="'+extra_text_color+'"></FONT><FONT SIZE="1" COLOR="red"> (tip)</FONT><BR>'
	else
	if (optie3=='2')
		this.extra='</A><FONT SIZE="1" COLOR="'+extra_text_color+'"></FONT><FONT SIZE="1" COLOR="blue"> (new)</FONT><BR>'
	else
	if (optie3=='3')
		this.extra='</A><FONT SIZE="1" COLOR="'+extra_text_color+'"></FONT><FONT SIZE="1" COLOR="FFFFE6">.</FONT><BR>'
	else
	if (optie3=='m')
		{this.meerRegel=true;this.linkCol=special;}
	else
	if (optie3=='8')
		this.extra=' </A>, ';
	else
	if (optie3=='9')
		this.extra='</A><FONT SIZE="2" COLOR="'+extra_text_color+'"> '+special+'</FONT><BR>'
}
function bloktype(kop,hideNum,color,btype)
{
	this.kop=kop;
	this.color=color;
	this.hlinks= new Array();
	this.hideNum=parseInt(hideNum);
	if (blokArray[this.hideNum]!='Y') this.show=true; else this.show=false;
	this.nextLink=0;
	this.addLink=addLink;
	if (btype=='S') this.btype='Search';
	else this.btype='Norm';
}
function kolomtype(num)
{
	this.kolomnum=num;
	this.blok= new Array();
	this.nextBlok=0;
	this.addBlok=addBlok;
}

function vulObjecten() {

 kolAant = -1; 
 kolNum = kolAant;
  
 lijstLengte = lijst.length;

 for (i=0; i < lijstLengte; i++) {

    record=lijst[i].split("¶");

     if (record[0]=='K') {

		// Het gaat om een nieuwe kolom
		kolAant++; kolNum=kolAant;
		kolom[kolNum] = new kolomtype(kolNum);
		var blokNum = -1;
     }
     else {

		 if (record[0]=='B'||record[0]=='S') {
		 
		    // Het gaat dus om een kop
		    blokNum++;
		    kolom[kolNum].addBlok(record[1],record[2],max_block_head_bgcolor,record[0]);
		 }
	     else {
		    // Het gaat om een hyperlink
		    with (kolom[kolNum]) {
				blok[blokNum].addLink(record[0],record[1],record[2],record[3],record[4],record[5]);
		    }
		 }
		 
      }
   }
}

function writeKop(kolNum,blokNum) {
   with (kolom[kolNum].blok[blokNum]) {
   
     document.writeln('<TABLE cellSpacing=1 bgColor=#0a80f9 WIDTH="215" border=0 cellspacing=0>' +
	 '<TR><TD BACKGROUND="'+max_block_head_background+'" BGCOLOR="#0a80f9">' +
     '<FONT SIZE="2" FACE="Verdana" COLOR="' + max_block_head_text + '"><B>' + kop +
     '</B></FONT></TD><TD BACKGROUND="'+max_block_head_background+'" BGCOLOR="#0a80f9" ALIGN=RIGHT>');
	 
     if (show==true) {
		document.writeln('<A HREF=JavaScript:hide('+kolNum+','+ blokNum+');>'+image_close+'</a></td></TR><TR><TD bgcolor="#FFFFE6" colspan=2 background="bg-table-text.jpg"><font face="Verdana" size="2"><font face="Verdana" size="2">');

		if (btype=='Search') {
		   document.writeln('<FORM NAME=searchforit ACTION=javascript:doSearch('+kolNum+','+blokNum+');void(0)//method=GET>');
		   document.writeln('<SELECT NAME="service">');
		}
     }
     else {
		document.writeln('<A HREF=JavaScript:unhide('+kolNum+','+blokNum+');><img align=right border=0  height=15 width=18'     +
		' src="o.gif"></img></a></td></TR><TR><TD bgcolor="'+max_block_links_bgcolor+'" colspan=2><font face="Verdana" size="2">');
     }
   }
}

function writeLinks(kolNum,blokNum) {

     for (k=0; k<kolom[kolNum].blok[blokNum].nextLink; k++) {
		with (kolom[kolNum].blok[blokNum].hlinks[k]) {
	
		   if (kolom[kolNum].blok[blokNum].btype=='Norm') {
				goWord=i+','+j+','+k;
				if (meerRegel) { 
					document.writeln("<img src=\"/images/buttons/addurl.gif\" border=\"0\"></img>");
					document.writeln('<A HREF="javascript:go('+goWord+');"' +
					' onMouseOver="mo('+goWord+');return(true);" onMouseOut="co();">'+
				    '<font color="'+linkCol+'"><I>'+oms+'</I></A></FONT><BR>');
				}
				else {
					document.writeln("<img src=\"/images/buttons/addurl.gif\" border=\"0\"></img>");
					document.writeln('<A HREF="javascript:go('+goWord+');"'+
			       ' onMouseOver="mo('+goWord+');return(true);" onMouseOut="co();">'+
			       oms + extra);
				}
		   }
		   else {
			document.writeln('<option value="'+adres.replace('@@','?')+'">'+oms);
		   }
		}
     }
}

function getCookie(cookieNaam) {
  var cname = cookieNaam + "=";
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + cname.length;
    if (document.cookie.substring(i, j) == cname){
    var leng = document.cookie.indexOf (";", j);
    if (leng == -1) leng = document.cookie.length;
    return unescape(document.cookie.substring(j, leng));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return "*";
}
function delCookie(cookieNaam)
{
  document.cookie = cookieNaam + "=; expires= Thu, 01-Jan-70 00:00:01 GMT";
  document.cookie = cookieNaam + "=; expires= Thu, 01-Jan-70 00:00:01 GMT; path=/";
  return true;
}

function setCookie(cookieNaam, cookieInhoud)
{
  document.cookie = cookieNaam + "= " + escape (cookieInhoud) +
	"; expires=Mon, 01-Jan-2030 00:00:01 GMT; path=/"
}
var UrlLijst= new Array();
function persLink(Url,Bijschrift)
{
    this.Url=Url;
    this.Bijschrift=Bijschrift;
}
//function getPersLinks()
//{
//   cookieWaarde= getCookie('PERSLINK');
//    if (cookieWaarde=='*')
//    {
//       return false
//    }
//    else
//    {
//       UrlGegevens = cookieWaarde.split("¶¶");
//       for (p=0; p < UrlGegevens.length; p++)
//       {
//	    kruimel = UrlGegevens[p].split("  ");
//	    UrlLijst[p]= new persLink(kruimel[0], kruimel[1]);
//       }
//       return true;
//    }
//}

function writeClosedBlock(colNum,blockNum) {

   with (kolom[colNum].blok[blockNum]) {
     document.writeln('<table width="100%" border=0 cellspacing=0>');
	 document.write('<tr><td background="'+closed_block_background+'" bgcolor="'+closed_block_bgcolor+'">');
     document.write('<a href=JavaScript:unhide('+colNum+','+blockNum+');>'+image_restore+'</a>');
	 document.write('<font size="2" face="Verdana,helvetica" color="' + closed_block_text + '"><b>' + kop + '</b></font>');
	 document.writeln('</td></tr>');
	 document.writeln('</table><br>');
   }
}


function writeContents() {

vulObjecten();

d.write("<table cellspacing=0 cellpadding=10 border=0><tr>");

for (i=0; i <= kolAant; i++) {

  with(kolom[i]) {
	document.writeln('<td width=195 valign="top">');

	// ================================================================================================
	// START PERSOONLIJKE LINKS (worden geprint, als kolom == 2 (3e kolom) helemaal boven);
	
	if (i==2) {
		d.write('<table width="215" border=0 cellspacing=1 bgColor=#0a80f9>');
		d.write('<tr><td BACKGROUND="'+max_block_head_background+'" BGCOLOR="#0a80f9"><font size=2 face="Verdana" color="#FFFFFF"><B>Put Personal Links</B></FONT></TD><TD ALIGN=RIGHT BACKGROUND="'+max_block_head_background+'" BGCOLOR="#0a80f9">');  
		d.write(image_close+'</td></TR><TR><TD bgcolor="FFFFE6" colspan=2><font face="Verdana" size="2">');

		if(getCookie("PERSLINK") != '*'){
				   var UrlGegevens=getCookie("PERSLINK").split("¶¶");
	    	   for (z=0; z < UrlGegevens.length; z++){
	  	     		pr = UrlGegevens[z].split("  ");
					d.write('<img src="/images/buttons/addurl.gif"> <a href="http://'+pr[0]+'")>'+pr[1]+'</a></img><BR>');}}
		d.write('<A href="/services/perslink2.php"><img src="/images/buttons/addurl.gif" border="0"> Put Favorites Links</img></A><FONT SIZE="1" COLOR="red"> (tip)</font><br>');

		d.write('</font></td></tr>');
		d.write('</table><br>');

	}
	// ================================================================================================	
	
	// ================================================================================================
	// START PRINTEN GEOPENDE BLOKKEN 
		for (j=0; j < nextBlok; j++) {
	
	   with(blok[j]) {
	  
	     if (show==true) {
			writeKop(i,j);
			writeLinks(i,j);
		
			if (btype=='Search') {
				document.writeln('</SELECT><BR>');
				document.writeln('<input name="query" VALUE="" size=15>');
				document.writeln('<INPUT TYPE="button" VALUE="Go" onClick="doSearch('+i+','+j+')">');
			}
		
			document.writeln('</td></tr>');
			document.writeln('</table><br>');
	     }
	  }
	}
	// ================================================================================================

	// ================================================================================================
	// START PRINTEN GESLOTEN BLOKKEN (onderaan de kolom)

	for (j=0; j < nextBlok; j++) {
	
	  with(blok[j]) {
	  
	     if (show!=true) {
			writeClosedBlock(i,j);
	     }
	  }
	}

	// START PRINTEN ALLE BLOKKEN 
	// ================================================================================================

	document.writeln('</td>');
  }

}

document.write('</tr></table>');

}

