// JavaScript Document

$(document).ready(function(){

//$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});

	// test answer
	$(".testAnswer").hover(
		function(){
			$(this).css("background-image", "url(/assets/imgs/content/checkbox_checked.gif)");
		},
		function(){
			$(this).css("background-image", "url(/assets/imgs/content/checkbox.gif)");
		}
	);

	// dropdown menu
	$("#mainMenu > li[class!=professionalsLink]").hover(
		function(){
			$(this).find("ul").show();
			$(this).find("> a:not(.active)").css("color", "#1e3e69");
		},
		function(){
			$(this).find("ul").hide();
			$(this).find("> a:not(.active)").css("color", "#4e6e9a");
		}
	);
	
	// search form
	$("#searchFormRight").submit(function() {
		if (true)
		{
			return true;
		}
	});

	// setup accordions
	setupAccordion(".accordion", ".collapsable", ".opened", false, 100);
	
	// replace with image
	textToImage(".morelink a:not([class])", "/assets/imgs/content/moreLinks/leesmeer.gif");
	textToImage(".morelink a.testimonial", "/assets/imgs/content/moreLinks/leeshetheleverhaal.gif");
	textToImage(".morelink a.gebitsproblemen", "/assets/imgs/content/moreLinks/allesovergebitsproblemen.gif");
	textToImage(".morelink a.gebitscontrole", "/assets/imgs/content/moreLinks/allesovergebitscontrole.gif");
	textToImage(".morelink a.daMoreInfo", "/assets/imgs/content/moreLinks/meerinfo_en_speciale_actie.gif");
	textToImage("a.onlineGebitscontrole", "/assets/imgs/content/moreLinks/doedeonlinegebitscontrole.gif");
	textToImage("a.bekijkTandenpoetsHond", "/assets/imgs/content/moreLinks/bekijkdetandenpoetsinstructiesvoorjehond.gif");
	textToImage("a.preventieveAlternatievenKat", "/assets/imgs/content/moreLinks/bekijkpreventievealternatievenvoorjekat.gif");
	textToImage(".onlineCheckDark", "/assets/imgs/content/doeonlinecheck_dark.gif");
	textToImage(".onlineCheckLight", "/assets/imgs/content/doeonlinecheck_light.gif");
	
});

function textToImage(elem, img)
{
	$(elem).html('<img src="' + img + '" alt="' + $(elem).html() + '" />');
}

function setupAccordion(containerElem, collapsableElem, openedElem, allowMultipleOpen, speed)
{
	$(containerElem + " " + collapsableElem).not(openedElem).children().not(":first-child").hide();	
	
	$(containerElem + " " + collapsableElem + " :first-child").click(function(){
		if (!allowMultipleOpen)
		{
			//$(containerElem + " " + collapsableElem).children().not(":first-child").hide(speed);
			$(this).parent().prevAll().children().not(":first-child").hide(speed);
			$(this).parent().nextAll().children().not(":first-child").hide();
			$(this).nextAll().show();
		} 
		else 
		{
			$(this).nextAll().toggle(speed);
		}
	});
}

function doSearch(po)
{
	location.href="/gebitsproblemen/zoek-een-dierenarts/" + po;
}

function doEnterSearch(evt, po)
{
	if (evt.keyCode == 13)
	{
		doSearch(po);
	}
}

