/*--------------------------------------------------------*/
/* referenties */
/*--------------------------------------------------------*/

	function time_move_referenties(){
		move_referenties(1);
	}

	function click_move_referenties(direction){
		window.clearInterval(ref_timer);
		move_referenties(direction);
	}

	function move_referenties(direction){	
		
		ref_current -= direction;				

		if (ref_current < (0-ref_total)){
			$("#referenties").css( { marginLeft:"0px" });
			ref_current = -1;
		}

		if (ref_current > 0){
			tmp = 0-(ref_width * ref_total);
			$("#referenties").css( { marginLeft: tmp+"px" });
			ref_current = (0-ref_total) + 1;
		}

		move_to = ref_current * ref_width;

		$("#referenties").animate( { marginLeft:move_to+"px" }, { queue:false, duration:1000 } );

	}

/*--------------------------------------------------------*/
/* slide show */
/*--------------------------------------------------------*/

	function alert_r(myObj){
		str = ""
		for ( var attr in myObj ) {
			str += attr + " = " + myObj[attr] + "\n";
		}
		alert(str);
	}

	function numChildren(node){
		if (typeof node != 'undefined') {
		  if (typeof node.children == 'undefined') {
			var num = 0;
			for(elem in node.childNodes){
				if(node.childNodes[elem].nodeType == 1){
					num ++;
				};
			}
			return num;
		  }else{					
			return node.children.length;
		  }
		} 
	}

	function initSlideShow(targets){

		slide_shows = new Array();

		for(i=0;i<targets.length;i++){
			
			var myShow = $("#"+targets[i].target_name)[0];	
			slide_show = targets[i];
			slide_show.current = 1;
			slide_show.real_id = myShow.className;
			slide_show.num_slides = numChildren(myShow);
			slide_show.targetObj = myShow;
			if (slide_show.num_slides != 1){			
				slide_show.timer = window.setTimeout('start_interVal('+i+')', targets[i].delay);
			}
			slide_shows.push(slide_show);	

		
			$("#slide_"+ myShow.className+"_"+0).show();
		}
		
		
		//slide_shows = new Array();
		slide_delay = 10;
		slide_speed = 1000;
		slide_time = 20000;
		slide_time_slow = 30000;
		
		$("#slides_middle").each(function(){
			
			slide_show = new Object();
			slide_show.target = this;
			slide_show.my_id = this.id;
			slide_show.current = 0;
			slide_show.num_slides = numChildren(this);
			if (slide_show.num_slides > 1){
				//slide_show.timer = window.setTimeout('start_ActiveInterVal('+i+')', slide_delay);			
			}else{
				//$("#"+this.id+"_nav").hide();
			}
			slide_shows.push(slide_show);
			i++;
		});
		
		ActiveslideShowNum(2,0);
	}

	function start_interVal(num){				
		SlideshowNext(num);		
		slide_shows[num].timer = window.setInterval('SlideshowNext('+num+')', slide_shows[num].time);
	}

	function SlideshowNext(show_num){
		
		showInfo = slide_shows[show_num];

		if (showInfo.current >= showInfo.num_slides){
			showInfo.current = 0;
		}	

		tar_id = showInfo.targetObj.id;

		rid = showInfo.real_id;
		
		$("#"+tar_id+" > div").css("z-index",1);				
		
		$("#slide_"+rid+"_"+(showInfo.current-1)).css("z-index",20);
		$("#slide_"+rid+"_"+showInfo.current).hide();
		$("#slide_"+rid+"_"+showInfo.current).css("z-index",40);
		$("#slide_"+rid+"_"+showInfo.current).fadeIn(1000);

		showInfo.current ++;
	}


/*--------------------------------------------------------*/
/* slide show welkom */
/*--------------------------------------------------------*/

	function start_ActiveInterVal(num){				

		ActiveSlideshowNext(num);
		slide_shows[num].timer = window.setInterval('ActiveSlideshowNext('+num+')', slide_time);
	}

	slideTimes = 0; 
	lastSlideFunction = "";
	function ActiveSlideshowNext(show_num){

		if (lastSlideFunction == "user"){
			//clearTimeout(slide_shows[show_num].timer);
			//slide_shows[show_num].timer = window.setInterval('ActiveSlideshowNext('+show_num+')', slide_time);
		}
		
		ActiveShowInfo = slide_shows[show_num];

		if (ActiveShowInfo.current >= ActiveShowInfo.num_slides){
			ActiveShowInfo.current = 0;
		}	

		tar_id = ActiveShowInfo.my_id;
				
		
		$("#"+tar_id+" > div").css("z-index",1);				
		$("#"+tar_id+" #slide_"+(ActiveShowInfo.current-1)).css("z-index",55);
		if (slideTimes != 0){
			$("#"+tar_id+" #slide_"+ActiveShowInfo.current).hide();
		}
		$("#"+tar_id+" #slide_"+ActiveShowInfo.current).css("z-index",105);
		$("#"+tar_id+" #slide_"+ActiveShowInfo.current).fadeIn(slide_speed);


		$(".image_num").css("background-color","#e2e7ea");
		$("#image_num_"+ActiveShowInfo.current).css("background-color","#0070af");

		ActiveShowInfo.current ++;
		slideTimes ++;
		lastSlideFunction = "auto";
	}

	function ActiveslideShowNum(show_num,num){
		
		//clearTimeout(slide_shows[show_num].timer);
		//slide_shows[show_num].timer = window.setInterval('ActiveSlideshowNext('+show_num+')', slide_time_slow);
		
		ActiveShowInfo = slide_shows[show_num];

		lastCurrent = ActiveShowInfo.current-1;
		ActiveShowInfo.current = num;

		tar_id = ActiveShowInfo.target.id;
		

		$("#"+tar_id+" > div").css("z-index",1);		
		$("#"+tar_id+" #slide_"+lastCurrent).css("z-index",55);
		$("#"+tar_id+" #slide_"+ActiveShowInfo.current).hide();
		$("#"+tar_id+" #slide_"+ActiveShowInfo.current).css("z-index",105);
		$("#"+tar_id+" #slide_"+ActiveShowInfo.current).fadeIn(slide_speed);

		$(".image_num").css("background-color","#e2e7ea");
		$("#image_num_"+ActiveShowInfo.current).css("background-color","#0070af");

		ActiveShowInfo.current ++;
		lastSlideFunction = "user";

	}

/*--------------------------------------------------------*/
/* tooltip */
/*--------------------------------------------------------*/

	function st(title,str,myTarget){
		pos = getAbsolutePos(myTarget);
		elm = document.getElementById('tooltip');
		elm.style.display = "block";
		elm.innerHTML = "<span class='title'>"+title+"</span><br />"+str;
		elm.style.top = (pos.y + 15) + 'px';
		elm.style.left = (pos.x + 5) + 'px';
	}

	function ht(){
		elm = document.getElementById('tooltip');
		elm.style.display = "none";	
	}

	function getAbsolutePos(el) {
		var r = { x: el.offsetLeft, y: el.offsetTop };
		if (el.offsetParent) {
			var tmp = this.getAbsolutePos(el.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	}


/*--------------------------------------------------------*/
/* multi menu */
/*--------------------------------------------------------*/

	function activateMenu(nav) {
		
		/* currentStyle restricts the Javascript to IE only */
		if (document.all && document.getElementById(nav).currentStyle) {  
		   var navroot = document.getElementById(nav);
			
			/* Get all the list items within the menu */
			var lis=navroot.getElementsByTagName("LI");  
			for (i=0; i<lis.length; i++) {
			
			   /* If the LI has another menu level */
				if(lis[i].lastChild.tagName=="UL"){
						
					
					/* assign the function to the LI */
					lis[i].onmouseover=function() {	
					
					   /* display the inner menu */
					   this.lastChild.style.display="block";
					}				
					lis[i].onmouseout=function() {                       
					   this.lastChild.style.display="none";
					}
				}
			}
		}
	}

/*--------------------------------------------------------*/
/* multi menu */
/*--------------------------------------------------------*/

	function changePassword(){

		$("#fake_user_pass").hide();
		$("#user_pass").show();
		$("#user_pass").focus();
		
	}