/* functie om hele blokken klikbaar te maken, en hover toevoegen */
$.fn.hoverClick = function()
{
	this.each(function()
	{
		if($("a:first", this).length)
		{
			$(this).hover(
				function() { $(this).addClass("hover").css("cursor", "pointer"); },
				function() { $(this).removeClass("hover").css("cursor", "pointer"); }
			);
			
			$(this).attr("title", $("a:first", this).attr("title"));
			
			$(this).click(function(){
				window.location = $("a:first", this).attr("href");
			});
		}
	});
	
	return this;
};


/* jumpbox */
$.fn.listJumpbox = function()	
{									
	this.each(function()	
	{ 
		var c = this;
		
		$(c).css("position", "relative");
		
		$("ul", c).css({
			position	: 'absolute',
			left		: 0,
			top			: $("span").outerHeight()
		}).hide();
		
		// wanneer er geen meer zichtbaar zijn de eerste tonen
		if($("li.actief", c).length)	{
			$("span.selected", c).text($("li.actief", c).text());
		}
		
		// jumpbox is dicht
		$(c).addClass("jumpbox_dicht");
		var dicht = true;
		
		// de eerste klikbaar maken om de lijst uit te klappen
		$("span.selected", c).click(function()
		{
			if(dicht)
			{
				$(c).removeClass("jumpbox_dicht").addClass("jumpbox_open").css("z-index", 1337);
				dicht = false;

				$("ul", c).css("opacity", 0).animate({ height: 'show', opacity: 1 }, 500);
			}
			else
			{
				$(c).removeClass("jumpbox_open").addClass("jumpbox_dicht");
				dicht = true;
																
				$("ul", c).animate({ height: 'hide', opacity: 0 }, 500, function() {
					$(c).css("z-index", 0)
				});
			}
		});
		
		// de eerste klikbaar maken om de lijst uit te klappen
		$("li:visible", c).click(function()
		{
			$("li", c).removeClass("actief");
			$(this).addClass("actief");
			
			$(c).removeClass("jumpbox_open").addClass("jumpbox_dicht");
			dicht = true;
															
			$("span.selected", c).text($(this).text());

			// lijstje
			$("ul", c).animate({ height: 'hide', opacity: 0 }, 500);
		});
		
		
		
	});

	return this;
};


function zetMenu()
{
	var vars = {
		actief			: $("#menu li.actief a").attr("class"),
		link_home		: $("#menu a.home").attr("href"),
		link_overons	: $("#menu a.overons").attr("href"),
		link_service	: $("#menu a.service").attr("href"),
		link_contact 	: $("#menu a.contact").attr("href")
	};
				
	$("#menu").css("backgroundImage", "none").empty().flash({
		width		: 388,
		height		: 40,
		src			: submap + "/fla/menu.swf",
		wmode		: 'transparent',
		menu		: false,
		flashvars	: vars
	});	
}

function zetHeader( onderdeel, toon_pijl )
{
	if(typeof(toon_pijl) == 'undefined')
		toon_pijl = true;
	
	var kop_tekst = ($("#header .header h1").text());
	var nieuwsbrief_href = $("#header a.nieuwsbrief").attr('href');
				
	$("#header .header").css("backgroundImage", "none").empty().flash({
		width		: 950,
		height		: 256,
		src			: submap + "/fla/header.swf",
		menu		: false,
		flashvars	: {
			toon_pijl		: toon_pijl,
			kop_tekst		: kop_tekst,
			nieuwsbrief		: nieuwsbrief_href,
			fotos_map		: datamap + '/',
			fotos_xml		: submap + '/header/fotos.xml?onderdeel='+ onderdeel,
			logos_map 		: datamap + '/',
			logos_xml		: submap + '/header/referenties.xml?onderdeel='+ onderdeel
		}
	});	
}

function zetHomeOnderdeel( onderdeel )
{
	var blok_url = $("#frontpage ."+ onderdeel +" a.main").attr("href");
	var link_url = $("#frontpage ."+ onderdeel +" a.link").attr("href");
				
	$("#frontpage ."+ onderdeel).css("backgroundImage", "none").empty().flash({
		width		: 277,
		height		: 206,
		src			: submap + "/fla/home_onderdeel.swf",
		wmode		: 'transparent',
		menu		: false,
		flashvars	: {
			onderdeel		: onderdeel,
			blok_url		: blok_url,
			link_url		: link_url,
			fotos_map		: datamap + '/',
			fotos_xml		: submap + '/frontpage/fotos.xml?onderdeel='+ onderdeel
		}
	});	
}

$(function() {
	$("#zijbalk a").hover(
		function()	{ $(this).parent("p").addClass("hover");	},
		function()	{ $(this).parent("p").removeClass("hover");	}
	);
});


var pngfix_selectors = '';//'.bg_container_header, .bg_container_main, ';
pngfix_selectors += 'ul#menu, '; // #main, ';
pngfix_selectors += '#frontpage .exposure, #frontpage .productie, #frontpage .exposuremeting, ';
pngfix_selectors += 'img, div.fotoalbum .vergroting, #aanbod_details .foto, ';
pngfix_selectors += '#zijbalk p a';
