// ===================================================================
// Author: Kolibrie Creatieve Media (c) 2006
// http://www.kolibrie.net/
// ===================================================================

function objRef(id) {return document.getElementById(id)}
function styleRef(id) {return this.objRef(id).style}

function hl(id){
	b=id.src;
	s=(b.substring(b.length-4,b.length-5)==0)?'1':'0';
	id.src=(b.substring(b.length-5,0)+s+b.substring(b.length,b.length-4));
}

function hl2(id,s){
	b=id.src;
	id.src=(b.substring(b.length-5,0)+s+b.substring(b.length,b.length-4));
}

function checkEnter(event) {
	code=(document.layers)?event.which:code=event.keyCode
	if (code==13) document.frmZoekmachine.submit();
}	

var autoplay=false;
var stopped=true;
var origB=2000;
var origH=3000;
var breedte=0;
var hoogte=0;
var tBreedte=0;
var tHoogte=0;
function init(template) {
	if (window.innerWidth) {
		// FireFox en Safari
		tBreedte=parseInt(window.innerWidth);
		tHoogte=parseInt(window.innerHeight)
	} else if (document.all) {
		// Internet Explorer
		tBreedte=parseInt(document.body.clientWidth);
		tHoogte=parseInt(document.body.clientHeight)
	}
	if (tBreedte<breedte || tHoogte<hoogte) {
		// reload om scrollbalk te voorkomen
		history.go(0);
	} else {
		breedte=tBreedte;
		hoogte=tHoogte;
		if (template==1) {
			if (objRef('fotoindex') || objRef('foto1')) fotosize();
			if (autoplay) {countdown()} else { if (objRef('plinfo')) objRef('plinfo').src='/img/spacer.gif'}
			if (!objRef('tblFoto') && !objRef('fotoindex')) {styleRef('fotoplayer').display='none'}  // template foto.asp wordt gebruikt voor iets anders dan cmsexec/collectie.asp
		} else {
			// achtergrond foto
			nBreedte=objRef('rechts').offsetLeft-579;
			nHoogte=tHoogte;
			if (origB/origH<nBreedte/nHoogte) {nHoogte=parseInt(nBreedte*(origH/origB))} 
			else {nBreedte=parseInt(nHoogte*(origB/origH)) }
			if (objRef('fotocontainer')) {
				styleRef('achtergrond').height=nHoogte+'px';
				styleRef('achtergrond').width=nBreedte+'px';
				styleRef('fotocontainer').height=tHoogte+'px';
				styleRef('fotocontainer').width=(objRef('rechts').offsetLeft-579)+'px';
			}
		}
		styleRef('imgSchaduw').height=tHoogte+'px';
	}
	if (template==1) enableTooltips('fotoplayer')
}

var puntje=1;
function countdown() {
	objRef('plinfo').src='/img/countdown_'+puntje+'.gif';
	puntje+=1;
	if (puntje>10) {
		if (!stopped) {
			objRef('plinfo').src='/img/ani_loading.gif';
			fotoplayer('start');
		}
	} else {
		setTimeout('if (!stopped) {countdown()}', 900);
	}
}

var tips=new Array()
function enableTooltips(id){
	if(!document.getElementById || !document.getElementsByTagName) return;
	if(id==null) links=document.getElementsByTagName("a");              // heel document
	else links=document.getElementById(id).getElementsByTagName("a");   // één layer
	for(i=0;i<links.length;i++) {
		t=links[i].getAttribute('title');
		links[i].removeAttribute('title');
		links[i].setAttribute('nummer',i);
		if(t==null || t.length==0) t='';
		tips[i]=t;
		links[i].onmouseover=showTooltip;
		links[i].onmouseout=hideTooltip;
		links[i].onmousemove=locate;
	}
}

function showTooltip(e){
//	alert('fotoplayer');
	if(e==null) e=window.event;
	nr=this.getAttribute('nummer');
//	alert(tips[nr].length);
	if(nr!=null) {
		if (tips[nr].length!='') {
			objRef('tooltip').innerHTML=tips[nr];
			styleRef('tooltip').visibility='visible';
		}
	}
}

function hideTooltip(e){styleRef('tooltip').visibility='hidden'}

function locate(e){
	var posx=0,posy=0;
	if(e==null) e=window.event;
	if(e.pageX || e.pageY){
	    posx=e.pageX; posy=e.pageY;
	    }
	else if(e.clientX || e.clientY){
	    if(document.documentElement.scrollTop){
	        posx=e.clientX+document.documentElement.scrollLeft;
	        posy=e.clientY+document.documentElement.scrollTop;
	        }
	    else{
	        posx=e.clientX+document.body.scrollLeft;
	        posy=e.clientY+document.body.scrollTop;
	        }
	    }
	styleRef('tooltip').top=(posy+22)+"px";
	styleRef('tooltip').left=(posx-6)+"px";
}

// window.onload=function(){enableTooltips('fotoplayer')};
