function $_GET(q,s) {
    s = (s) ? s : window.location.search;
    var re = new RegExp('&amp;'+q+'=([^&amp;]*)','i');
    return (s=s.replace(/^\?/,'&amp;').match(re)) ?s=s[1] :s='';
}

function initZoekenClear(){
//document.forms['form_search'].elements['zoek_model'].options[1].selected=true;

}

function initZoeken(){
var merkIndex = document.form_search.zoek_merk.selectedIndex;
var merk = document.form_search.zoek_merk.options[merkIndex].value;
if(merk != "-selecteer merk-"){
zoekModel();
var zoek_model = $_GET('zoek_model');
}
}



function zoekModel(){
		var merkIndex = document.form_search.zoek_merk.selectedIndex;
		var merk = document.form_search.zoek_merk.options[merkIndex].value;

		var page = 'zoek_model.php?zoek_merk=' + merk;
		var usediv = 'zoek_d';

         // Set up request varible
         try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
         
		  
         xmlhttp.onreadystatechange = function(){
                 //Check page is completed and there were no problems.
                 if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                        //Write data returned to page
                        document.getElementById(usediv).innerHTML = xmlhttp.responseText;
						//document.getElementById(usediv).innerHTML = 'hoi';
						}
         }
		
         xmlhttp.open("GET", page);
         xmlhttp.send(null);
         //Stop any link loading normaly
		 
		 
		 
		 
		 //document.getElementById('beta2').innerHTML = repair_scroll;
		 //window.scrollBy(0,repair_scroll/2); 
         		 
         return false;
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfY,scrOfX ];
}


function pausecomp(millis) 
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); } 
while(curDate-date < millis);
}


function load(page,usediv,bg){

if ( window.lastPage != page){

	loader(page,usediv,bg);
	
	}
         return false;
}

function preloader(usediv,text,bg){ 
 document.getElementById(usediv).innerHTML = '<img src="pictures/44_trans.gif" width=\"420\" style="margin:0 0 0 0;"><div style="margin:0 0 -150px 0;"></div>';
}

function loader(page,usediv,bg){


if ( window.lastPage != page){
         // Set up request varible
         try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
         //Show page is loading
		 preloader(usediv,'laden',bg);
		 //pausecomp(500);
         //scroll to top
         //send data
		  
         xmlhttp.onreadystatechange = function(){
                 //Check page is completed and there were no problems.
                 if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                        //Write data returned to page
                        document.getElementById(usediv).innerHTML = xmlhttp.responseText;
						}
         }
		
         xmlhttp.open("GET", page);
         xmlhttp.send(null);
         //Stop any link loading normaly
		 }
		 window.lastPage = page;
		 
		 
		 //document.getElementById('beta2').innerHTML = repair_scroll;
		 //window.scrollBy(0,repair_scroll/2); 
         		 
         return false;
}

function loaderHTML(page,usediv,bg){


if ( window.lastPage != page){
         // Set up request varible
         try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
         //Show page is loading
		 //preloader(usediv,'laden',bg);
		 //pausecomp(500);
         //scroll to top
         //send data
		  
         xmlhttp.onreadystatechange = function(){
                 //Check page is completed and there were no problems.
                 if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                        //Write data returned to page
                        document.getElementById(usediv).innerHTML = xmlhttp.responseText;
						}
         }
		
         xmlhttp.open("GET", page);
         xmlhttp.send(null);
         //Stop any link loading normaly
		 }
		 window.lastPage = page;
		 
		 
		 //document.getElementById('beta2').innerHTML = repair_scroll;
		 //window.scrollBy(0,repair_scroll/2); 
         		 
         return false;
}
 
 function LoadPage(page,usediv,h,bg,animatie,rel) {
 stopper();
 //makeBig();
  		 document.getElementById(usediv).style.background = "";
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).innnerHTML = "";

		if ( window.lastPage != page){
 
		var pLoad = function() { preloader(usediv,'bezig',bg); };
		var funct = function() { load(page,usediv,bg); }; 		
		document.getElementById(usediv).innerHTML = '';
		//animatie check on or of
		if(animatie == 'on'){
		verplaats(usediv,h);
		}
		clearTimeout(window.preloadtime);
		clearTimeout(window.pageloadtime);
		window.preloadtime = setTimeout(pLoad ,1);
		window.pageloadtime =setTimeout(funct ,1700);		
		
		}        
		 
		if ( page=="antivries.php" || page=="home.php" || page=="route_small.php" || page=="route_small_tnt.php" || page=="gekochte_auto.php" || page=="betaling.php" || page=="auto_inruilen.php" || page=="pinbeperking.php" || page=="bankinfo.php" ){
		 
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).style.color = "#000";
		 
		 
		 }else if ( page=="list.exe.php" || page=="make_promo.php" ){
		 
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).style.color = "#000";
		 
		 
		 }		 else{
		 		//document.getElementById(usediv).style.border = "solid 2px #ddd";		 
		 		document.getElementById(usediv).style.borderTop = "none";				
		 		document.getElementById(usediv).style.color = "#fff";
				
				}
				
			if ( rel =="car1" || rel =="car2" || rel =="car3" || rel =="car4"){
			doSomethingWithClasses2('car_','0000FF','hand');		 	 
			doSomethingWithClasses2('promo_','FFFF00','hand');
			changeBg(rel,'car_',bg,'ffff00','text');
		 	 
			
		 }else if ( rel =="promo1" || rel =="promo2" || rel =="promo3" || rel =="promo4"){
			doSomethingWithClasses2('promo_','FFFF00','hand');
			doSomethingWithClasses2('car_','ffff00','hand');
		 	changeBg(rel,'promo_',bg,'FFFF00','text');
			

		 
		 }	else{
		 	doSomethingWithClasses2('car_','ffff00','hand');
		 	 doSomethingWithClasses2('promo_','ffff00','hand');
		 	 
		 
		 
		 }
		
		 		document.getElementById(usediv).style.background = '#' + bg;
				
				
		  return false;
		 
		}
		
		
function stopper() {

if(typeof(window.ctime) != 'undefined') clearTimeout(window.ctime);
if(typeof(window.preloadtime) != 'undefined') clearTimeout(window.preloadtime);
if(typeof(window.pageloadtime) != 'undefined') clearTimeout(window.pageloadtime);

}

  function LoadPage2(page,usediv,h,bg,animatie,rel) {
 //makeBig();
	
 
 
  		 document.getElementById(usediv).style.background = "";
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).innnerHTML = "";

		if ( window.lastPage != page){
 
		var pLoad = function() { preloader(usediv,'bezig',bg); };
		var funct = function() { load(page,usediv,bg); }; 		
		document.getElementById(usediv).innerHTML = '';
		//animatie check on or of
		if(animatie == 'on'){
		verplaats(usediv,h);
		}
		setTimeout(pLoad ,1);
		setTimeout(funct ,1700);		
		
		}        
		 
		if ( page=="antivries.php" || page=="home.php" || page=="route_small.php" || page=="route_small_tnt.php" || page=="gekochte_auto.php" || page=="betaling.php" || page=="auto_inruilen.php" || page=="pinbeperking.php" || page=="bankinfo.php" ){
		 
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).style.color = "#000";
		 
		 
		 }else if ( page=="list.exe.php" || page=="make_promo.php" ){
		 
		 document.getElementById(usediv).style.border = "none";
		 document.getElementById(usediv).style.color = "#000";
		 
		 
		 }		 else{
		 		//document.getElementById(usediv).style.border = "solid 2px #ddd";		 
		 		document.getElementById(usediv).style.borderTop = "none";				
		 		document.getElementById(usediv).style.color = "#fff";
				
				}
				
			if ( rel =="car1" || rel =="car2" || rel =="car3" || rel =="car4"){
			doSomethingWithClasses2('car_','0000FF','hand');		 	 
			doSomethingWithClasses2('promo_','FFFF00','hand');
			changeBg(rel,'car_',bg,'ffff00','text');
		 	 
			
		 }else if ( rel =="promo1" || rel =="promo2" || rel =="promo3" || rel =="promo4"){
			doSomethingWithClasses2('promo_','FFFF00','hand');
			doSomethingWithClasses2('car_','ffff00','hand');
		 	changeBg(rel,'promo_',bg,'FFFF00','text');
			

		 
		 }	else{
		 	doSomethingWithClasses2('car_','ffff00','hand');
		 	 doSomethingWithClasses2('promo_','ffff00','hand');
		 	 
		 
		 
		 }
		
		 		document.getElementById(usediv).style.background = '#' + bg;
				
				
		  return false;
		 
		}
		
		
var allPageTags = new Array();
function doSomethingWithClasses(theClass)
{
//close_window('occasion_window');
	var allPageTags = document.getElementsByTagName('div');
	for (var i=0;i<allPageTags.length;i++) 
	{
		if(allPageTags[i].className == theClass)
		{
			//allPageTags[i].style.visibility = 'visible';
			allPageTags[i].style.display = 'none';
			
		} 
	}
	
}

var allPageTags2 = new Array();
function doSomethingWithClasses2(theClass,bgc,cr)
{
//close_window('occasion_window');
	var allPageTags2 = document.getElementsByTagName('div');
	for (var i=0;i<allPageTags2.length;i++) 
	{
		if(allPageTags2[i].className == theClass)
		{
			//allPageTags[i].style.visibility = 'visible';
			allPageTags2[i].style.background = '#' + bgc;
			allPageTags2[i].style.cursor = cr;
			allPageTags2[i].style.color = '#000';

		} 
	}
	
}

function loadPicture(img,imgname){
document[imgname].src="http://autofarm.direkthandel.nl/pictures_occ/" + img;
}


function changePicture(img,imgname){
document[imgname].src="http://www.autofarm.nl/pictures/36_000000.gif";
setTimeout("loadPicture('" + img + "','" + imgname + "');",800);
}

function loadPicture2(img,imgname){
document[imgname].src = img;
}


function changePicture2(img,imgname){
document[imgname].src="http://www.autofarm.nl/pictures/44_trans.gif";
setTimeout("loadPicture2('" + img + "','" + imgname + "');",1100);
}



function moveDiv(div,newWidth,newHeight){
//document.getElementById(div).style.width = newWidth;
document.getElementById(div).style.height = newHeight;
}


function verplaats(divje,h){
	document.getElementById(divje).style.background = "";
	document.getElementById(divje).style.border = "none";
	document.getElementById(divje).innnerHTML = "";
	
	var divje;
	var width;
	var newHeight;
	var newWidth;
	var timer;
	
	for(i=0;i<h;i++)
	{
		//newWidth = i + "px";
		if( i<h){
		newHeight = i + "px";
		}
		timer = i;
		setTimeout("moveDiv('" + divje + "','" + newWidth + "','" + newHeight + "');",timer);
	} 

}

function findPos(obj) {
	var curleft = curtop = 0;
if (obj.offsetParent) {
do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return [curtop];
}
}

function changeBg(div,cl,bgc,bgcr,cr){
doSomethingWithClasses2(cl,bgcr,'hand');
document.getElementById(div).style.background = '#' + bgc;
document.getElementById(div).style.cursor = cr;
document.getElementById(div).style.color = '#fff';

}


  
 function LoadHistory() {
 
 var h1 = function() { LoadPage2('historie_text.php','advertentie_container','#000','',''); };
 var h2 = function() { LoadPage2('voorraad_autofarm.temp.php','image_container','#000','',''); };
 var h3 = function() { LoadPage2('historie_text.php','standaard_uitrusting_container','#000','',''); };
 var h4 = function() { LoadPage2('historie_text.php','container_info','#000'); };

 
 
		setTimeout(h1 ,500);
		setTimeout(h2 ,2000);		
		setTimeout(h3 ,3500);
		setTimeout(h4 ,5000);		
		
 
 
		 
		}