
	// Without this, the menu will be desactivated
	enableDropDownMenu=1;

	if((typeof addToStart) == 'function') addToStart(checkDropDownMenu);

	function checkDropDownMenu(){
		if(enableDropDownMenu==0){
			if (document.getElementById('headerTSR')) document.getElementById('headerTSR').className='disableDropDown';
			}
		}


//-bouffe l'évènement pour pas qu'il arrive au DIV conteneur-
function CBbl(netEvent) {
    if (document.all) {
        alert('cbbl pour ms');
        window.event.cancelBubble = true;
    } else {
        alert('cbbl pour netscape');
        netEvent.cancelBubble = true;
    }
}
function setSearch(){
	tmp = '<div class="paragraphTitle">Recherche en cours...&nbsp;&nbsp;<img src="/images/interactif/player/searching.gif"></div>';
	document.body.innerHTML=tmp;
	}
function setHomePage(){
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage('http://www.tsr.ch');
	}


// Va afficher le formulaire pour intervenir par webcam
function displayWebcamInput(storyTitle, width){
	//if width not define use default value 470
	if(!width) width=470;
	
	var target = document.getElementById('webcamInputContainer');
	if(!target)return false;

	var rightNow = new Date();
	var rnYear = rightNow.getYear();
	if(rnYear < 999)rnYear+=1900;
	var rnMonth = rightNow.getMonth();
	var rnDay = rightNow.getDay();
	urlClipPost = 'http://www4.tsr.ch/webcam-recorder/index.php%3Faction%3DsaveClip%26applicationPath=tsr-www%26storyTitle='+encodeURI(storyTitle);
	urlClip = '/flash/nouvoscope-recorder.swf?flashServerUrl=rtmp://fms.nouvo.ch&amp;applicationPath=tsr-www&amp;backgroundImageUrl=/images/elmts/white-800px.jpg&amp;storagePath=TEST-RECORDER-'+rnYear+'/'+rnMonth+'/'+rnDay+'&amp;postPath='+urlClipPost;

	//htmlCode ='app=tsr-www et urlClip = <a href="'+urlClipPost+'">asdf</a> et allowScriptAccess="always"\n';
	htmlCode ='<img src="/images/interactif/nouvoscope-webcam-header.jpg" alt="" width="'+width+'"/>\n';
	htmlCode+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="420" id="nouvoscope-recorder" align="middle">\n';
	htmlCode+='	<param name="allowScriptAccess" value="always" />\n';
	htmlCode+='	<param name="movie" value="'+urlClip+'" />\n';
	htmlCode+='	<param name="quality" value="high" />\n';
	htmlCode+='	<param name="bgcolor" value="#ffffff" />\n';
	htmlCode+='	<embed src="'+urlClip+'" quality="high" bgcolor="#ffffff" width="'+width+'" height="420" name="nouvoscope-recorder" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	htmlCode+='</object>\n';

	htmlCode+='<div style="font-size:11px;"><p>Vous devriez voir ci-dessus notre enregistreur vidéo. Cela nécessite que le Flash Player 8 (<a href="http://www.macromedia.com/go/getflashplayer">télécharger</a>) soit installé sur votre système.</p>';

	htmlCode+='<p>Notez que lorsque vous pressez le bouton «envoyer», c\'est le dernier enregistrement visionné qui est retenu.</p>';


	htmlCode+='<p>Pour toute question, <a href="http://infrarouge.tsr.ch/forum-166-aide-webcam.html">référez-vous à notre forum d\'aide</a>.</p></div>';

	target.innerHTML = htmlCode;
	target.style.display='block';
}
// Appel du live tsrinfo (Live feed)

    function launchLive(urlVideo) {
        
        // Default video URL for the live feed
        //urlVideo = urlVideo || ' http://akastreaming.tsr.ch/vp/chtsr/no_geo/live.asx?gjmf=live_2_1'
        urlVideo = urlVideo || 'http://akastreaming.tsr.ch/vp/chtsr/no_geo/chtsr_2_1_ss.asx';
        
        // Create new DOM iframe element
        var iframe = document.createElement('iframe');
        iframe.src = urlVideo;
        iframe.width = 1;
        iframe.height = 1;
        iframe.style.border = 'none';
        
        // Add it to the document body
        var dbody = document.getElementsByTagName('body')[0];
        dbody.appendChild(iframe);
    }



  /********************************/
 /***   Flash mess for MSIE7   ***/
/********************************/

function writeString(html){
	document.write(html);
}
function insertString(dest,html){
	if(dest){
		dest.innerHTML = html;
	}
}
	function rewriteFlash () {
		// Ioan Sameli, 27.11.2006 16:50: disabled
		return;
		if(navigator.appVersion.indexOf('MSIE')<0)return;
		theObjects = document.getElementsByTagName("object");
		for (var i = 0; i < theObjects.length; i++) {
			var doifj = theObjects[i].outerHTML;
			theObjects[i].outerHTML = theObjects[i].outerHTML;
		}

		theObjects = document.getElementsByTagName("embed");
		for (var i = 0; i < theObjects.length; i++) {
			var doifj = theObjects[i].outerHTML;
			theObjects[i].outerHTML = theObjects[i].outerHTML;
		}

	}
if ((typeof notRewriteFlash == 'undefined') && (typeof addToStart == 'function')) addToStart(rewriteFlash);


  /***********************************/
 /***   Random common functions   ***/
/***********************************/

	function getURLParam(strGet){
	// récupère le paramètre demandé dans l'url
	// on peut passer en deuxième paramètre une autre URL (si par exemple on est dans des frames)
	// Ioan Sameli, 2003
		var url, args=getURLParam.arguments;

		if(args.length != 1) url = args[1];
		else url = window.location.search;

		if (url!=''){
			url=url.substring(1,url.length);
			liste=url.split("&");
			for (i=0;i<=liste.length-1;i++){
				temp=liste[i].split('=');
				if(temp[0]==strGet)return(temp[1]);
			}
			return(null);
		}
		else return(null);
	}
	
	function mangerBiscuit(leQuel){
	// function: Get a value from cookie
		if(!document.cookie) return false;
		var biscuits   = document.cookie;
		if (biscuits != ""){
			liste = biscuits.split(";");
			for (i=0;i<=liste.length-1;i++){
				temp = liste[i].split("=");
				if(temp[0].replace(/\s/,'')==leQuel) return(temp[1]);
			}
			return null;
		}
		else return null;
	}

	function cuireBiscuit(leQuel, valeur, maxage){
	// function: Save a value from a cookie
	// maxage is the maximum age in day
		if(!maxage)maxage=90;
		var expire = 1000*60*60*24*maxage;
		var maintenant = new Date();
		var temps = new Date(maintenant.getTime() + expire);
		document.cookie = leQuel+"="+valeur+"; expires="+temps.toGMTString()+"; path=/;";
	}

	// Pour la box A la tv et autres
	function bandePassanteok(){
		if(mangerBiscuit('testBandWidth') >= 160) return true;
		else return false;
	}

	function addToStart(fnc){
	// Add a finction that will be executed at page loading
		if(!window.listStart) window.listStart = new Array();
		window.listStart.push(fnc)
	}

	window.onload = function(){
	// To execute several functions on page load
	// Solution from http://www.ibilab.net/webdev/articles/Javascript/evenements-multiples-chargement-page-7.htm
		var ls = window.listStart;
		if(ls){
			for(iIp=0; iIp<ls.length; iIp++){
				fnc = ls[iIp];
				try {
					if(typeof(fnc) == 'function')fnc();
					else eval(fnc);
				}
				catch(e){trace(e);}
			}
		}
	}
	
	// Load a javascript file by appending a <script> tag to the head.
	// Parameters:
	//    jsFile (string): the path to the javascript file
	//    charset (strinf, optional): If a charset has to be specified (UTF-8 or so)
	function loadScript(jsFile, charset){
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.type = 'text/javascript';
		if (charset) script.charset = charset;
		script.src = jsFile;
		head.appendChild(script);
	}
	
	// Load a CSS file
	function loadStyleSheet(cssFile){
		var head = document.getElementsByTagName('head')[0];
		var cssLink = document.createElement('link');
		cssLink.type = 'text/css';
		cssLink.rel = 'stylesheet';
		cssLink.href = cssFile;
		head.appendChild(cssLink);
	}	
	
  /********************************/
 /***   LOAD VIDEO FUNCTIONS   ***/
/********************************/


document.write('<script type="text/javascript" src="/scripts/scriptaculous/prototype.js"></script>');
document.write('<script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>');
document.write('<script type="text/javascript" src="/scripts/tsrkit.js?d=20080315"></script>');
document.write('<script type="text/javascript" src="/wysistat_video.js"></script>');
document.write('<script type="text/javascript" src="/scripts/video_inpage.js"></script>');

/*
loadScript('/scripts/scriptaculous/prototype.js');
loadScript('/scripts/scriptaculous/scriptaculous.js');
loadScript('/scripts/tsrkit.js');
loadScript('/wysistat_video.js');
loadScript('/scripts/video_inpage.js');
*/

  /**************************************/
 /***   Macromedia flash detection   ***/
/**************************************/

	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

	function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision){
	// Fonction qui retourne TRUE si la version demandée de flash à été trouvée (ou version plus récente)
	 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
		for (i=25;i>0;i--) {
			if (isIE && isWin && !isOpera)versionStr = JSGetSwfVerIE(i);
			else versionStr = JSGetSwfVer(i);

			if (versionStr == -1 ) {
				return false;
			} else if (versionStr != 0) {
				if(typeof versionStr=='int' || typeof versionStr=='number') versionMajor = versionStr;

				else{

					if(isIE && isWin && !isOpera) {
						tempArray         = versionStr.split(" ");
						tempString        = tempArray[1];
						versionArray      = tempString.split(",");
					}
					else versionArray      = versionStr.split(".");

					versionMajor      = versionArray[0];
				}

		        // Si revision majeure >= version majeure demandee ET que la version mineure >= version mineure demandée
				if (versionMajor >= reqMajorVer) {
					return true;
				} else {
					return false;
				}
			}
		}
	}
	function JSGetSwfVer(i){
	// Détection flash - navigateur non IE

		if (navigator.plugins != null && navigator.plugins.length > 0) {
			if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
				var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		      	var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
				descArray = flashDescription.split(" ");
				tempArrayMajor = descArray[2].split(".");
				versionMajor = tempArrayMajor[0];
				versionMinor = tempArrayMajor[1];
				if ( descArray[3] != "" ) {
					tempArrayMinor = descArray[3].split("r");
				} else {
					tempArrayMinor = descArray[4].split("r");
				}
				versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
				flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
	      		} else {
				flashVer = -1;
			}
		}
		else {
			// Flash n'as pas été trouvé
			flashVer = -1;
		}
		return flashVer;
	}
	function JSGetSwfVerIE(){
	// Détection flash - seulement MSIE
		for(var i=15; i>0; i--){
			try{
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				return i;
			}
			catch(e){
			}
		}
		return -1;
	}
	
  /**************************************/
 /***   DateTime functions           ***/
/**************************************/


//convert the system date to the GMT to avoid the inconvenients issued from
//all differents time zone, return GMT as a timestamp format : yyyyMMddHHmmss
function systemDateToGMT()
{
    var time = new Date();
    var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000);
    var gmtTime =  new Date(gmtMS);
      
    var day = gmtTime.getDate();
    var month = gmtTime.getMonth()+1;
    var hr = gmtTime.getHours();
    var min = gmtTime.getMinutes();
    var sec = gmtTime.getSeconds();
    
    if(month < 10) month = "0"+month;
    if(day < 10) day = "0"+day;
    if(hr < 10) hr = "0"+hr; 
    if(min < 10)min = "0"+min;
    if(sec < 10)sec = "0"+sec;
    
    var timestamp = gmtTime.getFullYear().toString()+month.toString()+day.toString()
                    +hr.toString()+min.toString()+sec.toString();
    
   
    //alert("timestamp:"+timestamp);
    return timestamp;
     
   
}

