/********************************ALGEMEEN*******************************/

mmmaps = "";

function initmmmaps(phpwaarde) {
	//functie die waarde van $mmmaps uit php initialiseert als globale variabele in JS
	mmmaps = phpwaarde;

figurenladen();

	/*Extra (test)
	if (document.form.uitvoerder) {
		document.form.uitvoerder.focus();
	}*/
}


/***statusmaker***/
function linkStatus(obj) {
	window.status = obj.innerText;
	event.returnValue = true;
}


/***extra-BLOK***/
/*idLink is id van hoofdlink, idBlok is id van extra-tabel*/
/*innerText van hoofdlink moet altijd "Meer informatie" zijn!*/
function extra(idLink, idBlok) {
	var temp = eval("document.getElementById('" + idLink + "').innerHTML");
	/*alert("temp= " + temp);*/
	
	if(temp == 'Meer informatie') {
	eval("document.getElementById('" + idBlok + "').style.display= 'block'");
	eval("document.getElementById('" + idLink + "').innerHTML ='Verberg informatie'");
	}
	else {
	eval("document.getElementById('" + idBlok + "').style.display= 'none'"); 
	eval("document.getElementById('" + idLink + "').innerHTML ='Meer informatie'");
	}
}

function toonBlok(idBlok) {
	eval("document.getElementById('" + idBlok + "').style.display= 'block'");
}

function verbergBlok(idBlok) {
	eval("document.getElementById('" + idBlok + "').style.display= 'none'");
}


/***overlib**/

/***datum en tijd***/
function toonKlok(){
	var vandaag = new Date();
	var uren = vandaag.getHours();
	var min = vandaag.getMinutes();
	//var sec = vandaag.getSeconds();

	var dag = vandaag.getDate(); //van 0 tot 31
	//var weekdag = vandaag.getDay() //van 0 (zondag) tot 6(zaterdag)
	var maand = vandaag.getMonth() + 1; //+1, want begint blijkbaar maar te tellen vanaf 0 (?)
	//var jaar = vandaag.getYear(); //2 digits
	var jaar = vandaag.getFullYear(); //4digits

	if(min<10) min = "0" + min;
	//if(sec<10) sec = "0" + sec;
	if(dag<10) dag = "0" + dag;
	if(maand<10) maand = "0" + maand;
	if(jaar<10) dag = "0" + jaar;

	tijd = uren + ":" + min;
	datum = dag + "." + maand + "." + jaar;

	document.getElementById('klok').innerHTML= datum + " | " + tijd;

	setTimeout("toonKlok()",1000);
}

/***menu***/
var intVb, intSub, intTop;

function showmenu(nr) {
	//eerst alle parentmenu's weg en topimages op -0
	for(var i=1;i<7;i++){
		document.getElementById('menuDIV'+i).style.visibility = 'hidden';
		doeTopImageWeg(i);
		//document.getElementById('button'+i).src = mmmaps  + 'IMAGES/TOPNAV/' + i + '-0.gif';
		//--> zorgt voor problemen!
	}

	//dan diegene die moet blijven tonen
	document.getElementById('menuDIV'+nr).style.visibility = 'visible';
	
	//top-image aanpassen
	// document.getElementById('button'+nr).src = mmmaps  + 'IMAGES/TOPNAV/' + nr + '-1.gif';
	verwissel('button'+nr, mmmaps  + 'IMAGES/TOPNAV/' + nr + '-1.gif');
	
	//en timeout stoppen
	clearTimeout(intVb);
	clearTimeout(intTop);
}

function hidemenu(nr) {
	intVb = setTimeout("doeMenuWeg("+nr+")",300);
	intTop = setTimeout("doeTopImageWeg("+nr+")",300);
}

function showsubmenu(parentnr, subnr) {
	//blijf parent tonen
	clearTimeout(intVb);

	//toon submenu
	document.getElementById('menuDIV'+subnr).style.visibility = 'visible';

	//en timeout stoppen
	clearTimeout(intSub);
}

function hideSubMenu(subnr) {
	intSub = setTimeout("doeMenuWeg("+subnr+")",100);
}

function hideSubEnParentMenu(parentnr, subnr) {
	intSub = setTimeout("doeMenuWeg("+subnr+")",100);
	hidemenu(parentnr);
}

function doeMenuWeg(nr) {
	document.getElementById('menuDIV'+nr).style.visibility = 'hidden';
}

function doeTopImageWeg(nr) {
	// document.getElementById('button'+nr).src = mmmaps  + 'IMAGES/TOPNAV/' + nr + '-0.gif';
	verwissel('button'+nr, mmmaps  + 'IMAGES/TOPNAV/' + nr + '-0.gif');
}

function changeInStyle(me, bgcolor){
	me.firstChild.style.color = '#FFFFFF';
	me.style.backgroundColor = bgcolor;
}
function changeOutStyle(me, color){
	me.firstChild.style.color = color;
	me.style.backgroundColor = '';
}

/***preload img***/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function verwissel() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<verwissel.arguments.length; i+=2) {
			document[verwissel.arguments[i]].src = verwissel.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function figurenladen() {
	if (document.images) {
		menu1_lo = newImage(mmmaps  + "IMAGES/TOPNAV/1-0.gif");
		menu2_lo = newImage(mmmaps  + "IMAGES/TOPNAV/2-0.gif");
		menu3_lo = newImage(mmmaps  + "IMAGES/TOPNAV/3-0.gif");
		menu4_lo = newImage(mmmaps  + "IMAGES/TOPNAV/4-0.gif");
		menu5_lo = newImage(mmmaps  + "IMAGES/TOPNAV/5-0.gif");
		menu6_lo = newImage(mmmaps  + "IMAGES/TOPNAV/6-0.gif");
		menu1_hi = newImage(mmmaps  + "IMAGES/TOPNAV/1-1.gif");
		menu2_hi = newImage(mmmaps  + "IMAGES/TOPNAV/2-1.gif");
		menu3_hi = newImage(mmmaps  + "IMAGES/TOPNAV/3-1.gif");
		menu4_hi = newImage(mmmaps  + "IMAGES/TOPNAV/4-1.gif");
		menu5_hi = newImage(mmmaps  + "IMAGES/TOPNAV/5-1.gif");
		menu6_hi = newImage(mmmaps  + "IMAGES/TOPNAV/6-1.gif");
	}
	preloadFlag = true;
}


/********************************WRITERS********************************/

function writeBoven(){
writeTop();
writeNav();
writeActua();
}


function writeTop(){
document.write('	<table border="0" width="100%" height="64px" cellpadding="0" cellspacing="0" style="background-color:#182D48; background-image:url(\'' + mmmaps + 'IMAGES/TOPNAV/back_canteclaer4.jpg\')">');
document.write('		  <tr>');
document.write('			  <td width="520px"><div class="hand" onclick="javascript:location.href=\'http://www.canteclaer.be\'" style="width:520px; height:64px">&nbsp;</div></td>');
document.write('			  <td><div class="" onclick="" style="width:260px; height:64px">&nbsp;</div></td>');
document.write('		  </tr>');
document.write('	</table>');
}


function writeNav(){
document.write('<table border="0" width="100%" cellpadding="0" cellspacing="0" height="25px" style="background-color:#3D8FCC; background-image:url(IMAGES/TOPNAV/back_homepage_navi.gif)">');
document.write(' <tr>');
document.write('      <td>');
document.write('		<!--begin menus-->');
document.write('		<table cellpadding="0" cellspacing="0" border="0">');
document.write('		<tr>');
document.write('			<td width="10"/>');
document.write('			<td><a href="#" onmouseover="showmenu(1)" onmouseout="hidemenu(1)" id="menu1"><img src="IMAGES/TOPNAV/1-0.gif" name="button1" border="0" id="button1"></a></td>');
document.write('			  <td width="13"/>');
document.write('			<td><a href="#" onmouseover="showmenu(2)" onmouseout="hidemenu(2)" id="menu2"><img src="IMAGES/TOPNAV/2-0.gif" name="button2" border="0" id="button2"></a></td>');
document.write('			  <td width="13"/>');
document.write('			<td><a href="#" onmouseover="showmenu(3)" onmouseout="hidemenu(3)" id="menu3"><img src="IMAGES/TOPNAV/3-0.gif" name="button3" border="0" id="button3"></a></td>');
document.write('			  <td width="13"/>');
document.write('			<td><a href="#" onmouseover="showmenu(4)" onmouseout="hidemenu(4)" id="menu4"><img src="IMAGES/TOPNAV/4-0.gif" name="button4" border="0" id="button4"></a></td>');
document.write('			  <td width="13"/>');
document.write('			<td><a href="#" onmouseover="showmenu(5)" onmouseout="hidemenu(5)" id="menu5"><img src="IMAGES/TOPNAV/5-0.gif" name="button5" border="0" id="button5"></a></td>');
document.write('			  <td width="13"/>');
document.write('			<td><a href="#" onmouseover="showmenu(6)" onmouseout="hidemenu(6)" id="menu6"><img src="IMAGES/TOPNAV/6-0.gif" name="button6" border="0" id="button6"></a></td>');
document.write('		</tr>');
document.write('		</table>');
document.write('		<!--einde menus-->');
document.write('      </td>');
document.write('  </tr>');
document.write('</table>');
document.write('<script language="javascript" src="' + mmmaps + 'JAVASCRIPT/menuDIVs.js"></script>');
}

function writeActua() {
//document.write('<div style="margin-top:10px; margin-bottom:10px; height:50px; width:770px; background-color:white;">');
document.write('	<table style="margin-top:10px; margin-bottom:10px; height:50px; width:770px" class="standaard" cellspacing="0" cellpadding="0">');
document.write('	 <tr class="zetbovenaan">');
document.write('	  <td width="10px">&nbsp;</td>');
document.write('	  <td width="560px"><div id="Anchor"></div>');
document.write('	  </td>');
document.write('	  <td width="200px" id="klok" style="vertical-align:top; text-align:center;">');
document.write('	  </td>');
document.write('	 </tr>');
document.write('	</table>');
//document.write('</div>');
}

function writeCopyright() {
var nu = new Date;
var jaar = nu.getFullYear();

document.write('<div style="margin-left:10px;" class="copyright"><br/>');
document.write('<img src="' + mmmaps + 'IMAGES/GFX/LIJN-voet.gif" alt="" width="760px" height="1px"/><br/>');
document.write('&copy; Radio Canteclaer, 1995-' + jaar + ' | laatste aanpassing: ' + document.lastModified + ' | <a href="#">Home</a><br/><br/>');
document.write('</div>');
}


/********************************TICKER*********************************/

/******PARAMETERS******/

// Control parameters
var theCharacterTimeout = 30;
var theStoryTimeout     = 6000;
var theWidgetOne        =  "_";
var theWidgetTwo        =  "-";
var theWidgetNone       =  "";
var theLeadString       = "";

// Content parameters
var theDates = new Array();
var theSummaries = new Array();
var theSiteLinks = new Array();

theDates[0] ="16-19u: Tony Marten";
theSummaries[0] ="<b>Nu:</b> abc - when smokey sings (3:13)";
theSiteLinks[0] ="";

theDates[1] ="16-19u: Tony Marten";
theSummaries[1] ="<b>Vorig:</b> kylie minogue - chocolate (3:32)";
theSiteLinks[1] ="";

var theItemCount = theDates.length;


/******FUNCTIES******/

function buildSpaceFiller(aCount)
{
   var myResult = "";
   for(var ii=0; ii<aCount; ii++)
   {
      myResult = myResult + "  ";
   }
   return myResult;
}
function whatWidget()
{
   if(theCurrentLength == theStorySummary.length)
   {
      return theWidgetNone;
   }
   if((theCurrentLength % 2) == 1)
   {
      return theWidgetOne;
   }
   else
   {
      return theWidgetTwo;
   }
}
function startTicker()
{
   // Define run time values
   theCurrentStory     = -1;
   theCurrentLength    = 0;
   theSpaceFiller      = buildSpaceFiller(200);

   // Locate base objects
   theAnchorObject     = document.getElementById("Anchor");

   // Fire up the ticker
   runTheTicker();
}

function runTheTicker()
{
   var myTimeout;

   // Go for the next story data block
   if(theCurrentLength == 0)
   {
      theCurrentStory++;
      theCurrentStory		= theCurrentStory % theItemCount;
      theStoryDate			= theDates[theCurrentStory];
      theStorySummary		= theSummaries[theCurrentStory];
      theTargetLink			= theSiteLinks[theCurrentStory];
      //theAnchorObject.href 	= theTargetLink;
   }

   // Stuff the current ticker text into the anchor
   theAnchorObject.innerHTML = "<b><u>" + theStoryDate + "</u></b><br/>" +
			       theStorySummary.substring(0,theCurrentLength) +
			       whatWidget() + theSpaceFiller;

   // Modify the length for the substring and define the timer
   if(theCurrentLength != theStorySummary.length)
   {
      theCurrentLength++;
      myTimeout = theCharacterTimeout;
   }
   else
   {
      theCurrentLength = 0;
      myTimeout = theStoryTimeout;
   }

   // Call up the next cycle of the ticker
   setTimeout("runTheTicker()", myTimeout);

}


function openDialog(url, width, height) {
	window.open(url, "dialog", "width=" + width +", height=" + height +", location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0");	
}