var garnierMenu = false;
var garnierMenuWidth = 138;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',noresizable';
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// onclick="openWindow('page.html','name','width','height','yes ou no pour scrollbar'); return false"

// PopUp LEGAL
function popUpLegal(url) {
	fenetre=window.open(url,"int","resizable=no,width=600,height=487,scrollbars=yes");
}


// FOLDOUTMENU script
function SwitchMenu(obj, objtype) {
	if (document.getElementById) {
		var el = document.getElementById(obj);
		var ar = document.getElementById("masterdiv").getElementsByTagName("span");
//		var ar_li = document.getElementById("masterdiv").getElementsByTagName("li");
		if (el.style.display != "block") {
			for (var i=0; i<ar.length; i++) {
				if ( ar[i].className == objtype + "menu" ) {
					ar[i].style.display = "none";
//					ar_li[i].style.listStyleImage="url(../img/img_up.gif)";
				}
			}
			el.style.display = "block";
//			event.srcElement.style.listStyleImage="url(../img/img_down.gif)";
			
		} else {
			el.style.display = "none";
//			event.srcElement.style.listStyleImage="url(../img/img_up.gif)";
		}
	}
}

// Fonction pour les rollover menuGarnier
function rollGarnier(quel_b,bouton) {
	if (document.images) {
		document.images[quel_b].src=eval(bouton+".src");
	}
}

// nommé les images 
if (document.images) {
	arrow_o = new Image(4,6);arrow_o.src = "http://garnier.ca/img/menu_garnier/arrow_o.gif";
	arrow_n = new Image(4,6);arrow_n.src = "http://garnier.ca/img/menu_garnier/arrow.gif";
	arrowGarnier_o = new Image(4,6);arrowGarnier_o.src = "http://garnier.ca/img/menu_garnier/arrowGarnier_o.gif";
	arrowGarnier_n = new Image(4,6);arrowGarnier_n.src = "http://garnier.ca/img/menu_garnier/arrowGarnier.gif";
}

// Fonction pour les rollover
function roll(quel_b,bouton) {
	if (document.images) {
		document.images[quel_b].src = "../img/"+bouton+".gif";
	}
}


//return if user is on WIN IE, or not
function isMSIE() {
	//detection de browser
	var browserType = navigator.appName
	var browserOS = navigator.platform
	
	//IE 5+ pour Windows
	if( ( browserType.indexOf("Microsoft") != -1 ) && ( browserOS.indexOf("Win32") != -1 ) ) {
		browserType = "IE"
		browserOS = "Windows"
		return true;
	} else {
		return false;
	}
}
// show/hide div
function verifScreen() {
	if(screen.width > 800){
		
		if (!document.getElementById) return;
		s = document.getElementById('garnier');
		
		s.style.display = 'block';
		garnierMenu = true;
	}
}

function getObj(name)
{
  if (document.getElementById)
  {
  	if(document.getElementById(name)){
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
	}
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function showHideVoken(flag, objId) {
	//alert("Show Voken: "+flag);
	var obj = new getObj(objId);
	if (flag)
	{
		obj.style.display = "block";
		// Repositionne si menu Garnier
		fixDivLeftPos(obj, 237);
	} 
	else
	{
		obj.style.display = "none";
	}
}

// Si le menu Garnier est affiché, déplace le div vers la droite
function fixDivLeftPos(obj, realLeftPos) {
	if (garnierMenu) {
		//obj.style.left = realLeftPos + garnierMenuWidth + "px";
	}
}
function fEmbedFlash(sPath, sWidth, sHeight, sParams) {

	var str 			= '';
	
	var params_str = "";
	if (sParams != "") {
		defaultParams = defaultParams + ',' + sParams;
	}
	arr_params = defaultParams.split(",");
	for (i = 0; i< arr_params.length; i+=2) {
		params_str += ' ' + arr_params[i] + '=\"' + arr_params[i+1] + '\"';
	}
	
	str += '<object id=\"' + id + '\" classid=\"' + classid + '"\" codebase=\"' + codebase + '\" width=\"' + sWidth + '\" height=\"' + sHeight + '\">';
	str += '<param name=\"movie\" value=\"' + sPath + '\">';
	
	for (i = 0; i < arr_params.length; i+=2) {	
		str += '<param name=\"' + arr_params[i] + '\" value=\"' + arr_params[i+1]+ '\">';
	}
	str += '<embed src=\"' + sPath + '\" pluginspage=\"' + pluginspage+ '\" type=\"application/x-shockwave-flash\" width=\"' + sWidth + '\" height=\"' + sHeight + '\" ' + params_str + '></embed>';
	str += '</object>';
	document.write(str);
}

function getPageHeight() {	
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return y;
}
function showStyle(svariable,value)
{
	showHideVoken(true, 'stylesBox');
	var domAnimation = document.getElementById('animation');
	//var domAnimation =  new getObj('animation');
	setTimeout("javascriptToFlash('"+svariable+"','"+value+"')",1000);
}
function javascriptToFlash(svariable,value)
{
	var domAnimation = document.getElementById('animation');	 // video_id, "1"
	domAnimation.SetVariable(svariable,value);
}

var intval="";
var nextClick;
var loop;

function slide(){	
	var vitesse = 10;
	
	clearTimeout(loop);
	
	img2.style.left = '-525px';
	btn1.style.cursor = 'auto';
	btn2.style.cursor = 'auto';
	if(btn1.onclick==intervalOnclick){
		nextClick = btn2;
	}else if(btn2.onclick==intervalOnclick){
		nextClick = btn1;
	}
	btn1.onclick = '';
	btn2.onclick = '';

	if(img1.style.left==0){
		img1.style.left = '1px';
	}
	var leftposition = img1.style.left;
	
	leftposition = parseFloat(leftposition);
	
	if(leftposition<520){
		img1.style.left = leftposition+vitesse+'px';
		leftposition = leftposition - 526;
		img2.style.left = leftposition+vitesse+'px';
	}else{
		clearInterval(intval);
		intval='';
		img1.style.left = '-526px'
		img2.style.left = '0px'
		tempoimg1 = img1;
		tempoimg2 = img2;
		img1 = tempoimg2;
		img2 = tempoimg1;
		nextClick.onclick = intervalOnclick;
		nextClick.style.cursor = 'pointer';
		
		tempoimg1 = imgbtn1;
		tempoimg2 = imgbtn2;
		imgbtn1 = tempoimg2;
		imgbtn2 = tempoimg1;
		
		currentSlide = imgbtn2.src
		imgbtn2.src = currentSlide.replace('_on.png','_off.png');
		imgbtn2.onmouseout = function() {outBtn(imgbtn2.id);}
		imgbtn2.onmouseover = function() {overBtn(imgbtn2.id);}
		
		currentSlide = imgbtn1.src
		imgbtn1.src = currentSlide.replace('_off.png','_on.png');
		imgbtn1.onmouseout = "";
		imgbtn1.onmouseover = "";
		intervalTimer();
	}
}

function intervalOnclick(){
	intval=setInterval('slide()',10);
}

function intervalTimer(){
	loop = setTimeout('intervalOnclick()', 7000)
}

function overBtn(idimg){
	var nuSource = document.getElementById(idimg).src;
	nuSource = nuSource.replace('_off.png','_on.png');
	document.getElementById(idimg).src=nuSource;
}
function outBtn(idimg){
	var nuSource = document.getElementById(idimg).src;
	nuSource = nuSource.replace('_on.png','_off.png');
	document.getElementById(idimg).src=nuSource;
}
