RE = {};//Riders Edge namespace


YAHOO.util.Event.onDOMReady(function() {
	RE.util.pageLoad();
	
});

function playerReady(obj){
	var flashObj = document.getElementById(obj['id']);
	RE.util.vidPlayerReady(flashObj);
}

RE.util = {
	pageLoad: function(){
		RE.util.btnSearch();
		RE.util.initFlash();
		
	},
	
	//Listen for the hover over rows
	btnSearch: function(){
		var button = YAHOO.util.Dom.getElementsByClassName("RE_button");
		
		if(button.length > 0){
			var i;
			for(i=0;i<button.length;i++){
				button[i].onmouseover = function(){
					this.style.backgroundPosition = "0 -22px";
				};
				button[i].onmouseout = function(){
					this.style.backgroundPosition = "0 0";
				};
			}
		}
	},
	
	initFlash : function(){
		flashvars = {
			file : "/en_US/Media/video/learn_to_ride/new_rider_course.flv",
			image : "/en_US/Media/images/content/pictorial/learn_to_ride/newRiderCourseVid.jpg",
			frontcolor : "#ffffff",
			lightcolor : "#ffffff"
		};
		
		params = {
			wmode: "window",
			allowfullscreen: "true",
			allowScriptAccess: "always"
		};
		
		attributes = {
			id: "newRiderVideo",
			name: "newRiderVideo"
		};
		
		//swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn)
		swfobject.embedSWF('/en_US/Media/flash/Standard_Vid_Player/player.swf', 'newRiderVideo', '451', '277', '9.0.115.0', '',flashvars,params,attributes, RE.util.embedCallback);
		
	},
	
	embedCallback : function(response){
		if(response.success != true){
			var nonFlash = document.getElementById('nonFlashCopy');
			nonFlash.style.display = "block";
			RE.util.nonFlashStyling();
		}
	},
	
	videoHitBox : function(obj){
		if("PLAYING" == obj.newstate){
			document.getElementById("newRiderVideo").height = 284;
			RE.hbx.hbPageView("/Get+On+A+Bike/Learn+To+Ride/New+Rider/Video+Play");
		}
	},
	
	vidPlayerReady: function(element){
		if(element.id == 'newRiderVideo'){
			element.addModelListener("STATE","RE.util.videoHitBox");
			element.sendEvent("PLAY","false");
		}
	},
	
	nonFlashStyling: function(){
		var leftContentElement = document.getElementById('new_rider_course_content_left');
		var texts = leftContentElement.getElementsByTagName('p');
		
		for(var i=0; i< texts.length; i++){
			texts[i].style.marginTop = "5px";
		}
	}
	
}; // end RE.search_util namespace


RE.hbx = { 		
		
	hbPageView : function(category){	
		_hbPageView("RE", category);
	}
};




