var smooth_timer;
var interval_Id;


function hidestatus(){
	window.status=' ';
	return true;
}



function changeScrollbarColor(){
	if (document.all){	
	    document.body.style.scrollbarBaseColor				= mainbgcolor;
	    document.body.style.scrollbar3dLightColor			= mainbgcolor;
		document.body.style.scrollbarArrowColor				= focuscolor;
		document.body.style.scrollbarDarkShadowColor		= mainbgcolor;
		document.body.style.scrollbarFaceColor				= mainbgcolor;
		document.body.style.scrollbarHighlightColor			= focuscolor;
		document.body.style.scrollbarShadowColor			= mainbgcolor;
		document.body.style.scrollbarTrackColor				= focuscolor;
  	}   
}

							

function upclock(){					
	var dte = new Date();	
	var day = GetDayName(dte.getDay());			
	var daymonth = dte.getDate();
	var month = dte.getMonth();			
	var year = dte.getFullYear();
	var hrs = dte.getHours();
	var min = dte.getMinutes();
	var sec = dte.getSeconds();
	var col = ":";
	var spc = " ";
	var com = "";
	if (hrs == 0) hrs=12;
	if (min<=9) min="0"+min;
	if (sec<=9) sec="0"+sec;
	if(document.getElementById('clock')){
	document.getElementById('clock').innerHTML = daymonth + '-' + month + ' | ' + '<font color="#BC2222">'+hrs+col+min+'</font>';										
	}
}




function scrollUp(sObj){		
	if(!document.getElementById('vmarquee_'+sObj).style.top){document.getElementById('vmarquee_'+sObj).style.top='0px'}
	if(document.getElementById('vmarquee_'+sObj).offsetTop<0)document.getElementById('vmarquee_'+sObj).style.top=(parseInt(document.getElementById('vmarquee_'+sObj).style.top)+3)+'px';	
}


function scrollDown(sObj){	
	if(!document.getElementById('vmarquee_'+sObj).style.top){document.getElementById('vmarquee_'+sObj).style.top='0px'}
	if(document.getElementById('vmarquee_'+sObj).offsetTop>(document.getElementById('marqueecontainer_'+sObj).offsetHeight-document.getElementById('vmarquee_'+sObj).offsetHeight))document.getElementById('vmarquee_'+sObj).style.top=(parseInt(document.getElementById('vmarquee_'+sObj).style.top)-3)+'px';
}




function setMenu(obj, status){
	if(status){		
		obj.src = 'images/'+obj.id+'_o.gif'
	}
	else{
		obj.src = 'images/'+obj.id+'.gif'
	}
	
	obj.style.cursor='pointer';	
}



function loadPage(id){

	location.href=retPageName(id)
	
}


function retPageName(id){
	
	switch(parseInt(id)){
		case 1:
			return 'index.php';		
		case 2:
			return 'bikes.php';
 		case 3:
			return 'contact.php';
		case 4:
			return 'route.php';
		default:
			return 'index';
	}
}





function setSearch(id, visible){
  var trObj = (document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']");
  if (trObj != null) {
    if (visible) {		
    	trObj.style.display='';
    	trObj.style.height='62px';		
		SetCookie('search', 1, 30);
    }
    else {
    	trObj.style.display='none';
		SetCookie('search', '', -1);
    }
  }
}

function showSearch(id) {
  var trObj = (document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']");
  var iStep = 2;
  if(!bIsMSIE){iStep = 5}
  if (trObj != null) {
    if (trObj.style.display=="none") {    
      trObj.style.display="";
      smoothHeight(id, 0, 60, iStep, 'o');
      SetCookie("search", 1, 30);
    }
    else {
      smoothHeight(id, 60, 0, iStep, id);
      SetCookie("search", "", -1);
    }
  }
}

function smoothHeight(id, curH, targetH, stepH, mode) {
	
	diff = targetH - curH;
	var iPause = 20;
	
	if (Math.abs(diff) > stepH) {
		
		newH = (diff > 0) ? curH + stepH : curH - stepH;
	
		document.getElementById(id).style.height = newH + "px";
	
		if (smooth_timer) window.clearTimeout(smooth_timer);

		smooth_timer = window.setTimeout( "smoothHeight('" + id + "'," + newH + "," + targetH + "," + stepH + ",'" + mode + "')", iPause);
	}
	else if (mode != "o"){document.getElementById(id).style.display="none"}else{document.getElementById(id).style.height='62px'} 
}

function setPic(obj, w, h){				
	document.getElementById("showpic").src = obj.src.replace('tn_', 's_');
	document.getElementById("pic_width").value = w;
	document.getElementById("pic_height").value = h;
}

function showPic_back(obj){
	document.getElementById("showpic").src = obj.src.replace('tn_', 's_');
}

function showOriginal(oPic){				
	var iPos = oPic.src.indexOf('s_')+2;				
	popUp('showpic.php?pic='+oPic.src.substring(iPos), document.getElementById('pic_width').value, document.getElementById('pic_height').value, false);
}

function retPic(obj){
	var s = obj.style.backgroundImage;
	s = s.replace('url(upload/s_', '');
	s = s.replace(')', '');		
	return s;
}



//------------------------------------------------------------------------------------


function addnewContact() {
	addElement();				
}

function addElement() {
	var key = 0;
	var hr_key = 0;
	var prefix='contact';
	var cp = document.getElementById('contactperson');				
	
	while ( document.getElementById('initialen_'+key) != null ){
		key++;
	} ;				

	key = '_' + key;

	while ( document.getElementById('initialen_'+hr_key) != null ){
		hr_key++;
	} ;				

	var h3 = document.createElement('h3');
	h3.id='h3_'+hr_key;
	cp.appendChild(h3);
	document.getElementById('h3_'+hr_key).innerHTML='Contactpersoon ' + hr_key;
	var hr = document.createElement('hr');
	cp.appendChild(hr);
	
	
	
	
	for(var i = 0; i < 17; i++) {
		
		var lbl = document.createElement('label');		
		var textbox = document.createElement('input');		
		
		textbox.type='text'; 		
		
		switch (i) {
			
			case 0:				
				lbl.innerHTML='Achternaam';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'naam'+key;
				textbox.id=prefix+'naam'+key;					
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');
				break;				
			case 1:				
				lbl.innerHTML='Tussenvoegsel';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'tussenvoegsel'+key;
				textbox.id=prefix+'tussenvoegsel'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxsmall');
				break;				
			case 2:				
				lbl.innerHTML='Roepnaam';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'roepnaam'+key;
				textbox.id=prefix+'roepnaam'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');
				break;				
			case 3:				
				lbl.innerHTML='Initialen';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'initialen'+key;
				textbox.id=prefix+'initialen'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxsmall');
				break;				
			case 4:				
				lbl.innerHTML='Straat';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'straat'+key;
				textbox.id=prefix+'straat'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');
				break;				
			case 5:
				lbl.innerHTML='Nummer';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'nummer'+key;
				textbox.id=prefix+'nummer'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxsmall');
				break;				
			case 6:								
				ospan = document.createElement("span");
				cp.appendChild(ospan);
				ospan.innerHTML = '&nbsp;&nbsp;'
				textbox.name=prefix+'toevoegsel'+key;
				textbox.id=prefix+'toevoegsel'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxverysmall');
				break;				
			case 7:
				lbl.innerHTML='Postcode';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'postcodenummers'+key;
				textbox.id=prefix+'postcodenummers'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxsmall');				
				break;
			case 8:
				ospan = document.createElement("span");
				cp.appendChild(ospan);
				ospan.innerHTML = '&nbsp;&nbsp;'			
				textbox.name=prefix+'postcodeletters'+key;
				textbox.id=prefix+'postcodeletters'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textboxverysmall');				
				break;
			case 9:
				lbl.innerHTML='Plaats';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'plaats'+key;
				textbox.id=prefix+'plaats'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');				
				break;									
			case 10:				
				lbl.innerHTML='Telefoon 1';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'telefoon1'+key;
				textbox.id=prefix+'telefoon1'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textbox');
				break;				
			case 11:				
				lbl.innerHTML='Telefoon 2';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'telefoon2'+key;
				textbox.id=prefix+'telefoon2'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textbox');				
				break;				
			case 12:				
				lbl.innerHTML='Fax';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'fax'+key;
				textbox.id=prefix+'fax'+key;
				textbox.setAttribute('maxlength', '15')
				textbox.setAttribute('class', 'textbox');				
				break;				
			case 13:				
				lbl.innerHTML='Email';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'email'+key;
				textbox.id=prefix+'email'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');				
				break;				
			case 14:				
				lbl.innerHTML='Website';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'website'+key;
				textbox.id=prefix+'website'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');				
				break;				
			case 15:				
				lbl.innerHTML='Afdeling';
				lbl.setAttribute('class', 'label');	
				textbox.name=prefix+'afdeling'+key;
				textbox.id=prefix+'Afdeling'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');				
				break;				
			case 16:				
				lbl.innerHTML='Functie';
				lbl.setAttribute('class', 'item');	
				textbox.name=prefix+'functie'+key;
				textbox.id=prefix+'functie'+key;
				textbox.setAttribute('maxlength', '150')
				textbox.setAttribute('class', 'textbox');				
				break;									

		}					
		cp.appendChild(lbl);
		cp.appendChild(textbox);
		if(i==1||i==3||i==6||i==8||i==9||i==11||i==12||i==14||i==16){
			var br1 = document.createElement('br');			
			cp.appendChild(br1);			
			var br2 = document.createElement('br');
			cp.appendChild(br2);				
		}
	}	
	
	var hidden=document.createElement('input');
	hidden.type='hidden';
	hidden.id='modify'+key;
	hidden.name='modify'+key;	
	cp.appendChild(hidden);
	document.getElementById('modify'+key).value=0;
		
	
}

function collapseFieldset(id, oHref) {	
	
	var sCollapsed = getCookie('collapsed');	
		
	var oFieldset = document.getElementById(id); 	
	
	if(sCollapsed.indexOf(id)>-1){		
		oFieldset.style.height='';
		oFieldset.style.overflow='none';
		sCollapsed=sCollapsed.replace(id, '');
		var bVisible='visible';
		oHref.innerHTML='Inklappen';
	}
	else {
		oFieldset.style.overflow='hidden';
		oFieldset.style.height='0px';
		sCollapsed=sCollapsed+id;		
		var bVisible='hidden';
		oHref.innerHTML='Uitklappen';
	}	
	
	for ( var i = 0; i < oFieldset.childNodes.length; i++ ) {
		if ( oFieldset.childNodes[i].tagName=='INPUT' || oFieldset.childNodes[i].tagName=='LABEL' ) {
			oFieldset.childNodes[i].style.visibility=bVisible			
		}
	}
	
	setCookie('collapsed', sCollapsed, 1);
	
	
}

