// -------------------------------------------------------------------------------
// Détection du navigateur
// -------------------------------------------------------------------------------
agt = navigator.userAgent.toLowerCase();
ver = parseInt(navigator.appVersion);
app = navigator.appName.toLowerCase();
isIE = (agt.indexOf('msie') != -1 || agt.indexOf('Microsoft') != -1) ? 1 : 0; 
isNS = (agt.indexOf('netscape') != -1 || app.indexOf('netscape') != -1) ? 1 : 0;
isIE4 = (isIE && ver == 4 && !(agt.indexOf('msie 5') != -1)) ? 1 : 0;
isIE5 = (isIE && (ver == 5 || agt.indexOf('msie 5') != -1)) ? 1 : 0;
isIE4Plus = (isIE && ver >= 4) ? 1 : 0;
isIE6 = (isIE && ver == 6) ? 1 : 0;
isNS4 = (isNS && ver == 4) ? 1 : 0;
isNS6 = (isNS && ver == 5) ? 1 : 0;
isNS6Plus = (isNS && ver >= 5) ? 1 : 0;
isWIN = (agt.indexOf('win') != -1) ? 1 : 0;
isMAC = (agt.indexOf('mac') != -1) ? 1 : 0;

/*
//Declaration de l'object popup_home
if (!isMAC) {
	popup_home=null;
}
//-->
*/


/*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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//valide le formulaire ajout d'une gamme
function valid_form_add_gamme() {

	if (document.form_add_gamme.form_nom_new_gamme.value<1) {
		window.alert("Veuillez entrer un nom de gamme.");
		return false;
	}
	return true;
}

//valide le formulaire ajout d'une sous-gamme
function valid_form_add_ssgamme() {
	if (document.form_add_ssgamme.form_nom_new_ssgamme.value<1) {
		window.alert("Veuillez entrer un nom de sous-gamme.");
		return false;
	} else {
		var indice=document.form_add_ssgamme.form_rattache_gamme.selectedIndex;
		if (indice<0) {
			window.alert("Veuillez sélectionner une gamme parent.");
			return false;
		}
		return true;
	}
	return true;
}

//valide le formulaire modification 
function valid_form_modif() {
	if (document.form_modif.form_new_nom.value<1) {
		window.alert("Veuillez rentrer un nom.");
		return false;
	}
	return true;
}

//valide le formulaire de recherche
function valid_form_recherche() {
	if (document.form_recherche_ssgamme.recherche_ssgamme.value<1) {
		window.alert("Veuillez rentrer un nom de sous-gamme.");
		return false;
	}
	return true;
}

//traite le formulaire ajout d'une gamme si les champs sont valides
function submit_form_add_gamme() {
		if (valid_form_add_gamme()) {	 
			document.form_add_gamme.submit();
		}
}

//traite le formulaire ajout d'une sous-gamme si les champs sont valides
function submit_form_add_ssgamme() {
		if (valid_form_add_ssgamme()) {	 
			document.form_add_ssgamme.submit();
		}
}

//traite le formulaire modification d'une gamme ou sous-gamme si les champs sont valides
function submit_form_modif() {
	if (valid_form_modif()) {
		document.form_modif.submit();
	}
}

function submit_form_recherche() {
	if (valid_form_recherche()) {
		document.form_recherche_ssgamme.submit();
	}
}

//affiche le tableau demandé
function aff_liste(id_liste,taille) {
	if (document.getElementById(id_liste).style.visibility=="visible") {
		document.getElementById(id_liste).style.height=0;
		document.getElementById(id_liste).style.visibility="hidden";
	} else {
		document.getElementById(id_liste).style.height=taille;
		document.getElementById(id_liste).style.visibility="visible";
	}
}

//affiche le cadre de commentaire lors des rollovers
function aff_cadre(id_cadre) {

}

//FONCTION DE CHANGEMENT DE L'IMAGE DU HEADER LORS DU CLICK SUR LES MENUS
function chg_img_haut (name_img, url_img) {
	roll_img= eval("document.images['"+name_img+"']");
	roll_img.src= url_img;
	
}



//FONCTION DE FERMETURE DU POPUP
/*
function close_popup(popup) {
    alert("close popup");
    if (popup) alert("popup");
    if (!popup.closed) alert("! popup closed");
    if (popup.open) alert("popup open");

    if (popup && !popup.closed && popup.open) {
        popup.close();
    }
}
*/
function close_popup() {
    if (top.menu.popup_home && !top.menu.popup_home.closed && top.menu.popup_home.open) {
        top.menu.popup_home.close();
    }
}



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_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

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 MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


/* cooper */
function chg_menu(row,newcolor)
{
	var c;
	for( c=0 ; c<row.cells.length ; c++ )
	{
		row.cells[c].style.backgroundColor = newcolor;
	}
}

//ouvre la notice
function ouvrir_notice(destination)
{
	window.open(destination,'Notice','width=628,height=500,top=10,left=10,scrollbars=yes');
}