function toggle(id) {
	// standaard toggle script
	var my_ids = id.split(",");
	for (i=0;i<my_ids.length;i++){
	   	el = document.getElementById(my_ids[i]);
     	var display = '';
    	if  (!el.style.display) {
          	display = 'none';
    	}
     	el.style.display = display;
	}
}
function OpenWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
} 
function goSearch(f){ 
	
	if (f.city.value =='bijv. Amsterdam'){ 
		f.city.value ='';
		f.radius.value ='';
	}
	if (f.kAndEntire.value =='bijv. PHP Programmeur'){ 
		f.kAndEntire.value ='';
	}
	if ((f.city.value =='') || (f.city.value == null)){ 
		f.radius.value ='';
	}

	document.vaczoek.submit();
	}
	
function submitenter(myfield,e) {
	if (window.event.keyCode == 13)   {
		 if (vaczoek.kAndEntire.value =='bijv. PHP Programmeur'){ 
			vaczoek.kAndEntire.value ='';
		}
		if (vaczoek.city.value =='bijv. Amsterdam'){ 
			vaczoek.city.value ='';
		}
		if (vaczoek.city.value ==''){ 
			vaczoek.radius.value ='';
		}
	   myfield.form.submit();
	   return false;
	   }
	else {
	   return true;
	   }
}

// de volgende drie functies zijn voor het bladeren door de divs
// deze functies maken ook gebruik van de standaard toggle functie
// de div id's moeten eindigen met _nummer: dus bv id="tl_bl_0"

function getVisibleDiv(d,c){
	// bekijk welke van de set zichtbaar is en return het nummertje
	var activeID;
	for (i=0;i<=c;i++){
		var thisDiv = d+"_"+i;
		if (document.getElementById(thisDiv)) {
			var el = document.getElementById(thisDiv);
			if  ( (!el.style.display) || (el.style.display =="inline") ) {
				activeID = i;
	    	}
		}
	}
	return activeID;
}
function getDivCount(d){
	// tel het aantal divs met een bepaalde id
	var dcount = -1; // omdat de div's beginnen bij 0 en dcount het aantal gevonden divs is.... 
	var divArray = document.getElementsByTagName('div');
	for (var i = 0; i < divArray.length; i++) {
	   var e = divArray[i].getAttribute('id')+"";
	   	e = e.replace(/\d/g, '');
		if (e.length > 1) {
			if (e.lastIndexOf("_") == (e.length-1)){
				e = e.substring(0,e.length-1);
			}
	  		if (e == d ){
				dcount++;
			}
		}
	}
	return dcount ; 
}
function paginator(d,p){
	if (d == 'portlet_shorty_topright') {
		clearInterval(intervalID);
	}
	if (!d){
		d='portlet_shorty_topright';
	}
	if (!p) {
		p = 1;
	}
	
	// blader door de divs....
	var maxD = getDivCount(d);
	var activeID = getVisibleDiv(d,maxD);
	var nextID = activeID + p;
	var activeDiv = d +"_"+activeID;
	var nextDiv =  d +"_"+(nextID); 
	// aan het begin of eind? gewoon doorgaan....
	if ((activeID == maxD) && (p == 1) ){
		var nextDiv =  d +"_"+0;
	}
	if ((activeID == 0) && (p == -1) ){
		var nextDiv =  d +"_"+maxD;
	}
	// zet de zichtbare div uit en de andere aan
	
		var dcurrent = document.getElementById(activeDiv);
		var dnext = document.getElementById(nextDiv);
		
		dcurrent.style.display = "none";
		dnext.style.display = "inline";
		
	
}
//eind blader divs...
function init() {
	currentPortlet = 0;
	intervalID = setInterval("paginator('tj_page',0)", 7000);
}
