$(document).ready(function(){
	Cufon.replace('#menu li a', { 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();
		});
	}
});

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);
	}
}
