/* Javascript - Ingenico */

function Print()
{
	document.print();
}




function OpenLinkFooter(path,l,h,x,y,resize,scroll)
{
	window.open(path,'','width='+l+',height='+h+',left='+x+',top='+y+',resizable=' + resize + ',scrollbars='+scroll);	
}

/* Javascript - Ingenico *******************************************************************/


/***** Sommaire *****/
// 00 - Variables
// 10 - Popup
// 20 - Write Flash
// 30 - rollOver
// 40 - Affichage / Masquage Navigation de niveau 2
// 50 - Search clear
// 99 - onLoad
/*******************/

/***** 00 - Variables *****/
var actURL = document.location.href;
var isOpera = (navigator.userAgent.indexOf('Opera') != -1)? true : false;
var isIE = (document.all && !isOpera && navigator.platform == "Win32")? true : false;
var isIE7 = (navigator.userAgent.indexOf('MSIE 7') != -1)? true : false ;

/***** 10 - Popup *****/
function popThis(url,nom,c,w,h,o){
	if(c){
		var popHPos = (screen.availWidth/2)-(w/2);
		var popVPos = (screen.availHeight/2)-(h/2);
		pop = window.open(url,nom,'width='+w+',height='+h+',top='+popVPos+',left='+popHPos+','+o);
	} else {
		pop = window.open(url,nom,'width='+w+',height='+h+','+o);
	}
	pop.focus();
}

function openPop(f,l,h,op)
{
	longueur=l;
	hauteur=h;
	haut = screen.height/2 - hauteur/2;
	dim = screen.width/2 - longueur/2;
	window.open(f,'pop'+l+'_'+h,'width='+longueur+',height='+hauteur+',left='+dim+',top='+haut+',resizable=no,'+op+'');
}

/***** 20 - Write Flash *****/
function writeFlash(url,id,w,h,o){
	var tempFlashContent = '';
	var flashOptionsTab = new Array();
	flashOptionsTab = o.split('|');
	tempFlashContent += '\n<object id="'+id+'" type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'">\n';
	tempFlashContent += '\t<param name="movie" value="'+url+'" />\n';
	for(i=0; i<flashOptionsTab.length; i++){
		var tempParam = flashOptionsTab[i].split('#')[0];
		var tempValue = flashOptionsTab[i].split('#')[1];
		tempFlashContent += '\t<param name="'+tempParam+'" value="'+tempValue+'" />\n';
	}
	tempFlashContent += '</object>\n';
	document.write(tempFlashContent);
}

/***** 30 - rollOver *****/
var onAdd = '-on';
var rollPart = 'ro-'

function autoRoll(myImg,inde){
	// Evenement onmouse out
	if(!myImg.onmouseout && inde == false){
		myImg.onmouseout = function(){ autoRoll(myImg); }
	}
	// Extension
	imgExt = myImg.src.substring(myImg.src.lastIndexOf('.'));
	// Chemin de l'image
	imgName = myImg.src.substring(0,myImg.src.lastIndexOf("."));
	// Images On / Off
	imgOn = imgName+onAdd+imgExt;
	if(imgName.indexOf(onAdd) != -1){
		imgName = imgName.substring(0,imgName.length-onAdd.length);
	}
	imgOff = imgName+imgExt;
	//Si etat On > RollOff
	if(myImg.src.indexOf(onAdd) != -1){
		myImg.src = imgOff;
	} else { // Sinon RollOn
		myImg.src = imgOn;
	}
}

/***** 40 - Affichage / Masquage Navigation de niveau 2 *****/
var lastSNav = '';
var isRoll = false;

function showSNav(id){

	if(lastSNav != ''){
		hideSNav(lastSNav);
	}
	
	// Affichage

	if (document.getElementById('s'+id))
	{
		document.getElementById('s'+id).style.visibility = 'visible';
	
		if(isIE && !isIE7)
		{
			document.getElementById('f'+id).style.visibility = 'visible';
		}
		navImg = document.getElementById(id).getElementsByTagName('img')[0];
		if(navImg.src.indexOf(onAdd) == -1)
		{
			autoRoll(navImg,true);
			isRoll = true;
		}
		lastSNav = id;
	}
	
}

function hideSNav(id){
	// Masquage
	if (document.getElementById('s'+id))
	{
		document.getElementById('s'+id).style.visibility = 'hidden';
		if(isIE && !isIE7)
		{
			document.getElementById('f'+id).style.visibility = 'hidden';
		}
		navImg = document.getElementById(id).getElementsByTagName('img')[0];
		if(isRoll == true)
		{
			autoRoll(navImg,true);
			isRoll = false;
		}
		lastSNav = '';
	 }
}

/***** 99 - onLoad *****/
var imgTab = new Array();
var divTab = new Array();

function events () { this.functions = []; }
events.prototype.add = function (objFunction) { this.functions[this.functions.length] = objFunction; }
events.prototype.init = function () { for (var i=0;i<this.functions.length;i++) this.functions[i](); }

var navEvents = function loadNav () {
	
	// 00 - Variables
	imgTab = document.images;
	divTab = document.getElementsByTagName('div');
	
	// 30 - rollOver + addTitle
	for(i=0; i<imgTab.length; i++){
		if(imgTab[i].src.indexOf(rollPart) != -1 && imgTab[i].src.indexOf(onAdd) == -1){
			imgTab[i].onmouseover = function(){autoRoll(this)};
		}
		// Ajout du title
		imgTab[i].title = imgTab[i].alt;
	}
	
	// 40 - Affichage / Masquage Navigation de niveau 2
	var navRoot = document.getElementById('navTop');
	var navCount = 0;
	var navTab = navRoot.getElementsByTagName('li');
	
	for(i=0; i<navTab.length; i++){
		if(navTab[i].offsetParent && navTab[i].offsetParent.tagName == 'DIV'){
			// Attribution des ID
			navTab[i].id = 'nav'+navCount;
			navTab[i].onmouseover = function(){ showSNav(this.id); }
			navTab[i].onmouseout = function(){ hideSNav(this.id); }
			if (navTab[i].getElementsByTagName('ol')[0])
			{
				navTab[i].getElementsByTagName('ol')[0].id = 'snav'+navCount;
				// Ajout des iframe sous les layer si IE
				if(isIE && !isIE7){
					navTab[i].innerHTML += '\n<iframe id="fnav'+navCount+'" name="fnav'+navCount+'" frameborder="0" style="visibility:hidden; width:'+navTab[i].getElementsByTagName('ol')[0].offsetWidth+'px; height:'+((navTab[i].getElementsByTagName('ol')[0].offsetHeight)-10)+'px;"></iframe>\n';
				}
			}
			navCount ++;
		}
	}
	
	// XX - First list add
	var ulTab = document.getElementsByTagName('ul');
	if (ulTab)
	{
		for(i=0; i<ulTab.length; i++)
		{
			var test = ulTab[i].getElementsByTagName('li')[0];
			if (test)
			{
				ulTab[i].getElementsByTagName('li')[0].className += ' first';
			}
		}
	}
	
	var olTab = document.getElementsByTagName('ol');
	if (olTab) 
	{
		for(i=0; i<olTab.length; i++) 
		{ 
			var test = olTab[i].getElementsByTagName('li')[0]; 
			if (test)
			{
				olTab[i].getElementsByTagName('li')[0].className += ' first';
			}

		}
	}
	
	
	
	
}

function dynamicSnav (nav,content) {
	this.nav = nav;
	this.content = content;
	this.navNode = document.getElementById(this.nav).getElementsByTagName('li');
	this.contentNode = [];
	this.oldIndex = -1;
	for (var i=0;i<document.getElementById(this.content).getElementsByTagName('div').length;i++) if (document.getElementById(this.content).getElementsByTagName('div')[i].className=="cont") this.contentNode[this.contentNode.length] = document.getElementById(this.content).getElementsByTagName('div')[i];
	this.initEvents();
	this.change(0);
}

dynamicSnav.prototype.initEvents = function () {
	var o = this;
	for (var i=0;i<this.navNode.length;i++) {
		this.navNode[i].id = "n"+i;
		this.navNode[i].onclick = function () { o.change(this.id.charAt(1)); }
	}
}

dynamicSnav.prototype.change = function (index) {
	if (this.oldIndex!=-1&&this.oldIndex!=index) {
		this.navNode[this.oldIndex].className = "";
		this.contentNode[this.oldIndex].style.display = "none";
	}
	this.navNode[index].className = "on";
	this.contentNode[index].style.display = "block";
	this.oldIndex = index;
}

function launchWindowEvents () { windowEvent.init(); }
var windowEvent = new events();
windowEvent.add(navEvents);
window.onload = launchWindowEvents;

function switch_product(img) {
	document.getElementById("visu_produit").style.background = 'url('+img+') no-repeat 4px 3px';
}
