$(document).ready(function(){
	Cufon.replace('#menu li a', { fontFamily: 'aller' });
	Cufon.replace('#aankeiler h1', { fontFamily: 'aller' });
	Cufon.replace('#aankeiler h2', { fontFamily: 'aller' });
	Cufon.replace('.aller', { fontFamily: 'aller' });

	if ( $("#home").length ){
		var flashvars = {xmlPath:'../data/data.xml.php'};
		var params = {
			menu: "false",
			quality: "best",
			scale: "scale",
			salign: "tl",
			wmode: "transparent",
			base: "/swf",
			bgcolor: "#FFFFFF",
			allowscriptaccess: "always"
		};
		var attributes = {id:"flashcontent", name:"flashcontent"};
		var uid = Math.random();
		swfobject.embedSWF("/swf/Main.swf?uid="+uid, "flashcontent", "100%", "100%", "10", false, flashvars, params, attributes);
	}
	
	if ( $("#tests").length ){
		var flashvars = {xmlPath:'../data/data.xml.php'};
		var params = {
			menu: "false",
			quality: "best",
			scale: "scale",
			salign: "tl",
			wmode: "transparent",
			base: "/swf",
			bgcolor: "#FFFFFF",
			allowscriptaccess: "always"
		};
		var attributes = {id:"flashcontent", name:"flashcontent"};
		var uid = Math.random();
		swfobject.embedSWF("/swf/Main.swf?uid="+uid, "flashcontent", "100%", "100%", "10", false, flashvars, params, attributes);
	}
	
	var ie6= $.browser.msie && $.browser.version.substr(0,1)<7;
	if ( ie6 ){
		if ( $("#caseDetails h1.aller").length ){
			var html = $("#caseDetails h1.aller").html();
			$("#caseDetails h1.aller").addClass("shownTitle");
			$("#caseDetails h1.aller").after('<h1 class="hiddenTitle">'+html+'</h1>');
		}
	}

	resizeClip();

	$(window).bind('resize', function() {
		resizeClip();
	});
	
	//Contact Form
	if ( $("#contact").length ) {
		if ( $("#contactForm_mailing:checked").length==0 ){
			$("#contactForm_address").parent().hide();
			$("#contactForm_zipcode").parent().hide();
			$("#contactForm_city").parent().hide();
			$("#contactForm_country").parent().hide();
		}
		
		$("#contactForm_mailing").click(function(){
			$("#contactForm_address").parent().toggle();
			$("#contactForm_zipcode").parent().toggle();
			$("#contactForm_city").parent().toggle();
			$("#contactForm_country").parent().toggle();
		});
	}

	if ( $("#moreprofiles").length ) {

		if ($("#moreProfilesForm_target").val()!="4") {
			$("#moreProfilesForm_targetother").parent().hide();
		}

		$("#moreProfilesForm_target").change(function() {

			if ($(this).val()=="4") {
				$("#moreProfilesForm_targetother").parent().fadeIn();
			} else {
				$("#moreProfilesForm_targetother").parent().hide();
			}
		});
	}

	$("a.btnMoreProfiles").click(function(){
		window.location.href = moreProfilesURL;
	});
	
	if ($("#caroussel").length) {
		$('.ad-gallery').adGallery({});
	}
	
	$(".ad-thumb-list li a").hover(function() {
		$(".ad-thumb-list li a .namecontainer, .ad-thumb-list li a .name").hide();
		$(this).children(".namecontainer").fadeIn();
		$(this).children(".name").fadeIn();
	}, function() {
		$(this).children(".namecontainer").hide();
		$(this).children(".name").hide();
	});
	
	$("#viewswitch a").click(function() {
		if ($(this).hasClass("list")) {
			$(this).text("Lijstweergave");
			$(this).addClass("photo");
			$(this).removeClass("list");
			$("#namelist").hide();
			$("#caroussel").fadeIn();
		} else if ($(this).hasClass("photo")) {
			$(this).text("Fotoweergave");
			$(this).addClass("list");
			$(this).removeClass("photo");
			$("#caroussel").hide();
			$("#namelist").fadeIn();
		}
		
	});
});

function resizeClip(){
	if ( $("#clip").length ){
		//resize clip
		var w = $(window).width();
		clipWidth = Math.round((w-968)/2)+218;
		if ( clipWidth<218 ) clipWidth=218;
		//If screen width < 982 we have a scrollbar anyway, so show the whole clip
		if ( clipWidth>254 || w<982 ) clipWidth=254;
		$("#clip").css("width", clipWidth);
	}
}

