/*
Fading Ticker Tape Script- ? Dynamic Drive (www.dynamicdrive.com)
Fading background color component by Dave Methvin, Windows Magazine
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

var		speed = 4000;
var		cur_news = 1;
var		news;
var		tickerobject;

function start(my_news)
{
	news=my_news;
	if (document.all)
		tickerobject=document.all.subtickertape.style;
	else if(document.getElementById)
		tickerobject=document.getElementById("subtickertape").style;
	else
		tickerobject=document.tickertape.document;
	if (document.all||document.layers||document.getElementById)
	{
		regenerate2();
		update();
	}
}

function regenerate()
{
	window.location.reload()
}

function regenerate2()
{
	if (document.layers)
		setTimeout("window.onresize=regenerate",800);
}

function update()
{
 	BgFade(0xff,0xff,0xff, 0x00,0x00,0x00,10);
 	if (news[cur_news] == null)
 		return;
	if (document.layers)
	{
		document.tickertape.document.subtickertape.document.write('<div class="subtickertapefont">'+news[cur_news]+'</div>');
		document.tickertape.document.subtickertape.document.close();
	}
	else if(document.getElementById)
	{
		document.getElementById("subtickertape").innerHTML=news[cur_news];
	}
	else
		document.all.subtickertape.innerHTML=news[cur_news];
	if (cur_news < news.length-1)
		cur_news++;
	else
		cur_news=1;
	setTimeout("update()",speed);
}

function BgFade(red1, grn1, blu1, red2, grn2, blu2, steps)
{
	sred = red1; sgrn = grn1; sblu = blu1;
	ered = red2; egrn = grn2; eblu = blu2;
 	inc = steps;
 	step = 0;
 	RunFader();
}

function RunFader()
{
	var epct = step/inc;
 	var spct = 1 - epct;
 	if (document.layers)
 		tickerobject.bgColor = Math.floor(sred * spct + ered * epct)*256*256 + Math.floor(sgrn * spct + egrn * epct)*256 + Math.floor(sblu * spct + eblu * epct);
 	else
 		tickerobject.Style= Math.floor(sred * spct + ered * epct)*256*256 + Math.floor(sgrn * spct + egrn * epct)*256 + Math.floor(sblu * spct + eblu * epct);
 	if ( step < inc )
 		setTimeout('RunFader()',100);
 	step++;
}


// Fonction de gestion de l'affichage des sous-menus
// On commence par cacher tous les sous-menus
// Ensuite, on fait afficher celui qui nous int?resse.
function manage_lv2Submenus(menu2show)
{
	hide_all_lv2Submenus();
	if (menu2show)
	document.getElementById(menu2show).className = "ss_menu show_menu";
}

// Fonction servant ? rendre invisible les tous les sous-menus
// En fait, on cache chacune des div contenues dans la div ss_menus_container.
function hide_all_lv2Submenus()
{
	var ss_menus_container = document.getElementById("ss_menus_container");
	var ss_menus_divs = ss_menus_container.getElementsByTagName("div");
	for (var i=0; i< ss_menus_divs.length; i++)
	{
		ss_menus_divs[i].className = "ss_menu hide_menu";
	}
}

// Fonction r?affichant le menu propre ? la page sur
// laquelle on se trouve et higlightant le bouton de
// menu de level 1 correspondant.
function reset_init_menu(page_lv_name)
{
	ini_menu_name = "ss_menu_";
	li_menu_name = "li_menu_";
	if(page_lv_name!=0) {
		ini_menu_name = "ss_menu_" + page_lv_name;
		li_menu_name = "li_menu_" + page_lv_name;
	}
	manage_lv2Submenus(ini_menu_name);
	//document.getElementById(li_menu_name).className = "actualPageLVSelected";
	if(li_menu_name != "vide" && document.getElementById(li_menu_name) != null){document.getElementById(li_menu_name).className = "actualPageLVSelected";}
}

// On encha?ne avec l'affichage de ces images
function Rollover(nom, url)
{
	window.document.images[nom].src = url;
}

function changeliste(select_famille, first_l1, first_l2)
{
	select_gamme=document.getElementById('gamme');
	if (select_famille.options[select_famille.selectedIndex].text == first_l1)
	{
		select_gamme.options.length=1;
		select_gamme.options[0].text=first_l2;
		select_gamme.options[0].value="";
		return;
	}
	myarray = select_famille.options[select_famille.selectedIndex].value.split("%FIN");
	select_gamme.options.length=myarray.length;
	select_gamme.options[0].text=first_l2;
	select_gamme.options[0].value="";
	select_gamme.options[0].selected="selected";
	for (var i=0;i < myarray.length-1; i++)
	{
		arrayGamme=myarray[i].split("%NAME");
		select_gamme.options[i+1].text=arrayGamme[1];
		select_gamme.options[i+1].value=arrayGamme[0];
	}
}

function quickOpen(url) {
	if(url.length>0) {
		if (url.substr(0,6)=='0-http') {
			url2 = url.substr(2,url.length);
			window.open(url2,'777');
		}else{
			window.location.href=url;
		}
	}
}

/* DDTH Portes ouvertes */
function openJPO()
{
	window.open('http://www.dedietrich-thermique.fr/spepro/jpo2007/index.htm', 'jpo2007', 'height=400, width=700, directories=no, menubar=no, status=no, location=no, scrollbars=no');
}

/* DDTH Jeu Rugby */
function openRugby(object_id, email, nom, prenom, numero_client) {
	var url  = "http://www.dedietrich-thermique.fr/spepro/rugby2007/";
	    url += "?object_id=" + object_id;
	    url += "&email=" + escape(email);
	    url += "&nom=" + escape(nom);
	    url += "&prenom=" + escape(prenom);
	    url += "&numero_client=" + escape(numero_client);
	    
	    window.open(url, 'rugby2007', 'height=500, width=735, resizable=yes, directories=no, menubar=no, status=no, location=no, scrollbars=yes');
}

function openFormPromo(form, width) {
	var opt = 'width='+width+', height=560,menubar=no,status=no,location=no,scrollbars=yes';
	var w   =  window.open('http://www.dedietrich-thermique.fr/spepro/formulaires_promo/'+form+'/index.php', 'form_promo_'+form, opt);
 
	w.focus();
}

function openPopup(url, name, w, h, opt) {
	var o = 'height=' + h + ', width=' + w;
	
	if(!opt) {
		o += ', resizable=no, directories=no, menubar=no, status=no, location=no, scrollbars=yes';
	} else {
		o += ', ' + opt;
	}
	
	var p = window.open(url, name, o);
	
	if(p) {
		p.focus();
	}
}

function eKitOpen(nodeID, w, h) {
	openPopup('/ekit/connect/' + nodeID, 'ekit' + nodeID, w, h);
}

function ShowHideLayer(boxID) {
	/* Obtain reference for the selected boxID layer and its button */
	var box = document.getElementById("box"+boxID);
	var boxbtn = document.getElementById("btn"+boxID);
	
	/* If the selected box is currently invisible, show it */
	if(box.style.display == "none" || box.style.display=="") {
		box.style.display = "block";
 		boxbtn.src = "../images/fleche_fermer.gif";
	}
	/* otherwise hide it */
	else {
		box.style.display = "none";
		boxbtn.src = "../images/fleche_ouvrir.gif";
	}
}



imgout=new Image(5,5);
imgin=new Image(5,5);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="../images/fleche_ferme.gif";
	imgin.src="../images/fleche_ouvert.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}


function toggle(targetId) {
target = document.getElementById(targetId);
if (target.style.display == "none"){
target.style.display="";
} else {
target.style.display="none";
}
}

