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");

		if (address.match("g8_climatescorecards_2009_flash_de")) {
			var so = new SWFObject("/images/flash/scorecard_4_german.swf", "replaceWithFlash", "837", "626", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
		}
		
		if (address.match("g8_climatescorecards_2009_flash_it")) {
			
			var so = new SWFObject("/images/flash/scorecard_5_italian_F.swf", "replaceWithFlash", "837", "626", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
		}
		
		if (address.match("g8_climatescorecards_2009_flash_fr")) {
			var so = new SWFObject("/images/flash/scorecard_4_french_F.swf", "replaceWithFlash", "837", "626", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
		}
		
		if (address.match("g8_climatescorecards_2009_flash_br")) {
			var so = new SWFObject("/images/flash/scorecard_5_portug.swf", "replaceWithFlash", "837", "626", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
		}
		
		else if (address.match("g8_climatescorecards_2009")&&!address.match("g8_climatescorecards_2009_flash_de")&&!address.match("g8_climatescorecards_2009_flash_fr")&&!address.match("g8_climatescorecards_2009_flash_it")) {
	
			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_enmb")) {
			var so = new SWFObject("/climate_tipping_points/en_US/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Download complete report as PDF");
		}	
		
		if (address.match("climate_tipping_points_frmb")) {
			var so = new SWFObject("/climate_tipping_points/fr_FR/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Download complete report as PDF");
		}	

		if (address.match("climate_tipping_points_ptmb")) {
			var so = new SWFObject("/climate_tipping_points/pt_PT/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Download complete report as PDF");
		}	
		
		if (address.match("climate_tipping_points_esmb")) {
			var so = new SWFObject("/climate_tipping_points/es_ES/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Download complete report as PDF");
		}		
		
		if (address.match("climate_tipping_points_demb")) {
			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)");
		}		
		
		
		if (address.match("climate_tipping_points_itmb")) {
			var so = new SWFObject("/climate_tipping_points/it_IT/WWF_Climate_Tipping_Points.swf", "replaceWithFlash", "910", "600", "null", "#ffffff");
			so.write("flashplacement");
			setTimeout("urlFlashLayer()", 500);
			
			$('#report').append("Gesamte Studie zum Download (PDF)");
		}			
		
		if (address.match("from=banner")) {
			urchinTracker('nopi_banner_scorecard');
		}
		if (address.match("from=banner")) {
			urchinTracker('nopi_banner_scorecard');
		}		
		
		$("#flashlayerOverlay, #closeLayer").click( function() {
			urchinTracker('/flashlayer/close');
			if($('#162x600_banner')){
				$('#162x600_banner').fadeIn('slow');
			}	
			hideFlashLayer();
			return false;
		});
	}
});

function openFlashLayer() {
	urchinTracker('/flashlayer/open-click');
	showFlashLayer();
}

function urlFlashLayer() {
	urchinTracker('/flashlayer/open');
	showFlashLayer();
}

function showFlashLayer() {
	$("#flashcontent").hide();
	$("#menubottom").hide();
	$("#flashlayer").fadeIn("fast");
	$("#flashlayerOverlay").show();
	$("#flashlayerOverlay").fadeTo("slow", "0.75");
}

function hideFlashLayer() {
	$("#flashcontent").show();
	$("#menubottom").show();
	$("#flashlayer").fadeOut("fast");
	$("#flashlayerOverlay").fadeOut("slow");
}
