/* ------------------------------------------------------------------- */
// Cognicase | Solutions Web | Marc-Antoine Duhaime
// Ce script à été testé sur les plateformes suivantes:
// PC  IE 5.00 | 5.50 | 6.0
// PC  NS 4.6 | 4.7 | 4.77 | 6.0 (Désactivé) | 6.21
// MAC IE 4.50 
// MAC NS 4.75
/* ------------------------------------------------------------------- */

/* -- [>] Popup communique speciaux ------------------------------------------------- */
function openpopcomm(page) {
	if (page == 'nohref')
		{ return; }
	else
		{ 
			var iMyWidth;
			var iMyHeight;
			iMyWidth = (window.screen.width/2) - (330 + 10); 
			iMyHeight = (window.screen.height/2) - (200 + 10); 
			var win2 = window.open(page,"Lassonde","width=700,height=600,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
			win2.focus();
		}
}

/* -- [>] Configuration ---------------------------------------------- */
var lib_NewsHeight = 100;
var lib_NewsSpeed = 100;
var lib_NewsStep = 1;


/* -- [>] Nouvelles -------------------------------------------------- */
var lib_NewsText = "";
var xmlHttp;

function generateText()
{
	xmlHttp=GetXmlHttpObject();
	
  	if(xmlHttp == null)
  	{
    	alert("Your browser does not support AJAX!");
     	return;
  	}
  	
  	var url = escape("http://lassonde.fr.mediaroom.com/index.php?s=10872&pagetemplate=rss");
  	xmlHttp.onreadystatechange = stateChanged;
  	xmlHttp.open("GET", "../RssProxy/proxy.asp?lang=fr&url=" + url, true);
  	xmlHttp.send(null);
}

function stateChanged()
{  	
  	if(xmlHttp.readyState == 4)
  	{
	  	document.getElementById('lib_ChildLayer').innerHTML = xmlHttp.responseText;
	  	/*alert(document.getElementById('lib_ChildLayer').innerHTML);*/
	  	/*lib_NewsText = xmlHttp.responseText;*/
	  	
	  	if(lib_bw.ns4){lib_NewsTextHeight = document.lib_ParentLayer.document.lib_ChildLayer.document.height;}
		if(lib_bw.ie){lib_NewsTextHeight = document.all['lib_ChildLayer'].offsetHeight;}
		if(lib_bw.dom){lib_NewsTextHeight = document.getElementById('lib_ChildLayer').offsetHeight;}
	  	
	  	lib_Scroll();
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	
	try
	{
    	xmlHttp = new XMLHttpRequest();
  	}
  	catch(e)
  	{
    	try
    	{
	    	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    catch(e)
	    {
	    	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	}
	
	return xmlHttp;
}


/* -- [>] Browser detection ------------------------------------------ */
function lib_browserCheck(){
	this.usr=navigator.userAgent;
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie6=(this.ver.indexOf("MSIE")>-1 && this.dom && !this.ie4 && !this.ie5)?1:0;
	this.ie=(this.ie4 || this.ie5 || this.ie6);
	this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
	this.ns60=(this.usr.indexOf("6.0")>-1 && this.ns6)?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ns=(this.ns4 || this.ns6);
	this.ok=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6);
	this.mac=(this.ver.indexOf("Mac")>-1)?1:0;
	return this;
}
var lib_bw = new lib_browserCheck();



/* -- [>] Écriture du DIV ou LAYER ----------------------------------- */
if(lib_bw.ok && !lib_bw.ns60){
	var lib_Html = "";

	
	if(lib_bw.ns4){
		lib_Html += "<layer id='lib_ParentLayer' pageX='10' pageY='205' z-index='999' width='750' height='100' visibility='show' clip='0,0,750,100'>";
		lib_Html += "	<layer id='lib_ChildLayer' left='0' top='0' z-index='999' width='750' visibility='show'>"+lib_NewsText+"</layer>";
		lib_Html += "</layer>";
	}
	
	if(lib_bw.ie || lib_bw.dom){
		lib_Html += "<div id='lib_ParentLayer' style='z-index:999; position:absolute; overflow: hidden; visibility: visible; top: 205px; left: 10px; width: 750px; height: 100px; clip:rect(0,750,100,0);'>";
		lib_Html += "	<div id='lib_ChildLayer' style='position: absolute; visibility: visible; top: 0px; left: 0px; width: 750px;'>"+lib_NewsText+"</div>";
		lib_Html += "</div>";
	}
	
	document.open();
	document.write(lib_Html);
	document.close();
}

/* -- [>] Scroll ----------------------------------------------------- */	
function lib_Scroll(){

	if(lib_bw.ns4){
		if(document.lib_ParentLayer.document.lib_ChildLayer.top >= - lib_NewsTextHeight){
			document.lib_ParentLayer.document.lib_ChildLayer.top += - lib_NewsStep;
			setTimeout('lib_Scroll()',lib_NewsSpeed);
		}
		else{
			document.lib_ParentLayer.document.lib_ChildLayer.top = lib_NewsHeight;
			lib_Scroll()
		}
	}

	if(lib_bw.ie4){
		if(parseInt(document.all['lib_ChildLayer'].style.top) >= - lib_NewsTextHeight){
			document.all['lib_ChildLayer'].style.top = parseInt(document.all['lib_ChildLayer'].style.top) - lib_NewsStep;			
			setTimeout('lib_Scroll()',lib_NewsSpeed);
		}
		else{
			document.all['lib_ChildLayer'].style.top = lib_NewsHeight;
			lib_Scroll();
		}
	}

	if(lib_bw.dom){
		if(parseInt(document.getElementById('lib_ChildLayer').style.top) >= - lib_NewsTextHeight){
			document.getElementById('lib_ChildLayer').style.top = parseInt(document.getElementById('lib_ChildLayer').style.top) - lib_NewsStep;			
			setTimeout('lib_Scroll()',lib_NewsSpeed);
		}
		else{
			document.getElementById('lib_ChildLayer').style.top = lib_NewsHeight;
			lib_Scroll();
		}
	}
}


/* -- [>] Initialisation --------------------------------------------- */
var lib_NewsTextHeight
function initNews(){
/*		
	if(lib_bw.ns4){lib_NewsTextHeight = document.lib_ParentLayer.document.lib_ChildLayer.document.height;}
	if(lib_bw.ie){lib_NewsTextHeight = document.all['lib_ChildLayer'].offsetHeight;}
	if(lib_bw.dom){lib_NewsTextHeight = document.getElementById('lib_ChildLayer').offsetHeight;}
*/	
	generateText();
	/*lib_Scroll();*/
}
