var last=null;
var first=null;

function klick(num)
{
 if (num != '')
 {
  var thiso=document.getElementById(num);
  if (thiso)
  {
	var color_sel=thiso.style.backgroundColor;
	if(last)
	{
	  last.getElementsByTagName('b').item(0).style.borderBottom='1px solid #FFF';
	}
	thiso.getElementsByTagName('b').item(0).style.borderBottom='1px solid '+color_sel;
	document.getElementById('lowbar').style.backgroundColor=color_sel;
	last=thiso;
	var label='H-'+thiso.id;
	document.getElementById('menu').innerHTML=document.getElementById(label).innerHTML;
  }
 }
 else
 {
  document.getElementById('menu').innerHTML='';
 }
}

function resizecontent()
{
document.body.style.overflow='hidden';
 var maintop=132;
 if (document.body.clientHeight>maintop+10)
 {
  var thisp=document.getElementById('main');
  var mainheight=document.body.clientHeight-maintop-3;
  thisp.style.height=(mainheight)+'px';
  if (document.getElementById('maincontent'))
  {
    var thisp=document.getElementById('maincontent');
    thisp.style.height=(mainheight-5)+'px';
    var thisp=document.getElementById('mainindex');
    thisp.style.height=(mainheight-5)+'px';
  }
  var thisp=document.getElementById('left');
  thisp.style.height=(mainheight-1)+'px';
  var thisp=document.getElementById('left2');
  thisp.style.height=(mainheight-1)+'px';
 }
 var mainleft=80;
 if (document.body.clientWidth>mainleft+5)
 {
  var thisp=document.getElementById('main');
  var mainwidth=document.body.clientWidth-mainleft-5;
  if (mainwidth>920) {mainwidth=920;}
  if (mainwidth<600) {mainwidth=600;}
  thisp.style.width=(mainwidth)+'px';
  if (document.getElementById('maincontent'))
  {
    var thisp=document.getElementById('maincontent');
    thisp.style.width=(mainwidth-200)+'px';
  }
  var thisp=document.getElementById('top');
  thisp.style.width=(mainwidth)+'px';
  var thisp=document.getElementById('slagzin');
  thisp.style.width=(mainwidth-150)+'px';
  var thisp=document.getElementById('lowbar');
  thisp.style.width=(mainwidth)+'px';
  var thisp=document.getElementById('T-menubar');
  thisp.style.width=(mainwidth)+'px';
 }
 //document.body.style.overflow='auto';
}


function plaatsLocationData()
{
  var locationdata_html=document.getElementById('locationdata_html');
  var locationdata_container=document.getElementById('locationdata_container');
  locationdata_container.innerHTML=locationdata_html.innerHTML;
  locationdata_html.innerHTML='';
}



function clk(id,link)
{
  if(document.images) { (new Image()).src="/leave.asp?id="+id+"&link="+link; }
  return true;
}



function fnToggle()
{
	if (is_win && ie5)
	{
		prvImageContainer.filters[0].Apply();
		document.getElementById('prvImage' + activeImage).style.visibility='hidden';
		if (activeImage == maxImages) activeImage=0;
		activeImage++;
		document.getElementById('prvImage' + activeImage).style.visibility='visible';
		prvImageContainer.filters[0].Play();
	} else {
		document.prvImage.src = img[activeImage].src;
		activeImage++;
		if (activeImage > maxImages) activeImage=1;
	}
}    		
function beginTransitions()
{
	timerID = setInterval('fnToggle()', 3000);
}





var agt = navigator.userAgent.toLowerCase();
var dom = (document.getElementById) ? true : false;
//var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
//var ns4 = (document.layers && !dom) ? true : false;
//var ie4 = (document.all && !dom) ? true : false;
//var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
var is_win  = ((agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1)) ? true : false;
// NS4 resize fix:
/*
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}
*/



function showcal(inputbox,visible,jaar,maand) {
	var callendar1=document.getElementById("cal1");
	if (visible==1) {
	  if (inputbox != '') { 
		var inputbox1=document.getElementById(inputbox);
		callendar1.style.left=inputbox1.style.left;
		var callendar1=document.getElementById("cal1");
		var tt=callendar1.getElementsByTagName('td');
		ShowCallendarMonth(inputbox,tt.item(0),jaar,maand);
	  }
	  callendar1.style.visibility="visible";
	} else {
	  callendar1.style.visibility="hidden";
	}
}
function showfreetextinput(inputbox,visible) {
	var dropdowninput=document.getElementById("txt"+inputbox);
	var freetextinput=document.getElementById("freetext"+inputbox);
	var freetextbutton=document.getElementById("freetextbutton"+inputbox);
	if (dropdowninput && freetextinput && freetextbutton) { 
	  if (visible==1) {
		freetextinput.style.visibility="visible";
		freetextbutton.value='<-';
		freetextbutton.onclick=function() {showfreetextinput(inputbox,0)};
		freetextinput.value=dropdowninput.value;
	  } else {
		freetextinput.style.visibility="hidden";
		freetextbutton.value='...';
		freetextbutton.onclick=function() {showfreetextinput(inputbox,1)};
		dropdowninput.value=freetextinput.value;
		if (freetextinput.value=='') {
			if (dropdowninput.options[0].value=='') dropdowninput.options[0].selected=true;
		}
		if (dropdowninput.value!=freetextinput.value) {
			dropdowninput.options[dropdowninput.options.length]=new Option(freetextinput.value,freetextinput.value);
			dropdowninput.value=freetextinput.value;
		}
	  }
	}
}
function MakeArray(n) {
	this.length = n
	return this
}
function st(inputbox,d) {
  document.getElementById(inputbox).value=d;
  showcal(inputbox,0);
}
/*
function getTop(el) {
	if (el.offsetParent) { return el.offsetTop + getTop(el.offsetParent); }
	else  { return el.offsetTop  ; }//+ parseInt(el.style.top)
}
function getLeft(el) {
	if (el.offsetParent) { return el.offsetLeft + getLeft(el.offsetParent); }
	else  { return el.offsetLeft + parseInt(el.style.left); }
}
*/

function ShowCallendarMonth(inputbox,calbox,jaar,maand)
{
	var datum_today=new Date();

	var objInputbox=document.getElementById(inputbox);
	var textinbox=objInputbox.value;
	var dateinbox;
	var objRegExp=/\b(0?[1-9]|[12][0-9]|3[01])[\-\/](1[0-2]|0?[1-9])[\-\/]((19|20)\d{2})/;
	var matchArray = objRegExp.exec(textinbox);
	if (matchArray) {
	  dateinbox=new Date(matchArray[3],matchArray[2]-1,matchArray[1]);
	  if ((jaar==0) || (maand==0)) {
		jaar=dateinbox.getYear();
		maand=dateinbox.getMonth()+1;
	  }
	} else {
	  if ((jaar==0) || (maand==0)) {
		jaar=datum_today.getYear();
		maand=datum_today.getMonth()+1;
	  }
	}

	var d=new Date(jaar,maand-1,1);
	var weekdag=(d.getDay()+6) % 7 +1;
	var html= '<pre>';

var callendar1=document.getElementById("cal1");
if (inputbox != '') { 
	var inputbox1=document.getElementById(inputbox);
	var el=inputbox1;
	tottop=0;
	totleft=0;
	while (el) {
	  if ((el.tagName!='A') && (el.tagName!='FORM')) {
//		html+= el.tagName+'.';
//		html+= el.offsetTop+'.';
	  tottop+=el.offsetTop;
//		html+= el.tagName+'.';
//		html+= el.offsetLeft+'.';
	  totleft+=el.offsetLeft; }
	  el=el.parentElement;
	  if (el.tagName=='DIV') {el=0;}
	}
		//html+= tottop+'.'+totleft
		tottop=tottop+18;
	callendar1.style.visibility="visible";
	callendar1.style.top=tottop;
	callendar1.style.left=totleft;
}

	if (dateinbox) { dateinbox=dateinbox.toDateString();}
	if (datum_today) {datum_today=datum_today.toDateString();}

	monthNames = new MakeArray(12);
	monthNames[1] = 'januari';
	monthNames[2] = 'februari';
	monthNames[3] = 'maart';
	monthNames[4] = 'april';
	monthNames[5] = 'mei';
	monthNames[6] = 'juni';
	monthNames[7] = 'juli';
	monthNames[8] = 'augustus';
	monthNames[9] = 'september';
	monthNames[10] = 'oktober';
	monthNames[11] = 'november';
	monthNames[12] = 'december';

	var dd=new Date(jaar,maand-2,1);
	html+= "<a href=# onclick=\"javascript:showcal('" + inputbox + "',1," + dd.getYear() + "," + (dd.getMonth()+1) + ");\">&lt;-</a>"
	html+= " <b>" + monthNames[d.getMonth()+1] + " " + d.getYear() + "</b>";
	for (i=1; i<(11-monthNames[d.getMonth()+1].length); i++) { html+= " "; }
	var dd=new Date(jaar,maand,1);
	html+= "<a href=# onclick=\"javascript:showcal('" + inputbox + "',1," + dd.getYear() + "," + (dd.getMonth()+1) + ");\">-&gt;</a>\n"
	html+= "ma di wo do vr za zo \n";
	for (i=1; i<=(weekdag-1); i++) { html+= '   '; }
	do {
		var dag=d.getDate();
		if (dag<10) { html+= " "; }

		html+= "<a";

		if (d.toDateString()==dateinbox) { html+= " class='selected_current'"; }

		if (d.toDateString()==datum_today) {
		  html+= " id='selected_today' title='vandaag'";
		}
	
		html+= " href=# onclick=javascript:st('" + inputbox + "','" + dag + "-" + maand + "-" + jaar + "')>" + dag + "</a> ";

		d.setTime(d.getTime() + (24 * 60 * 60 * 1000) + (5*60*1000));
		weekdag=weekdag+1;
		if (weekdag>7) {
			weekdag=1;
			html+= '\n';
		}
	} while (d.getMonth()+1 == maand);
	for (i=weekdag; i<=7; i++) { html+= '   '; }
	html+= "<a href=#><b>X</b></a>";
	//html+= "</pre>";
	calbox.innerHTML=html;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function storeCookie(name, value){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+ 60);
	document.cookie = name + "=" + escape(value)+";expires="+exdate.toGMTString() + "path=/";
}
function getCookie(name){
	if (document.cookie.length > 0) {
		c_start=document.cookie.indexOf(name + "=")
			if (c_start != -1) {
				c_start = c_start + name.length + 1;
				c_end = document.cookie.indexOf(";", c_start);
			    if (c_end == -1) c_end=document.cookie.length;
   				return unescape(document.cookie.substring(c_start,c_end));
   			} 
	}
	return "";
}

function editShowCity(city) {
	var input=document.getElementById('showcity_'+city);
	var div=document.getElementById('city_'+city);
	if(input && div) {
		div.style.display=(input.checked ? '' : 'none');
		value = input.checked;
		storeCookie(input.id, (value ? '1' : '0'));
	}
}
function initShowCities(count) {
	for(var city=1; city<=count; city++) {
		value = getCookie('showcity_'+city);
		var input=document.getElementById('showcity_'+city);
		input.checked = (value=='1' || value=='');
		editShowCity(city);
	}
}

