var wFlash = '100%';
var hFlash = '100%';


function addthisAttributes(url, title)
{	
	var bt = $('addthis_button');
	if (bt)
	{
		bt.set('addthis:url', url);
		bt.set('addthis:title', title);		
	}	
}

function goToAddThis()
{
	var bt = $('addthis_button');
	if (bt)
	{
		bt.onclick();
	}
}

function setAndClickAddthisButton(sUrl, sTitle)
{
	
	addthis.button('#addthis_bt', {}, {url: sUrl, title: sTitle});
	$('addthis_bt').onclick();
	  setTimeout("addthisDecal()",1000);
	/*
	var looping = true;
	while(looping){
		if($('at16p') != null) {
			$('at16p').style.marginLeft = 180;
			looping = false
		}
		//else sleep(100);
	}
	*/
}

function addthisDecal(){
		if( $('at16p') != null) {
			$('at16p').style.marginLeft = 180;
		}
		else setTimeout("addthisDecal()",1000);
}


function affiche_video(urlVideo)
{
	
	if (! navigator.appName.indexOf('Netscape') == -1) 
	{
		document.getElementById("hide").setStyle('z-index',0);
		document.getElementById("video").setStyle('z-index',200);
	}
	ma_div = document.getElementById("video");
	video_visible(urlVideo);
	replaceDiv();
	ma_div.style.visibility = "visible";
	
}

function video_visible(urlVideo)
{	
	ma_div = document.getElementById("video");
	if (navigator.appName.indexOf('Netscape') == -1) {
	
	//navigateur = 'IE';
	ma_div.innerHTML = "<OBJECT id='Player' classid='clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='600' height='400' STANDBY=Chargement des composants...>"
	+" <PARAM name='AutoStart' value='true'>"
	+" <PARAM name='url' value='"+urlVideo+"'>"
	+" <PARAM name='Volume' value='100' />"
	+" <PARAM name='wmode' value='opaque' />"
	+" <PARAM name='StretchToFit' value='true' />"
	+" <PARAM name='TransparentAtStart ' value='true' />"
	+" <PARAM name='uiMode' value='full' /></OBJECT>";
	} else {		
	 ma_div.innerHTML = "<object id='MediaPlayer' width='580' height='400' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715' align='middle' standby='Chargement...' type='application/x-oleobject'>"
        +"<param name='SendPlayStateChangeEvents' VALUE='True'>"
        +"<param name='AutoStart' VALUE='True'>"
        +"<param name='FileName' VALUE='"+urlVideo+"'>"
        +"<param name='ShowControls' value='1' />"
        +"<param name='ShowDisplay' value='0' />"
        +"<param name='ShowGotoBar' value='0' />"
        +"<param name='ShowPositionControls' value='1' />"
        +"<param name='TransparentAtStart ' value='1' />"
        +"<param name='ShowAudioControls' value='1' />"
        +"<param name='Volume' value='0' />"
        +"<param name='ShowTracker' value='1' />"
        +"<param name='ShowStatusBar' value='0' />"
        +"<embed src='"+urlVideo+"' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' ShowControls='1' ShowDisplay='0' ShowPositionControls='0' ShowAudioControls='1' name='MediaPlayer' width='600' height='400' autostart='1' ></embed>"
		+"</object>";

	}

}


function video_invisible(){
	if (navigator.appName.indexOf('Netscape') == -1){
		StopPlayer ();
		mon_player = document.getElementById("Player");
		mon_player.style.visibility = "hidden";
	}
	
	ma_div = document.getElementById("video");	
	ma_div.style.visibility = "hidden";
	
	ma_div.innerHTML = "";
}


function replaceDiv() 
{

	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }


	ma_div = document.getElementById("video");
	ma_div.style.top = 144;
	
	globalWidth = window.getWidth();
	
	if(viewportwidth > 1015){
		ma_div.style.left = viewportwidth/2-463;
	}
	else {
		ma_div.style.left = 49;
	}
	
	
	if(viewportheight > 768){
		ma_div.style.top = viewportheight/2-240;
	}
	else {
		ma_div.style.top = 144;
	}
	
}

//Player
//=========================//
function FullPlayer (){
	if (navigator.appName.indexOf('Netscape') != -1)
		alert("Avec votre navigateur, vous devez double-cliquer sur la vidéo pour activer le mode 'PLEIN ÉCRAN'.");
    Player.fullscreen='3';
}
function StopPlayer (){
    Player.controls.stop();
}
function setVideoSuivante(){
	document.getElementById("web_tv").setVideoSuivante();
}
//=========================//





function fermer() {
	/*if(window.name!="")
		self.close();
	else
		window.location = "http://www.savoie-mont-blanc.com/webtv/";*/
	window.load();
}

function ouvrePopup(url){
	window.open(url, "Informations", "width=400,height=490,scrollbars=yes, resizable=no");
}

function recup_var(){
	var filename = "";
	var requete = window.location.search;
	
	if (requete) {
		requete=requete.substring(1);
		requete = unescape(requete);
		tabVideo = requete.split("=");
		return(tabVideo[1]);
	}
}
