function cleardiv(divid){
  document.getElementById(''+divid+'').innerHTML='';	
}
var selObj;
function selectObj(obj){
    if(selObj!=false && selObj!=undefined){
	  deselectObj(selObj);
    }
    selObj=obj;
	obj.style.background='#f8e0e0';
	obj.style.fontWeight='normal';
}
function deselectObj(obj){
    selObj=false;
	obj.style.background='#ffffff';
	//alert(obj.className.substr(3));
}

function objScrollX(objcontname,objname,xval){
	contobj=getObj(''+ objcontname +'');
	slideobj=getObj(''+objname +'');
	if(xval<0){
	  if(slideobj.targetX==undefined && slideobj.offsetLeft >= ( contobj.offsetWidth - slideobj.offsetWidth ) ){
		  
		  slideobj.targetX= slideobj.offsetLeft + xval;
	  }	
	}
	else{
		
	  if(slideobj.targetX==undefined && slideobj.offsetLeft < 0 ){
		  slideobj.targetX= slideobj.offsetLeft + xval;
	  }	
		
	}

	
}

function objScrollY(objcontname,objname,yval){
	contobj=getObj(''+ objcontname +'');
	slideobj=getObj(''+objname +'');
	if(yval<0){
	  if(slideobj.targetY==undefined && slideobj.offsetTop > ( contobj.offsetHeight - slideobj.offsetHeight ) ){
		  slideobj.targetY= slideobj.offsetTop + yval;
		  
	  }	
	}
	else{
	  if(slideobj.targetY==undefined && slideobj.offsetTop < 0 ){
		  slideobj.targetY= slideobj.offsetTop + yval;
	  }	
		
	}
	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findY(id){
  return findPosY(document.getElementById(''+ id +''))	;
}

function findX(id){
  return findPosX(document.getElementById(''+ id +''))	;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}



function hidediv(id) {
   obj = document.getElementsByTagName("div");
   obj[id].style.display = 'none';
}

function showdiv(id) {
    obj = document.getElementsByTagName("div");
    obj[id].style.display = 'block';
}

function showhide(id){
  obj = document.getElementsByTagName("div");
  if(obj[id].style.display=='block'){
    hidediv(id);
  }
  else{
    showdiv(id);
  }
}

function menuover(num){
	
  if(document.actmenu){
    hidediv('menusub'+document.actmenu);
  }
  showdiv('menusub'+num);
  document.actmenu=num;
}
  
function menuout(){
  if(document.actmenu){
	 hidediv('menusub'+document.actmenu);
	 //document.getElementById('menusub'+ document.actmenu).targetA=0;
  }
}

function subover(num){
	
  if(document.actsub){
    hidediv('menusubsub'+document.actsub);
  }
  
  document.actsub=num;
  showdiv('menusubsub'+num);
}
  
function subout(){
	hidediv('menusubsub'+document.actsub);
}


function flashSetVar(moviename,varname,varval){
	if(eval('window.' + moviename)){ 
	  window.document[''+moviename+''].SetVariable(''+varname+'', ''+varval+'');
	}
	if(eval('document.' + moviename)){
	 eval('document.' + moviename).SetVariable(''+varname+'', ''+varval+'');
	}

}

  function setAlpha(obj,alpha){
    if(document.getElementById(obj).filters){
	  document.getElementById(obj).filters.alpha.opacity= alpha

	}
    if(document.getElementById(obj).style.MozOpacity){
	  document.getElementById(obj).style.MozOpacity= (alpha/100);
	}
	//return true;
  }
  
  function getAlpha(obj){
    if(document.getElementById(obj).filters){
	  return document.getElementById(obj).filters.alpha.opacity;
	}
    if(document.getElementById(obj).style.MozOpacity){
	  return document.getElementById(obj).style.MozOpacity * 100;
	}
  }
  
  function setFade(){

    objs = document.getElementsByTagName("div");
	
	for(c=0;c<objs.length;c++){
	  
	  if(objs[c].className=='fader'){
	    
		if('hdr'+document.actmenu==objs[c].id){
		  if(getAlpha(objs[c].id)<100){
		    setAlpha(objs[c].id , (getAlpha(objs[c].id) +25));
		  }
		  
		}
		else{
		 if(getAlpha(objs[c].id)>0){
		   setAlpha(objs[c].id , (getAlpha(objs[c].id) -25));
		 }
		}

	  }
	  
	}
	
  }
  
  function nlsubcheck(theform){
    if(!validRequired(theform.inlname,"Naam"))
	  return false;
    if(!validEmail(theform.inlmail,"Email",1))
	  return false;
	  
	return true;
  }
  
function forum_over(robj){
	  robj.style.background= '#f3f3f3';
	  robj.style.color= '#A50000';
	  
}

function forum_out(robj){
	  robj.style.background= '';
	  robj.style.color= '#000000';
	  
}

function bg_over(robj,cval){
	  if(robj!=selObj){
	    robj.style.background= '#'+ cval + '';
	  }
	  
}

function setbgimg(tobj,imgfile){
	document.getElementById(''+ tobj +'').style.background='url('+ imgfile +')';
}

function scrollUp(cdiv,wdiv,sval){

   document.scrollInt= setInterval('doScroll(\''+ cdiv +'\',\''+wdiv +'\',-10)',40);
}

function scrollDown(cdiv,wdiv,sval){
   document.scrollInt= setInterval('doScroll(\''+ cdiv +'\',\''+wdiv +'\',10)',40);
}

function scrollStop(){
	 clearInterval(document.scrollInt);
}


function doScroll(scrollDiv,windowDiv,scrollVal){
  //alert(scrollDiv);
  if(scrollVal < 0){
	  if(getObj(scrollDiv).offsetTop > (getObj(windowDiv).offsetHeight - getObj(scrollDiv).offsetHeight) ){
		  //alert('scrolup');
		  getObj(scrollDiv).style.top = getObj(scrollDiv).offsetTop + scrollVal + 'px';
	  }
  }
  else{
	  if(getObj(scrollDiv).offsetTop < 0){
		  getObj(scrollDiv).style.top = getObj(scrollDiv).offsetTop + scrollVal + 'px';
	  }
  }
  

}

function getObj(objid){
  return document.getElementById(''+ objid +'');
}


function showonlygroup(group,num){
  obj = document.getElementsByTagName("div");
  for(c=0;c<obj.length;c++){
    if(obj[c]['id'].substring(0,group.length)==''+group+''){
	  if(obj[c]['id']==''+group+''+num){
	    showdiv(obj[c]['id']);
	  }
	  else{
	    hidediv(obj[c]['id']);
	  }
	}
  }
  
}

function toggleval(objid,val1,val2){
  if(getObj(objid).value == val1){
	  getObj(objid).value = val2; 
  }	
  else{
	  getObj(objid).value  =val1;
  }
}

function togglecheckbox(objid,valobj){
	if(getObj(objid).check==1){
		getObj(objid).check=0;
		getObj(objid).src ="images/checkbox.gif"; 
	}
	else{
		getObj(objid).check=1;
		getObj(objid).src ="images/checkbox_checked.gif"; 
	}
	getObj(valobj).value=getObj(objid).check;
}


function checkorder(theForm){
    if (!validRequired(theForm.iname,"naam"))
	  return false;
    if (!validRequired(theForm.ilastname,"achternaam"))
	  return false;
    if (!validRequired(theForm.iaddress,"adres"))
	  return false;
    if (!validRequired(theForm.izipcode,"postcode"))
	  return false;
    if (!validRequired(theForm.icity,"plaats"))
	  return false;
    if (!validRequired(theForm.icountry,"land"))
	  return false;
    if (!validEmail(theForm.iemail,"email adres",1))
	  return false;

	
	return true;
}

function regformcheck(theForm){
    if (!validRequired(theForm.iregusername,"username"))
	  return false;
    if (!validRequired(theForm.iregpasswd,"password"))
	  return false;
    if (!validRequired(theForm.iregpasswdcheck,"password check"))
	  return false;
    if (theForm.iregpasswdcheck.value!= theForm.iregpasswd.value){
		alert('the passwords must be the same');
	 return false;
	 
	}
    if (!validRequired(theForm.iregemail,"email",1))
	  return false;
    if (!validRequired(theForm.iregemailcheck,"email check",1))
	  return false;
    if (theForm.iregemail.value!= theForm.iregemailcheck.value){
		alert('the emailadresses must be the same');
	 return false;
	 
	}
    if (!validRequired(theForm.iregname,"Naam"))
	  return false;
	 
	
	return true;
}


function regformcheck2(theForm,thediv){
	msg='';
    if (!validRequired(theForm.iregusername,"username"))
	  msg+='your username must be filled in<br>';
	  
    if (!validRequired(theForm.iregpasswd,"password"))
	  msg+='your password must be filled in<br>';
    if (!validRequired(theForm.iregpasswdcheck,"password check"))
    if (theForm.iregpasswdcheck.value!= theForm.iregpasswd.value){
	   msg+='the two passwords must be the same<br>';
	 
	}
    if (!validRequired(theForm.iregemail,"email",1))
	   msg+='your emailadress must be filled in<br>';

    if (!validRequired(theForm.iregemailcheck,"email check",1))

if (theForm.iregemail.value!= theForm.iregemailcheck.value){
	  msg+='the two emailadresses must be the same<br>';
	 
	}
    if (!validRequired(theForm.iregname,"Naam"))
	   msg+='your name must be filled in<br>';
	 
	 
	 if(msg!=''){
	   document.getElementById('' + thediv + '').innerHTML = msg;
	   document.getElementById('' + thediv + '').style.display='block';
	   return false;
	 }
	
	return true;
}

function openVideo(vidID){
  window.open('http://video.supercarchallenge.nl/dscplayer.php?vidID='+ vidID +'&q=hi&portal=1','dscvidplayer','width=740,height=590');	
}

function confirmSubmit(){
	var agree=confirm("Weet u zeker dat u dit item wilt verwijderen?");
	if (agree)
		return true;
	else
		return false;
}

var numb      = "0123456789";
var phone     = "- ()"+numb;
var price     = ",."+numb;
var capitals  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var undercast = "abcdefghijklmnopqrstuvwxyz";
var alphabet  = capitals+undercast;
var numbalphabet = alphabet+numb;

function restrictKeys(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
			w += x;
	}
	t.value = w;
}

function showimg(cobj,imgfile,imgw,imgh){
  showdiv('imgviewer');
  obj= getObj('imgviewer');
  obj.style.width= imgw +'px';
  obj.style.height= (imgh+20) +'px';
  getObj('imgviewercontent').src=''+ imgfile +'';
  getObj('imgviewercontent').width= imgw;
  getObj('imgviewercontent').height= imgh;
  
  getObj('imgviewercontrol').style.width= imgw + 'px';

  obj.style.top = findPosY(cobj) - (imgh) + 'px';
  
  obj.style.left = parseInt((screen.availWidth/2) - (imgw/2)) + 'px';
  return false;
}

var searchInterval;
function homeSearch(thediv){
 clearTimeout(searchInterval);
 strCmd="jspost(getObj('homesearchform'),'"+thediv+"')";
 searchInterval=setTimeout(strCmd,500);
}