 	$(document).ready(function() {
		createPlayer();
	})

 	var params = {allowfullscreen:"true",allowscriptaccess:"always",allowfullscreen:"true",allowscriptaccess:"always",showdownload:"false",usekeys:"true",backcolor:"000000",frontcolor:"FFFFFF",lightcolor:"FFDD15"}
	var attributes = {id:"pornplayer",name:"pornplayer"}
	var currentState = "NONE"; 
	var previousState = "NONE"; 
 
	var player = null;
	function playerReady(thePlayer) {
		player = document.getElementById(thePlayer.id);
		addListeners();
	}

	function addListeners() {
		if (player) { 
			player.addModelListener("STATE", "stateListener");
		} else {
			setTimeout("addListeners()",100);
		}
	}

	function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
		currentState = obj.newstate; 
		previousState = obj.oldstate; 
	 
		var tmp = document.getElementById("stat");
		if (tmp) { 
			tmp.innerHTML = "current state: " + currentState + 
			"<br>previous state: " + previousState; 
		}
		if ((currentState == "PAUSED")) {
			player.sendEvent('PLAY', true);
			window.open(link_url);
		}
	 
				if ((currentState == "COMPLETED")&&(previousState == "PLAYING")) {
					$("div.videobox_container").empty().append('<div id="bz_shareporn"></div>');
					if(jQuery.browser.msie) {
							var flashvars = {file:scene_trailer_share,image:postroll}
	 						swfobject.embedSWF("http://static.brazzers.com/player/hdtools_player.swf", "bz_shareporn", width, height, "9.0.115", false, flashvars, params, attributes);
					}
					else
						$("div.videobox_container").html('<object width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" id="pornplayer" name="pornplayer" data="http://static.brazzers.com/player/hdtools_player.swf"><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="showdownload" value="false"/><param name="usekeys" value="true"/><param name="backcolor" value="000000"/><param name="frontcolor" value="FFFFFF"/><param name="lightcolor" value="FFDD15"/><param name="flashvars" value="image='+postroll+'&&overstretch=fit&displayheight=400&file='+scene_trailer_share+'&backcolor=000000&frontcolor=FFFFFF&linkfromdisplay=true&link=&linktarget=_blank"/></object>');
					}
	}
	
	function createPlayer() {
		var flashvars = {file:scene_trailer_share,image:start_image}
	 	swfobject.embedSWF("http://static.brazzers.com/player/hdtools_player.swf", "bz_shareporn", width, height, "9.0.115", false, flashvars, params, attributes);
	}
