/****************************************************************************/
/* Fonctions permettant de gérer le zomm sur une image dans un layer volant */
/****************************************************************************/

var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
	return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function zoom2(which, e, position, imgwidth, imgheight){
	if (ie||ns6){
		crossobj=document.getElementById? document.getElementById("zoomImage") : document.all.zoomImage
		// ICI POUR REGLER LA POSITION DE LA LOUPE PAR RAPPORT A LA PAGE
		crossobj.style.left=500+"px"
		crossobj.style.top=80+"px"
		
		crossobj.innerHTML='<div align="right" id="dragbar" class="txt-bold"><span id="closetext" onClick="closepreview()">&raquo; Fermer</span></div><img src="'+which+'">'
		crossobj.style.visibility="visible"
		return false
	}
	else //if NOT IE 4+ or NS 6+, affiche image ds le navigateur en pleine page
		return true
}

function closepreview(){
	crossobj.style.visibility="hidden"
}

function drag_drop(e){
	if (ie&&dragapproved){
		crossobj.style.left=tempx+event.clientX-offsetx+"px"
		crossobj.style.top=tempy+event.clientY-offsety+"px"
	}
	else if (ns6&&dragapproved){
		crossobj.style.left=tempx+e.clientX-offsetx+"px"
		crossobj.style.top=tempy+e.clientY-offsety+"px"
	}
	return false
}

function initializedrag(e){
	if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
		offsetx=ie? event.clientX : e.clientX
		offsety=ie? event.clientY : e.clientY
		
		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		
		dragapproved=true
		document.onmousemove=drag_drop
	}
}

function checkOther(isOther,name_other){
	if(isOther){
    $(name_other).disabled=false;
    $(name_other).focus();
  }
  else{
    $(name_other).value='';
    $(name_other).disabled=true;
  }
}

function deployShowcase(){
  switch($('showcase_module_contenu_test').style.visibility){
    case 'hidden':
      $('showcase_module_contenu_test').style.visibility = 'visible';
      break;
    
    case 'visible':
      $('showcase_module_contenu_test').style.visibility = 'hidden';
      break;
  }
}

function deployRecommendation(num){
	if(num=='all'){
    switch($('etat_categorie').value){
      case 'close':
        for(i=0;i<$('nb_categorie').value;i++){
          $('div'+i).style.display = 'inline';
          $('img'+i).src = '/images/bas.png';
          $('img_etat').src = '/images/moins.png';
          $('etat_categorie').value = 'open';
        }
        break;
        
      case 'open':
        for(i=0;i<$('nb_categorie').value;i++){
          $('div'+i).style.display = 'none';
          $('img'+i).src = '/images/droite.png';
          $('img_etat').src = '/images/plus.png';
          $('etat_categorie').value = 'close';
        }
        break;
    }
  }
  else{
    switch($('div'+num).style.display){
      case 'none':
        $('div'+num).style.display = 'inline';
        $('img'+num).src = '/images/bas.png';
        break;
        
      case 'inline':
        $('div'+num).style.display = 'none';
        $('img'+num).src = '/images/droite.png';
        break;
    }
  }
}


function afficheLayerBlog(e,num){
  var DocRef;    // Variable pour IE uniquement
  
  //alert(e);
  // L'événement est passée à la fonction
  // donc tous sauf IE…
  if(navigator.appName=="Microsoft Internet Explorer"){                     // Dans ce cas on obtient directement la position dans la page
    Mouse_X = event.clientX;
    Mouse_Y = event.clientY;
    
    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
      DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est réfèrence
    else
      DocRef = document.body;                    // Dans ce cas c'est body qui est réfèrence

    //-- On rajoute la position liée aux ScrollBars
    Mouse_X += DocRef.scrollLeft;
    Mouse_Y += DocRef.scrollTop;
  }
  else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
  }
  
  $("layer"+num).style.top = (Mouse_Y+20)+"px";
  $("layer"+num).style.left = (Mouse_X+20)+"px";
  $("layer"+num).show();
}
/****************************************************************************/

  /* impossible d'arriver à récupérer la bonne valeur
     voulais l'utiliser dans subscription/setValeurs
function getRadioValue(radioName)
{
  var radio = document.getElementByTagName(radioName);
return "klhljghklj";
 var ret='m';
  return ret+radio.length;
for (var i=0; i<radio.length; i++)
  if (radio[i].checked) { alert radio[i].value; return radio[i].value; }
return '';
}
*/


/****************************************************************************/

//------------------------------------------------------------------------------
// dimensions utiles du navigateur
//http://www.codingforums.com/showthread.php?t=77296
function getBrowserWidth(){
var w;
if(document.innerWidth){ w=document.innerWidth;
} else if(document.documentElement.clientWidth){ w=document.documentElement.clientWidth;
} else if(document.body){ w=document.body.clientWidth; }
return w;
}
function getBrowserHeight(){
var h;
if(document.innerHeight){ h=document.innerHeight;
} else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight;
} else if(document.body){ h=document.body.clientHeight; }
return h;
}


if($('tetiere_module_menu')){
  $('tetiere_module_menu').hide();
  $('tetiere_module_menu').show();
}
