/* VARIABLES */
var ie6=false; 
var nbr_popin_total=0;
var current_popin=0;

/* 
	Functions Standards 
*/
function _(o) {
	if (!o) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById(o)) return false;
	return document.getElementById(o);
}
function getnextnode(source,o) {
	if (!o) return false;
	oo=false;
	if (o.firstChild) return o.firstChild;
	if (o.nextSibling) return o.nextSibling;
	o=o.parentNode;
	while (!oo && o && (o!=source)) {
		oo=o.nextSibling;
		o=o.parentNode;
	}
	return oo;
}
function getElementsByClassName(needle) {
	var my_array = document.getElementsByTagName("*");
	var retvalue = new Array();
	var i;
	var j;
	for (i=0,j=0;i<my_array.length;i++) {
		var c = " " + my_array[i].className + " ";
		if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[i];
	}
	return retvalue;
}
function classRepl(whatReplace,style) {
	for(var i=0;i<whatReplace.length;i++) {	
		whatReplace[i].style.display=style;
    }
}
/* 
	INIT 
*/
window.onload=init;
function init() {
	ie6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	if (_('popin_produit')) {
		nbr_popin_total=getElementsByClassName('lien_popin').length;
	}
	startList("page");
}

/*
	STARTLIST
*/
var maxtour=1000;
function startList(n) {
	courant=0;
	if (document.getElementById) {
		navRoot = document.getElementById(n);
		node = navRoot;//getnextnode(navRoot);
		last_node = "";
		while ((node) && (courant<maxtour)) {
			node = getnextnode(navRoot,node);
			courant++;
			if (node) {
				// applique iepngfix sur les png
				if (node.nodeName=="IMG" && ie6) {
					mysplit=node.src.split('.');
					myext=mysplit[mysplit.length-1];
					if (myext.toLowerCase()=='png') node.style.behavior="url(/build/iepngfix.htc);";
				}
				// Gestion des formulaires : contact
				if (node.className=='button_content') {
					node.onmouseover=function () {
						close_all('footer_content');
						myid=parseInt(this.id.replace('button_content',''));
						_('footer_content'+myid).style.display='block';
						return false;
					}
					node.href='javascript:;';
				}
				if (node.id=='header') {
					node.onmouseover=function () {
						close_all('footer_content');
						if (_('footer_actu')) _('footer_actu').style.display='block';
						return false;
					}
					node.href='javascript:;';
				}
				// Gestion des popins
				if (node.className=='lien_popin') {
					node.onclick=function () {
						mid=this.id;
						mid=parseInt(mid.replace('popin_',''));
						current_popin=mid;
						affi_popin();
						return false;
					}
					node.href='javascript:;';
				}
				if (node.className=='popin_fermer') {
					node.onclick=function () {
						_('popin_produit').style.display='none';
						_('popin_content_visu').innerHTML='';
						_('popin_content_txt').innerHTML='';
						return false;
					}
					node.href='javascript:;';
				}
				if (node.id=='f_gauche_lien') {
					node.onclick=function () {
						current_popin--;
						affi_popin();
						return false;
					}
					node.href='javascript:;';
				}
				if (node.id=='f_droite_lien') {
					node.onclick=function () {
						current_popin++;
						affi_popin();
						return false;
					}
					node.href='javascript:;';
				}
				
			}
		}
	}
}
function affi_popin() {
	if (current_popin<1) current_popin=nbr_popin_total;
	if (current_popin>nbr_popin_total) current_popin=1;
	_('popin_content_visu').innerHTML=_('popin_content_visu-'+current_popin).innerHTML;
	_('popin_content_txt').innerHTML=_('popin_content_txt-'+current_popin).innerHTML;
	_('popin_produit').style.display='block';
}
function close_all(maclass) {
	mytab=getElementsByClassName(maclass);
	if (mytab) {
		classRepl(mytab,'none');
	}
}
function affobj(o,sens) {
	if (!o) return false;
	o=_(o);
	if (!o) return false;
	o.style.display=(sens==1) ? "block":"none";
	return false;
}
