function goto_secrets(){
var item = document.leftredirectobjectif.focusStar.value;
window.document.location.href=item;
}

function redirect(){
var item=document.redirectform.objet.value;
window.document.location.href=item;
}

function redirect_destination(){
var itemdestination=document.redirectdestination.destination.value;
window.document.location.href=itemdestination;
}

function redirect_objectif(){
var itemobjectif=document.redirectobjectif.objectif.value;
window.document.location.href=itemobjectif;
}

function leftredirect_destination(){
var itemdestination=document.leftredirectdestination.destination.value;
window.document.location.href=itemdestination;
}

function leftredirect_objectif(){
var itemobjectif=document.leftredirectobjectif.objectif.value;
window.document.location.href=itemobjectif;
}

function rightredirect_destination(){
var itemdestination=document.rightredirectdestination.destination.value;
window.document.location.href=itemdestination;
}

function SOSrightredirect_destination(){
var itemdestination=document.SOSrightredirectdestination.SOS.value;
window.document.location.href=itemdestination;
}

function show_calories(elt){
var obj=elt.value;
alert(obj);
}


function deplacer(l1,l2,Kcal) {

		var Sel_Obj = l1.options[l1.options.selectedIndex].text;
		var liste_Sel = l2.length;

		if(liste_Sel>0){
			for (i=0;i<liste_Sel;i++){
						if (l2.options[i].text==Sel_Obj){
						var pass = "non";
						break;
						}
			}
		}


		if (l1.options[l1.options.selectedIndex].value=="forbidden"){
		alert("Vous ne pouvez pas choisir une rubrique");
		}
		else if (pass=="non"){
		alert("Vous ne pouvez pas choisir deux aliments identiques pour ce repas");
		}
		else if (l1.options.selectedIndex>=0) {

					o = new Option(l1.options[l1.options.selectedIndex].text,l1.options[l1.options.selectedIndex].value);

					l2.options[l2.options.length] = o;

					if(Kcal.value<=0){
					Kcal.value=0;
					ActualKcal = parseInt(Kcal.value);
					}
					else{
					ActualKcal = parseInt(Kcal.value);
					}

					//alert(ActualKcal);
					AddKcal = parseInt(l1.options[l1.options.selectedIndex].value);
					//alert(AddKcal);
					AddedKcal = ActualKcal + AddKcal;
					//alert(AddedKcal);
					Kcal.value=null;
					Kcal.value=AddedKcal;
					Kcal.focus();

					if(document.form.Kcal.value<=0){
							document.form.Kcal.value=0;
					}
					if(document.form.Kcaldeux.value<=0){
							document.form.Kcaldeux.value=0;
					}
					if(document.form.Kcaltrois.value<=0){
							document.form.Kcaltrois.value=0;
					}
					if(document.form.Kcalquatre.value<=0){
							document.form.Kcalquatre.value=0;
					}

					document.form.TotalKcal.value=parseInt(document.form.Kcal.value)+parseInt(document.form.Kcaldeux.value)+parseInt(document.form.Kcaltrois.value)+parseInt(document.form.Kcalquatre.value);



		}

}


function supprimer(l1,Kcal){



	if (l1.options.selectedIndex>=0) {

				if(Kcal.value<=0){
				Kcal.value=0;
				ActualKcal = parseInt(Kcal.value);
				}
				else{
				ActualKcal = parseInt(Kcal.value);
				}
				//alert("actuel "+ActualKcal);

				SupprKcal = parseInt(l1.options[l1.options.selectedIndex].value);
				//alert("Supp value "+SupprKcal);

				SuppressedKcal = ActualKcal - SupprKcal;
				//alert("final "+SuppressedKcal);

				Kcal.value=null;
				Kcal.value=SuppressedKcal;
				Kcal.focus();

				l1.options[l1.options.selectedIndex] = null;


				if(document.form.Kcal.value<=0){
						document.form.Kcal.value=0;
				}
				if(document.form.Kcaldeux.value<=0){
						document.form.Kcaldeux.value=0;
				}
				if(document.form.Kcaltrois.value<=0){
						document.form.Kcaltrois.value=0;
				}
				if(document.form.Kcalquatre.value<=0){
						document.form.Kcalquatre.value=0;
				}

				document.form.TotalKcal.value=parseInt(document.form.Kcal.value)+parseInt(document.form.Kcaldeux.value)+parseInt(document.form.Kcaltrois.value)+parseInt(document.form.Kcalquatre.value);

	}

}


function clear_all(){

			var count_liste1 = document.form.liste_art_choisis.length;
			for (i=0;i<=count_liste1;i++){
			document.form.liste_art_choisis.options[0] = null;
			}
			var count_liste2 = document.form.liste_art_choisisdeux.length;
			for (i=0;i<=count_liste2;i++){
			document.form.liste_art_choisisdeux.options[0] = null;
			}
			var count_liste3 = document.form.liste_art_choisistrois.length;
			for (i=0;i<=count_liste3;i++){
			document.form.liste_art_choisistrois.options[0] = null;
			}
			var count_liste4 = document.form.liste_art_choisisquatre.length;
			for (i=0;i<=count_liste4;i++){
			document.form.liste_art_choisisquatre.options[0] = null;
			}

}



	function slideShow(slide,nbTotal) {

	    for(i=1;i<(nbTotal+1);i++)
			if( i==slide )
				document.getElementById('slide'+i).style.display = "block";
			else
				document.getElementById('slide'+i).style.display = "none";
	}

	function slideShowPeople(slide,nbTotal) {

	    for(i=0;i<(nbTotal+1);i++)
			if( i==slide )
				document.getElementById('slide'+i).style.display = "block";
			else
				document.getElementById('slide'+i).style.display = "none";
	}

	function slideShowDouble(slide,nbTotal) {

	    for(i=0;i<(nbTotal+1);i++)
			if( i==slide )
			{
				document.getElementById('image'+i).style.display = "block";
				document.getElementById('slide'+i).style.display = "block";
			}
			else
			{
				document.getElementById('image'+i).style.display = "none";
				document.getElementById('slide'+i).style.display = "none";
			}
	}

	function prec(nbTotal){

		for(i=1;i<(nbTotal+1);i++)
			if( document.getElementById('slide'+i).style.display == "block" )
				if( i==1 ) show = nbTotal;
				else show = i-1;
		slideShow(show,nbTotal);
	}

	function suiv(nbTotal){

		for(i=1;i<(nbTotal+1);i++)
			if( document.getElementById('slide'+i).style.display == "block" )
				if( i==nbTotal ) show = 1;
				else show = i+1;
		slideShow(show,nbTotal);
	}


	function check_objectif(){

		var item=document.go_menu_personnalise.objectif_calorique.value;

		if((item>3000)||(item<1500)){
			alert("Votre apport calorique doit se situer entre 1500 et 3000 calories");
		}
		else{
			document.go_menu_personnalise.submit();
		}
	}

	function valider(){

		var item=document.go_menu_personnalise.objectif_calorique.value;

		if((item>3000)||(item<1500)){
			alert("Votre apport calorique doit se situer entre 1500 et 3000 calories");
			return false;
		}
		else{
			return true;
		}
	}

	function popupWindow(url) {
  		window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=850,height=600,screenX=150,screenY=150,top=100,left=150')
	}
	
	/**
		Auteur: Ousmane KANTE (kante.ousmane@gmail.com) le 12-03-07__17h45
		ajouté pour ouvrir un pop up sans redimensionnement: functionalité d'edition in-site
		voir le template design/elle_edit_design/templates/open_elle_edit_div.tpl
	*/
	function visualisationPopUp(url) {
  		window.open(url)
	}
	
	/**
		fonctionalité d'affichage des div  de modification
	*/
	function ShowOrHideCadres(show,nomClasse,masquer,afficher)
	{
		if(document.getElementById(show).innerHTML==afficher)
		{
			var mesStyle ="float:left;border-color:#FF0000;border-style:solid;border-width:1px";
			ChangeClassNameBorder( nomClasse, mesStyle);
			document.getElementById(show).innerHTML=masquer;
		}
		else if(document.getElementById(show).innerHTML==masquer)
		{
			var mesStyle ="";
			ChangeClassNameBorder( nomClasse, mesStyle );
			document.getElementById(show).innerHTML=afficher;
		}
	}
	/*cette fonction modifie la bordure de toutes les divs de class=nomClass)
	on peut l'étendre à souhait en passant un troisiemen paramètre (tagName) et
	tester ensuite si l'element est du type souhaiter, dans mon cas tous les élement son de type div
	*/
	function ChangeClassNameBorder(nomClass, mesStyle)  
	{   
		var elems = document.getElementsByTagName("div");
		for ( var i = 0; ( elem = elems[i] ); i++ ) 
		{ 
			if ( elem.className == nomClass ) 
			{
				 if(document.all)//IE
				 {
				 	elem.style.cssText=mesStyle;
				 }
				 else //gecko Base
					elem.setAttribute('style',mesStyle); 
			} 
		}
	}
	/* toAffiche variable globale défini dans preview.tpl*/
	function BlocMouseOver(id)
	{
		if ( toAffiche == 0 )
		{
			if ( document.all )
			{
				document.getElementById(id).style.cssText = 'position:absolute;float:left; top:20%; left:20%;z-index:1000;width:50%; height:50%;display:block;';
			}
			else
				document.getElementById(id).setAttribute('style', 'position:absolute;float:left; top:20%; left:20%;z-index:1000;width:50%; height:50%;display:block;')
		}
	}
	function BlocMouseOut(id)
	{
		if ( toAffiche == 0 )
		{
			document.getElementById(id).style.display = "none";			
		}
	}
	function MyRoleOver(nomClasse)
	{
		if(toAffiche == 1 )
		{
			//var mesStyle = "float:left;margin:0; padding:0;position:relative";
			//OutLineClass( nomClasse, mesStyle );
			OutLineClass( 'image_programmable' , 'display:none');
			document.getElementById('my_rollover_button').value = "Afficher les blocs";
			toAffiche = 0;
			return;
		}
		else
		{
			//var mesStyle = "float:left;margin:0; padding:0;position:relative";
			//OutLineClass( nomClasse , mesStyle );
			OutLineClass( 'image_programmable' , 'position:absolute;float:left; top:20%; left:20%;z-index:1000;width:50%; height:50%;display:block;');
			document.getElementById('my_rollover_button').value = "Cacher les blocs";
			toAffiche = 1;
			return;
		}
	}
	function OutLineClass(nomClass, outlineText)  
	{   
		var elems = document.getElementsByTagName("div");
		for ( var i = 0; ( elem = elems[i] ); i++ ) 
		{ 
			if ( elem.className == nomClass ) 
			{
				if(document.all)//IE
				{
					elem.style.cssText = outlineText;
				}
				else //gecko Base
				{
					elem.setAttribute('style',outlineText);
				}
			} 
		}
	}
	function ElleUK_TV()
	{
		//window.open('http://www.elleuk.com/elle/elletv_player/newplayer6.html','Ellecatwalk2tabbedplayer','scrollbars=no,resizable=no,status=no,width=990,height=550');
		window.location='http://www.elleuk.com/elleuk_tv/elleTV.php';
	}
	
	//fin modification Ousmane KANTE
	
	
	//pngfix is to add transparency for png on ie
	function pngfix(){
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		
		if ((version >= 5.5) && (document.body.filters)) {
		   for(var i=0; i<document.images.length; i++){
		      var img = document.images[i]
		      var imgName = img.src.toUpperCase()
		      if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
		         var imgID = (img.id) ? "id='" + img.id + "' " : ""
		         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		         var imgStyle = "display:inline-block;" + img.style.cssText 
		         if (img.align == "left") imgStyle = "float:left;" + imgStyle
		         if (img.align == "right") imgStyle = "float:right;" + imgStyle
		         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		         var strNewHTML = "<span " + imgID + imgClass + imgTitle
		         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
		         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		         + "(src=\'" + img.src + "\');\"></span>" 
		         img.outerHTML = strNewHTML
		         i = i-1
			  }
			}
		}
	}
