var dcookie = document.cookie ;
var cookie_str = dcookie.toString();

var site_index = /^http\:\/\/www\.lesoir\.be\/?$|.*?la_une.*?|.*?index\.shtml/ ;


var site_url = window.location.toString() ;

var is_index = site_url.match(site_index) ;

if(!dcookie) {
	createCookie('init','1',1,true);	
}

if (is_index) 
{	
	var splash_active = /splash_active=([0-9])/i ;
	var matches_splash = cookie_str.match(splash_active) ;

	if(!matches_splash) {
		
		if(dcookie) {
			createCookie('splash_active','1',1,true);
			document.location.href = '/splash.html' ;
		}
	} 
}

function getElement(id) {
	return document.getElementById(id) ; 
}
function createCookie(name,value,days,timespan)
{
	defaultTime = days*24*60*60*1000 ;
	if (timespan)
	{
		defaultTime = 3*60*60*1000 ; 
	}
	if (days)
	{	var date = new Date();
		date.setTime(date.getTime()+(defaultTime));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
/* display prefs */
var toggle = null ; 
function toggle_display(toggle) {
	var getuserpref = /fulldisplay=([d|f])/i ;
	var matches_up = null ; 

	if(toggle) {	
		var action = toggle ; 
	} 
	
	if(matches_up = cookie_str.match(getuserpref)) {
		var wrap = getElement('wrap');
		if(toggle) {
			document.cookie = document.cookie.replace(getuserpref,'fulldisplay='+toggle)
			up = toggle ;  
		} else {
			up = matches_up[1];
		} ;
		
		if( up == 'f' ) {
		//	wrap.style.width= '100%';
			wrap.className = 'wrap_full'
		} else {
			wrap.className = 'wrap_fixed'
		//	wrap.style.width= '980px';				
		} ;
		
	} else {
		createCookie('fulldisplay','d','365')		
		//document.cookie+='fulldisplay='+action;
	}
}
function IsPopupBlocker() {
var strNewURL = "Dummy.htm"
var Strfeature = "" ;
var WindowOpen = window.open
(strNewURL,"MainWindow",Strfeature);
try{
var obj = WindowOpen.name;
WindowOpen.close();
}
catch(e){
alert("Nous avons détecté que vous avez bloqué l'ouverture des pop-up (fenêtres additionelles). Or certains services comme les 'Direct Live' sportifs du Soir en ligne utilisent ce type d'ouverture de fenêtre. Il est donc possible que vous ne puissiez pas bénéficier de ces services. Pour débloquer ces fenêtres, vous devez placer http://www.lesoir.be dans vos sites autorisés.\n\n Sous Microsoft Internet Explorer : ouvrez Outils / Options Internet / Confidentialité / Popup Blocker. \nSous FireFox: ouvrez Outils / Options / Fonctionalités Web et ajoutez http://www.lesoir.be dans vos sites autorisés.\n\nOu contactez votre administrateur système.\n\nMerci. ");
}
}

function doprint(url) {
	window.open("/statiques/print/print.php?url="+url,"imprimer");
}
function ftvlaunch(video,quality,pid) {
	  var LeftPosition = (screen.width) ? (screen.width-665)/2 : 0;
	  var TopPosition = (screen.height) ? (screen.height-430)/2 : 0;
	  var popwin = window.open('http://www.zoomin.tv/videoplayer/index.cfm?id='+video+'&mode=normal&quality='+ quality +'&pid='+ pid,'MTV6_window','toolbar=no,width=665,height=430,top='+TopPosition+',left='+LeftPosition+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
      popwin.focus();
}
function tools_windowOpen(page, id) {

	//return false ; 
	switch(page) {
		case 'fil' : 
			window_url = '/actualite/le_fil_info/index_popup.shtml';
			window_name = 'filinfo';
			props = 'width=500, height=450, scrollbars=no, toolbar=no, resizable=yes' ;
   		    break ; 
		case 'fil_sp' : 
			window_url = 'http://www.lesoir.be/filinfo/fi_sp.php?mode=1&id='+id ;
			window_name = 'filinfo';
			props = 'width=500, height=450, scrollbars=no, toolbar=no, resizable=yes' ;
   		    break ; 
			case 'DL_FOOT' : 
			IsPopupBlocker();
			window_url = 'http://www.lesoir.be/bell1/flash/fr/' ;
			window_name = 'DLFOOT';
			props = 'height=530,width=790, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no' ;
   		    break ; 
		case 'DL_F1' : 
			IsPopupBlocker();
			window_url = 'http://www.lesoir.be/f1/flash/fr/' ;
			window_name = 'DLF1';
			props = 'height=620,width=825, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no' ;
   		    break ; 
	}
	window.open(window_url, window_name, props);
}


function meteo_form() {
	form_item = "document.getElementById('meteo_region')";
	if(eval(form_item))	{
		fitem = eval(form_item);
		index = fitem.selectedIndex ; 
		var str = dcookie.toString();
		var meteo_reg = /sel_meteo=([0-9])/i ;
		var meteo_active = str.match(meteo_reg) ;
		createCookie('sel_meteo',index,'365')
		window.location.reload();
	}
}
	var off_state = /off/ ;
	var active_state  = /active/ ;
	
	function c_tab_obj() {
		this.tab = null ;
		this.div = null ; 
		this.index = 0 ;
	}
	function display_div() {
		var i = 0 ; 
		while(i<tabs.length) {
			tabs[i].tab.className= tabs[i].tab.className.replace(active_state, "off")			
			tabs[i].div.className = "off" ;
			i++  ;
		}
		this.parent.div.className = "active";
		this.className= this.className.replace(off_state, "active") ;
	}
	tabs = new Array()	
	function init_divs() {
		var i = 0;
		for(i ; i<=2; i++) {
			div = eval(document.getElementById('graph_'+i)) ;
			tab = eval(document.getElementById('graph_h'+i)) ;
			
			tabs[i] = new c_tab_obj();
			tabs[i].tab = tab ;
			tabs[i].tab.parent = tabs[i] ;
			tabs[i].div = div ;			
			tabs[i].index = i ; 
			tabs[i].tab.onclick = display_div ;
			tabs[i].tab.onmouseover = display_div ;		
			if(i==0) {
				tabs[i].tab.className= tabs[i].tab.className.replace(off_state, "active");
				tabs[i].div.className = "active" ; 
			}
			if(i>0) {
				tabs[i].div.className = "off" ;
			}		
		}
	}
window.onload=function() {

	if(document.getElementById("meteo_region")) {document.getElementById("meteo_region").onchange = meteo_form;}
	//if(document.getElementById("bourse_graphs")) {init_divs();}		
}
window.onunload = function() {
	clearTimeout(login_idle);
}

