// dit zijn eigenschappen voor het automatisch laten verdwijnen van menu items
var menuTimerOn = false;
var menuTimerCount = 250;
// maximale id grof hoog gezet, dient nog een keer andere opzet voor gemaakt te worden voor nu is dit afdoende
var cmax = 2000;

function clearDropdown() {
   for(var c=0; c<cmax; c++) {
      if(document.getElementById('menu_'+c+'_child') && document.getElementById('menu_'+c+'_parent')) {
         document.getElementById('menu_'+c+'_child').style.display = 'none';
         document.getElementById('menu_'+c+'_parent').className = '';
      }
   }
}

function placeDropdown(linkID) {
   var parent = document.getElementById('menu_'+linkID+'_parent');
   var child = document.getElementById('menu_'+linkID+'_child');
   
   if(child && parent) {
      child.style.left = (parent.offsetLeft-10)+'px';
      child.style.top = (parent.offsetTop-2)+'px';
      child.style.display = 'none';
   }
}

function showDropdown(linkID) {
   var parent = document.getElementById('menu_'+linkID+'_parent');
   var child = document.getElementById('menu_'+linkID+'_child');
   
   if(child && parent) {
   	
      clearDropdown();
      stopMenuTimer();
      placeDropdown(linkID);
      child.style.display = 'block';
      parent.className = 'active';       
   }
}

function hideDropdown(linkID) {
	
   var parent = document.getElementById('menu_'+linkID+'_parent');
   var child = document.getElementById('menu_'+linkID+'_child');
   
   if(child) {
      child.style.display = 'none';
      parent.className = '';
   }
}

function startMenuTimer(linkID) {
   if (menuTimerOn == false) {
      menuTimerID = setTimeout("hideDropdown(\'"+linkID+"\')" , menuTimerCount);
      menuTimerOn = true;
   }
}

function stopMenuTimer() {
	if (menuTimerOn) {
      clearTimeout(menuTimerID);
      menuTimerOn = false;
   }
}

function toggle(elName) {
   var el = document.getElementById(elName);
   if(el) {
      if(el.style.display == 'none') { el.style.display = ''; }
      else { el.style.display = 'none'; }
   }
}

function printDistr(sitePath,DistrID,Lang) {
   var URL = sitePath+'print.php?id='+DistrID+'&lang='+Lang;
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=480');");
}
function printIDistr(sitePath,DistrID,Lang) {
   var URL = sitePath+'print.php?inet=1&id='+DistrID+'&lang='+Lang;
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=480');");
}

function openShop() {
   var URL = 'http://www.hapro.com/dealershop/index_en.html';
   window.open(URL, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=840,height=485');
   return false;
}

function setTopLeftWidget(firefox){
	
	var varHeight = getDocHeight();
	
	if(firefox=='0'){
		if(document.getElementById("onder_tekst")){
			waarde 			= (varHeight - 600 ) + "px";
			document.getElementById("onder_tekst").style.top=waarde;
		}
		
		if(document.getElementById("onder")){
			waarde 			= (varHeight - 614 ) + "px";
			document.getElementById("onder").style.top=waarde;
		}
	} else {
			if(document.getElementById("onder_tekst")){
			waarde 			= (varHeight - 600 ) + "px";
			document.getElementById("onder_tekst").style.top=waarde;			
		}
		
		if(document.getElementById("onder")){
			waarde 			= (varHeight - 610 ) + "px";
			document.getElementById("onder").style.top=waarde;
		}	
	}
}


function addLatLng(gid, lat, lng) {
	ajaxObj.call("file=include/mybic_classes.inc.php&class=gmap&dealerID="+gid+"&lat="+lat+"&lng="+lng, ajaxGmap);
}

function addLatLngPC(postcode, land, lat, lng) {
	ajaxObj.call("file=include/mybic_classes.inc.php&class=gmapPC&postcode="+postcode+"&land="+land+"&lat="+lat+"&lng="+lng, ajaxGmapPC);
}

function ajaxStat(response){
	if (response) {
			//niets
	}
}

function ajaxGmap(response) {
	if (response) {
		//alert(response);
		//niets
	}
}

function ajaxGmapPC(response) {
	if (response) {
		//alert(response);
		// niets
	}
}	

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
/* google map functionaliteit */
	 