//=================================================================================================
//	You can delete these three functions if not needed.
//-------------------------------------------------------------------------------------------------
function customBodyLoad( sender )
{
}
//=================================================================================================
function customBodyResize( sender, size )
{
}
//=================================================================================================
function customBodyScroll( sender )
{
}
//=================================================================================================
//=================================================================================================
//	GOOGLE MAPS
//=================================================================================================
function initGoogleMap(lat, lon)
{
	var
		url       = new Url(),
		divGoogle = document.getElementById("divGoogle");
	
	if ( divGoogle )
	{
		if ( GBrowserIsCompatible() )
		{
			map    = new GMap2( document.getElementById("divGoogle") );
			center = new GLatLng( lat, lon );
			
			map.setCenter( center, 16 );
			//map.setMapType(G_SATELLITE_MAP);
			map.addControl( new GLargeMapControl() );
			//map.addControl( new GSmallMapControl() );
			map.addControl( new GMapTypeControl() );
			map.addControl( new GOverviewMapControl() );

			//newIcon      = new GIcon( baseIcon, "http://www.optiesbijwelkom.nl/img/" + icons[icon] ), 
			//marker       = new GMarker( new GLatLng( lat, lng ), newIcon );
			var marker = new GMarker(new GLatLng(lat, lon));
			map.addOverlay(marker);
		}
		else
			alert("Helaas is uw browser niet geschikt voor deze kaart.");
	}
}
//=================================================================================================
var
	map, center, 
	markers = new Array();
//=================================================================================================
function setMarker(lat, lon)
{
	var marker = new GMarker(new GLatLng(lat, lon));
	map.addOverlay(marker);			
}
//=================================================================================================
function clearField(target, defaultValue)
{
	var from = document.getElementById(target);
	
	if (from.value == defaultValue)
	{
		from.value = "";
	}	
}
//=================================================================================================
function submitDirection(e, fromAdress, target, defaultValue )
{
	var key=e.keyCode;
	
	if (key==13)
	{
		getDirections(fromAdress, target, defaultValue);
	}
}
//=================================================================================================
function getDirections(fromAdress, target, defaultValue)
{
	var from = document.getElementById(target);
	if(from)
	{		
		if (from.value != defaultValue && from.value != '')
		{
			window.open("misc/getDirections.aspx?from=" + from.value + "&to=" + fromAdress);
		}
		else
		{
			alert("nog geen postcode ingevoerd")
		}
	}
}
//=================================================================================================
function plotDirections(to, from)
{
	var map;
	var directionsPanel;
	var directions;	
	  
	map = new GMap2(document.getElementById("divGoogleMap"));  
	map.addControl( new GSmallMapControl() );
	map.addControl( new GMapTypeControl() );
	directionsPanel = document.getElementById("divGoogleDirections");  
	map.setCenter(new GLatLng(53.04,5.65), 13);  
	directions = new GDirections(map, directionsPanel);  	
	directions.load("from: "+ from + " to: " + to,
                { "locale": "nl_NL" });	
}
//=================================================================================================
var menuTimer;
//=================================================================================================
function hideMenu( sender )
{
	//alert("hideMenu( " + valueString( document.getElementById( sender ) ) + " )");
	//toggleSubmenu( sender.id.substr(1), false );
	menuTimer = setTimeout("toggleSubmenu( " + sender.id.substr(1) + ", false );", 1000 );
}
//=================================================================================================
function showMenu( sender )
{
	toggleSubmenu( 1028, false );
	toggleSubmenu( 1029, false );
	toggleSubmenu( 1030, false );
	toggleSubmenu( 1031, false );
	
	clearTimeout(menuTimer);

	//alert("showMenu( " + valueString( eval("submenu_" + sender.id.substr(1)).style.display ) + " )");
	toggleSubmenu( sender.id.substr(1), true );
}
//=================================================================================================
function mouseoverSubCat( sender )
{
	//alert("mouseoverSubCat( " + valueString( sender ) + " )");
	//sender.style.display = "block";
	clearTimeout(menuTimer);
}
//=================================================================================================
function mouseoutSubCat( sender )
{
	//alert("mouseoutSubCat( " + valueString( sender ) + " )");
	//sender.style.display = "none";		// vuurt al bij het binnengaan van subitem. Is op te lossen met timeouts, maar lastig (Erwin). Opgelost me onderstaande event op subitem
	menuTimer = setTimeout('document.getElementById("' + sender.id + '").style.display = "none";' , 1000 );
}
//=================================================================================================
function toggleSubmenu( id, on )
{
	document.getElementById( "submenu_" + id ).style.display = on ? "block" : "none";
}
//=================================================================================================
function mouseoverSubitem( )
{
	clearTimeout(menuTimer);
}
//=================================================================================================
var branchesDropdownTimer;
var solutionsDropdownTimer;
//=================================================================================================
function toggleBranchesDropdown ()
{
	var div = document.getElementById( "divBranches" );
	//div.style.display = div.style.display == "none" ? "block" : "none";
	div.style.display = "block";
}
//=================================================================================================
function mouseoverBranchesDropdown()
{
	clearTimeout(branchesDropdownTimer);
}
//=================================================================================================
function mouseoutBranchesDropdown()
{
	branchesDropdownTimer = setTimeout('document.getElementById("divBranches").style.display = "none";' , 1000 );
}
//=================================================================================================
function toggleSolutionsDropdown ()
{
	var div = document.getElementById( "divOplossingen" );
	//div.style.display = div.style.display == "none" ? "block" : "none";
	div.style.display = "block";
}
//=================================================================================================
function mouseoverSolutionsDropdown()
{
	clearTimeout(solutionsDropdownTimer);
}
//=================================================================================================
function mouseoutSolutionsDropdown()
{
	solutionsDropdownTimer = setTimeout('document.getElementById("divOplossingen").style.display = "none";' , 1000 );
}
//=================================================================================================
function openFlipbook( itmID )
{
	var
		url = new Url("/misc/Flipbook.aspx").add("itmID", itmID ),
		win = window.open( url, "frmFlipbook", "menubar=0,location=0,toolbar=0,scrollbars=0,resizable=0,status=0,width=1000,height=600");
	
	if ( win )
		win.focus();
}