
var player = null;
function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
	addListeners();
	
}

function addListeners() {
	if (player) { 
		player.addModelListener("TIME", "timeListener");
	} else {
		setTimeout("addListeners()",100);
	}
}
function timeListener(obj) {
	if(obj.position == (obj.duration-0.2)){
		player.sendEvent("PLAY",false);
	}
}


//
// Avoid jQuery other framework interference
jQuery.noConflict();

//
// Jocky's Initialization
var params     = {
					menu      : "false",
					flashvars : "URL_JE_DECOUVRE=./&URL_JE_PARIE=https://www.parier.pmu.fr/prgPortlets/html/static/ouvertureCompte/jou01.html&AUTHENTICATE_URL=https://www.parier.pmu.fr/c/portal/login&RETRIEVE_URL=https://www.parier.pmu.fr/web/guest/ouverturecompteprogress?p_p_id=progressOuvertureComptePortlet_WAR_prgPortlets%26p_p_action=0%26p_p_state=exclusive%26p_p_mode=view%26p_p_col_id=%26p_p_col_pos=0%26p_p_col_count=0%26_progressOuvertureComptePortlet_WAR_prgPortlets_struts_action=%2FprogressOuvertureComptePortlet%2Foublicodeconfauthclient",
					scale     : "exactFit",
					quality   : "high",
					wmode     : "transparent",
					allowscriptaccess:"always"
};

var attributes = {
					id        : "jocky"
};


function flashPlayer(file,width, height, name , div, params, flashvars, version ) {
	
		var attributes = {id:name,  name:name}
        swfobject.embedSWF(file, div, width, height, version, false, flashvars, params, attributes);
}




function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		player =  window[movieName]
	}
	else {
		player =  document[movieName]
	}
}

function jedecouvre_btn(){
//alert("clik je decouvre "+ thisMovie("jocky").skip_intro(5))
	player.onChange();
}


//
// Xhtml/Css/Javascript Interface
jQuery(document).ready(function(){


	flashPlayer("swf/main_ptvm_vincent_cs3_01.swf",957, 500, "jocky" , "jocky_container", params, {},"8" );
	thisMovie("jocky");
	//
	// Info Legales Button
	jQuery('#btn_infos_legales').click(function(e)
	{
		jQuery('#infos_legales').slideDown();
	});
	
	jQuery('.close').click(function(e){
		e.preventDefault();
		closer(jQuery(this).parent());
	});
	
	function closer(obj)
	{
		obj.slideUp();
	}
	//
	// Navigation Interface
	var navigation_state = true;
	
	jQuery('#btnJeDecouvre').click(function(){
		
	
		jedecouvre_btn();
		return false;
	});
	
	jQuery('#btnJeDecouvre').mouseover(function(){
		if(navigation_state)
		{
			jQuery(this).css({"z-index" : "2", "background-image" : "url(./images/btnJeDecouvreHover.png)"});
			jQuery('#btnJeParie').css({"z-index" : "1", "background-image" : "url(./images/btnJeParie.png)"});
		}
	});

	jQuery('#btnJeDecouvre').mouseout(function(){
		if(navigation_state)
		{
			jQuery(this).css({"z-index" : "1", "background-image" : "url(./images/btnJeDecouvre.png)"});
			jQuery(this).css({"z-index" : "2", "background-image" : "url(./images/btnJeDecouvreHover.png)"});
		}
	});
jQuery('#btnJeParie').click(function(){
		
		 ns_flashcounter("progress.clic.je_decouvre.je_parie");
			document.forms["parie"].submit(); 
		
		return false;
	});
	jQuery('#btnJeParie').mouseover(function(){
		if(navigation_state)
		{
			jQuery(this).css({"z-index" : "2", "background-image" : "url(./images/btnJeParieHover.png)"});
			jQuery('#btnJeDecouvre').css({"z-index" : "1", "background-image" : "url(./images/btnJeDecouvre.png)"});
		}
	});

	jQuery('#btnJeParie').mouseout(function(){
			jQuery(this).css({"z-index" : "1", "background-image" : "url(./images/btnJeParie.png)"});
			jQuery('#btnJeDecouvre').css({"z-index" : "2", "background-image" : "url(./images/btnJeDecouvreHover.png)"});
	});
});

