var ENV = {
	
	vr : function(){
		
		/**
		 * Evens out the height of the vertical rule (div.vr) 
		 * to the height of the parent element (div.row).
		 */
		
		var cc = this,
			vr = $("#content").find("div.vr"),
			parentHeight = $(vr).parent("div.row").height();
		
		for (var i = vr.length - 1; i >= 0; i--){		
			$(vr[i]).height($(vr[i]).parent("div.row").height());
		}
		
	},
	
	common : function(){

	    $('a[rel*=external]').click(function(){
	        window.open(this.href);
	        return false;
	    });
	
		var flashVersion = swfobject.getFlashPlayerVersion();
		if (flashVersion['major'] > 9){
			$("html").addClass("flash");
		}
		
	},
	
	home : function(){
		
		$("#navigation").find("ul").children("li").hover(function(){
			$(this).children("a").addClass("active");
			$(this).find("ul").show();
		}, function(){
			$(this).children("a").removeClass("active");
			$(this).find("ul").hide();
		})
		
		var cc = this,
			orButtonContainer = $("#intro"),
			orButton = orButtonContainer.find("a"),
			orPageContainer = $("#pages"),
			orPage = orPageContainer.find("li"),
			orBackButton = orPage.find("a.back-button"),
			speed = "slow";
			
		$(orPageContainer).hide();
		$(orPage).hide();

		$(orButton).click(function(){
			if (!$(this).hasClass("no")) {
				$(orPageContainer).show();
				$($(this).attr("href")).fadeIn(speed);
				return false;				
			}
		});
		
		$(orBackButton).click(function(){
			$(this).parents("li").fadeOut(speed, function(){
				$(orPageContainer).hide();
			});
		});
	
		if ($('html').hasClass("flash")){
			var flashvars = {};
			var params = { wmode: "transparent", base: "assets/swf/"};
			var attributes = {};
			swfobject.embedSWF("assets/swf/environment.swf", "content", "970", "500", "9.0.0", "assets/swf/expressInstall.swf", flashvars, params, attributes, "");
		}
	},
	
	videoPlayer : function(page, container){
		
		var file = "";
		
		if (page == "water"){
			file = "890x395_water.swf";
			mov = "water/Water.mov";
			jpg = "water/Water-poster.jpg";
		} else if (page == "waste"){
			file = "890x395_waste.swf";
			mov = "waste/Environment_Waste.mov";
			jpg = "waste/Environment_Waste-poster.jpg";
		} else {
			file = "890x395_energy.swf";
			mov = "energy/Energy.mov";
			jpg = "energy/Energy-poster.jpg";
		}
		
		if ($('html').hasClass("flash")){
			var flashvars = {};
			var params = {};
			var attributes = {};
			swfobject.embedSWF("../../assets/swf/videos/"+file, container, "890", "395", "9.0.0", "assets/swf/expressInstall.swf", flashvars, params, attributes, "");
		} else {
			var vidHtml = '<video src="../../assets/movies/'+mov+'" type="video/x-m4v" controls="controls" autoplay="autoplay" width="890" height="395" poster="../../assets/movies/'+jpg+'" >';
			$("#"+container).html(vidHtml);
		}
			
	},
	
	init : function(){
		
		var cc = this;
		
		cc.common();
		cc.vr();
		
	}
	
};
