/* O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o° */
/* O°o°O°o°O°o°O°o° Powered by Chewing Com O°o°O°o°O°o°O°o°O°o°O°o°O°o° */
/* O°o°O°o°O°o°O° http://www.chewing-com.com o°O°o°O°o°O°o°O°o°O°o°O°o° */
/* O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o°O°o° */

/* ECRITURE DU FLASH
/* ******************************************************************** */
function WriteSWF(path, file, videofile, width, height){
var EmbedSWF = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+path+file+"?videofile="+videofile+"\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><embed src=\""+path+file+"?videofile="+videofile+"\" menu=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed></object>";

document.write(EmbedSWF);
}

/* ROTATION DES GAMMES SUR LA PAGE D'ACCUEIL
/* ******************************************************************** */

ActusLayers = new Array();
ActusLayers[0] ="rub1";
ActusLayers[1] ="rub2";
ActusLayers[2] ="rub3";
ActusLayers[3] ="rub4";
ActusLayers[4] ="rub5";
var id;
function AutoSwapNews(id){
	//alert("On démarre avec le nombre "+id+ " ("+ActusLayers[id]+")");
	for(i = 0; i<ActusLayers.length; i++){
		if(i == id){
			if(document.all){
				document.all[ActusLayers[i]].style.display = "block";
			}
			if(document.getElementById){
				document.getElementById(ActusLayers[i]).style.display = "block";
			}
		} else {
			if(document.all){
				document.all[ActusLayers[i]].style.display = "none";
			}
			if(document.getElementById){
				document.getElementById(ActusLayers[i]).style.display = "none";
			}
		}
	}
	// On déclenche le diaporama en fonction de ce nombre
	TimerNews(id);	
}

function SwapNews(id){
	//alert("On démarre avec le nombre "+id+ " ("+ActusLayers[id]+")");
	for(i = 0; i<ActusLayers.length; i++){
		if(i == id){
			if(document.all){
				document.all[ActusLayers[i]].style.display = "block";
			}
			if(document.getElementById){
				document.getElementById(ActusLayers[i]).style.display = "block";
			}
		} else {
			if(document.all){
				document.all[ActusLayers[i]].style.display = "none";
			}
			if(document.getElementById){
				document.getElementById(ActusLayers[i]).style.display = "none";
			}
		}
	}
	window.clearTimeout(test);
}


/* JAVASCRIPT DIAPO RECETTE */
function SwitchProduct(direction, count, table, widcat, initNb){
	count = count - 1;
	if(direction =="next"){
		if(initNb<count){
			initNb = initNb+1;
		} else if(initNb==count){
			initNb = 1;	
		}
	}
	
	if(direction =="prev"){
		if(initNb>1){
			initNb = initNb-1;
		} else if(initNb==1){
			initNb = count;
		}
	}
	
	window.location.href="produit.php?wid="+table[initNb]+"&initNb="+initNb;
}


function TimerNews(id){
	var next;
	if (id == (ActusLayers.length-1)){
		next=0;
	} else {
		next = id+1;
	}
	//alert("le prochain est le nombre "+next+ " ("+ActusLayers[next]+")");
	// LE TEMPS EST PARAMETRÉ A 5 SECONDES
	test=window.setTimeout("AutoSwapNews("+next+")",5000);
}

function DiapoNews(){
	// On attribue un nombre aléatoirement entre 0 et 2
	var id = Math.round(Math.random()*2);
	// On fais apparaitre le calque en conséquence
	AutoSwapNews(id);
}



/* ROLLOVER D'IMAGE
/* ******************************************************************** */
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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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];}
}


/* OUVERTURE POP UP VOEUX 2010 */

function openVoeux2010() {
	window.open('pepsico-voeux2010.html', 'Voeux2010', 'width=900, height=610', 'resizable=no');
}