var address = new String(window.location);

$().ready( function() {
	if ($("#flashlayerOverlay").length) {
		var last = $("#menubottom")
		var offset = last.offset();

		$("#flashlayerOverlay").css("opacity", "0.001");
		$("#flashlayerOverlay").css("height", $(document).height() + "px");
		$("#flashlayerOverlay, #flashlayer").css("width", $(document).width() + "px");
		
		var test=address.split("/");
		var cktest = document.cookie;
		
		if ((test[5] == "klimawandel" && test.length < 8) && !(cktest.match("introlayerceo2=true"))) {
			$("#flashcontent").html('<iframe src="http://stage.ceo2.allianz.esolut.com/de.html" frameborder="0" width="920" height="610" scrolling="no" name="ifl" id="ifl"></iframe>')
			setTimeout("urlFlashLayer()", 500);
			var ceo2gg = new Date();
			var ceo2end = ceo2gg.getTime() + (360 * 24 * 60 * 60 * 1000);
			ceo2gg.setTime(ceo2end);
			document.cookie = "introlayerceo2=true; expires=" + ceo2gg.toGMTString();
		}
		
		if (address.match("ceo2_allianz_wwf_klimaspiel_strategie.html")) {
			$("#flashcontent").html('<iframe src="http://live.ceo2.allianz.esolut.com/de.html" frameborder="0" width="920" height="610" scrolling="no" name="ifl" id="ifl"></iframe>');
			setTimeout("urlFlashLayer()", 500);
		}
		
		if ((address.match("kaltfront_klimaschlacht.html"))) {
			$("#flashcontent").html('<iframe src="http://stage.ceo2.allianz.esolut.com/de.html" frameborder="0" width="920" height="610" scrolling="no" name="ifl" id="ifl"></iframe>')
			setTimeout("urlFlashLayer()", 500);
		}
		
		if (address.match("g8_climatescorecards_2009")) {
			var so = new SWFObject("/images/flash/scorecard_3.swf", "replaceWithFlash", "837", "626", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
		}
		
		
		if (address.match("climate_tipping_points_de")) {
			var so = new SWFObject("/climate_tipping_points/de_DE/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Gesamte Studie zum Download (PDF)");
		}			

		$("#flashlayerOverlay, #closeLayer").click( function() {
			urchinTracker('/flashlayer/close');
			hideFlashLayer();
			return false;
		});
	}
});

function openFlashLayer() {
	urchinTracker('/flashlayer/open-click');
	showFlashLayer();
}

function urlFlashLayer() {
	urchinTracker('/flashlayer/open-redirect');
	showFlashLayer();
}

function showFlashLayer() {
	$("#flashcontent").hide();
	$("#flashlayer #flashcontent").show();
	$("#menubottom").hide();
	$("#flashlayer").fadeIn("fast");
	$("#flashlayerOverlay").show();
	$("#flashlayerOverlay").fadeTo("slow", "0.75");
}

function hideFlashLayer() {
	$("#flashcontent").show();
	$("#menubottom").show();
	$("#flashlayer").fadeOut("fast");
	$("#flashlayerOverlay").fadeOut("slow");
}
