/* == FUNCTION: NAVIGATION LAYOUT == */

function navigationLayout()
{
	jQuery("div#navigation ul li:last").addClass("last");
}



/* == FUNCTION: DEFAULT SEARCH TEXT == */

function defaultSearchText()
{
	jQuery("form#SearchForm_SearchForm input#SearchForm_SearchForm_Search").focus(function() {
		if (jQuery(this).val() == jQuery(this)[0].defaultValue)
		{
			jQuery(this).val("");
		}
	});
	
	jQuery("form#SearchForm_SearchForm input#SearchForm_SearchForm_Search").blur(function() {
		if (jQuery(this).val() == "")
		{
			jQuery(this).val(jQuery(this)[0].defaultValue);
		}
	});
}



/* == FUNCTION: TOGGLE HELP TOPICS HOME == */

function toggleHelpTopicsHome()
{
	if (jQuery("div#help_topics_home div.help_topic").length > 1)
	{
		jQuery("div#help_topics_home div.help_topic h4").each(function() {
			jQuery(this).html("<a href=\"#\">" + jQuery(this).text() +"</a>");
		});
		
		jQuery("div#help_topics_home div.help_topic:gt(0) p").hide();
		
		jQuery("div#help_topics_home div.help_topic:eq(0)").addClass("active");
		
		jQuery("div#help_topics_home div.help_topic h4 a").click(function() {
			jQuery(this).parent().siblings("p").slideToggle("normal");
			
			jQuery(this).parent().parent().toggleClass("active").siblings("div.help_topic").removeClass("active").children("p:visible").slideUp("normal");
			
			return false;
		});
	}
}



/* == FUNCTION: GOOGLE MAPS == */

function googleMaps()
{
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new google.maps.LatLng(51.31913, 4.91936), 16);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var marker = new GMarker(new GLatLng(51.31913, 4.91936));
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml("<p><strong>Contineo</strong><br />Steenweg op Antwerpen 99/2<br />2300 Turnhout</p>");
		});
		map.addOverlay(marker);
	}
}



/* == EVENTS == */

jQuery(function() {
	defaultSearchText();
	navigationLayout();
	toggleHelpTopicsHome();
});

jQuery(window).load(function()
{
	if (jQuery("div#map").length > 0)
	{
		googleMaps();
	}
});

jQuery(window).unload(function()
{
	if (jQuery("div#map").length > 0)
	{
		GUnload();
	}
});
