function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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.0
  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 && document.getElementById) x=document.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 Is() {
    var agent   = navigator.userAgent.toLowerCase();
    this.major  = parseInt(navigator.appVersion);
    this.minor  = parseFloat(navigator.appVersion);
    this.ns     = ((agent.indexOf('mozilla')   != -1) &&
                  (agent.indexOf('spoofer')    == -1) &&
                  (agent.indexOf('compatible') == -1) &&
                  (agent.indexOf('opera')      == -1) &&
                  (agent.indexOf('webtv')      == -1));
    this.ns4    = (this.ns && (this.major      ==  4));
    this.ns6    = (this.ns && (this.major      >=  5));
    this.ie     = (agent.indexOf("msie")       != -1);
    this.ie3    = (this.ie && (this.major      <   4));
    this.ie4  	= (this.ie && (this.major >= 4));
    this.ie5    = (this.ie && (this.major      ==  4) &&
                  (agent.indexOf("msie 5.0")   != -1));
    this.ie6    = (this.ie && (this.major      ==  4) &&
                  (agent.indexOf("msie 6.0")   != -1));
    this.ieX    = (this.ie && !this.ie3 && !this.ie4);
}

var is = new Is();
var selmenu;
	
function layerObject(id,left) {
		if (is.ie5||is.ns6||is.ie6){
		this.obj = document.getElementById(id).style;
		this.obj.left = left;
		return this.obj;
		} else if(is.ie4) {
		this.obj = document.all[id].style;
		this.obj.left = left;
		return this.obj;
		} else if(is.ns4) {
		this.obj = document.layers[id];
		this.obj.left = left;
		return this.obj;
		}
}

function show(id)
{
	theobjs[id].objShow();
}
function hide(id)
{
	theobjs[id].objHide();
}
function smenuHide(id)
{
	//eventSrcId=(event.srcElement)?event.srcElement.id:"undifined";
	//eventType = "-"+event.type;
	//alert(eventSrcId + eventType);
	//menuHide(id);
	theobjs[id].objTimer = setTimeout("hide('"+id +"')",10);
}
function smenuShow(id)
{
	if ( theobjs[id].objTimer != null)
	{
		clearTimeout(theobjs[id].objTimer);
		theobjs[id].objTimer = null;
	}
	show(id);
}
function menuHide(id)
{
	if (!obj_exists(id)) { return false; }
	if(!is.ns4) {
	theobjs[id].objTimer = setTimeout("hide('"+id +"')",50);
	}
}

function menuShow(id)
{
	if (!obj_exists(id)) { return false; }
	if(is.ns4) {
		HideLayers();
	}
	else {
		if ( theobjs[id].objTimer != null) {
			clearTimeout(theobjs[id].objTimer);
			theobjs[id].objTimer = null;
		}
	}
	show(id);
}

function obj_exists(id) {
  return (typeof(theobjs) == 'undefined') ? false : (typeof(theobjs[id]) == 'undefined') ? false : true;
}

function init() {
	create_objects();
}

function layerSetup() {
	  if (MM_findObj('option1Div')) { centerLyr1 = new layerObject('option1Div', (available_width-772)/2+615); show('option1Div'); }
		if (MM_findObj('option2Div')) { centerLyr2 = new layerObject('option2Div', (available_width-772)/2+615); show('option2Div'); }
		if (MM_findObj('option3Div')) { centerLyr3 = new layerObject('option3Div', (available_width-772)/2+615); show('option3Div'); }
		if (MM_findObj('option4Div')) { centerLyr4 = new layerObject('option4Div', (available_width-772)/2+615); show('option4Div'); }
		if (MM_findObj('option5Div')) { centerLyr5 = new layerObject('option5Div', (available_width-772)/2+615); show('option5Div'); }
		if (MM_findObj('option6Div')) { centerLyr6 = new layerObject('option6Div', (available_width-772)/2+615); show('option6Div'); }
		if (MM_findObj('option7Div')) { centerLyr7 = new layerObject('option7Div', (available_width-772)/2+615); show('option7Div'); }
}


// code pour agrandissement/rapetissement des photos produit
var timer = new Array();

function rapetissement(id_photo, ratio) { 
	clearInterval(timer[id_photo]);
	timer[id_photo]=setInterval("moins('"+id_photo+"', "+ratio+");",50);
}

function moins(id_photo, ratio) {
  p=document.images[id_photo] ;
	p.width-=10;
	p.height = Math.round(p.width/ratio);
	if (p.width<=129) {
	  clearInterval(timer[id_photo]);
	}
}

function agrandissement(id_photo, ratio) { 
	clearInterval(timer[id_photo]);
	timer[id_photo]=setInterval("plus('"+id_photo+"', "+ratio+");",10);
}

function plus(id_photo, ratio) {
  p=document.images[id_photo] ;
	p.width+=10;
	p.height = Math.round(p.width/ratio);
	if (p.width>=200) {
	  clearInterval(timer[id_photo]);
	}
}

function ValideFormProduit(form) {
	if (form.elements['cref'].selectedIndex < 1) {
		alert('Vous devez préciser votre choix');
		return false;
	} else {
	  return true;
  }
}

function OpenKiala(code_postal) {
  var haut = 515;
  var larg = 650;
  var top=(screen.height-haut)/2;
  var left=(screen.width-larg)/2;
  var url = '/kiala/kiala.php';
  if (typeof(code_postal) != 'undefined') {
    if (code_postal == 'pres') { url += '?action=pres'; }
    else if (code_postal != '') { url += '?action=rech_cp&cp='+code_postal; }
  }
  window.open(url,'kiala','top=' + top + ',left=' + left + ',width=' +larg+ ',height=' + haut + ',' + 'scrollbars=yes');
}

//------------------------ Modifications Ad'oc 2007-01 --------------------------------------
function verif_cp() {
  result = false;
  code_postal = document.forms['form_kiala_cp'].elements['cp'].value;
  code_postal_str = code_postal + '';
  if (code_postal=='') { 
    alert('Vous devez indiquer votre code postal'); 
  } else if (isNaN(code_postal) || (code_postal_str.length != 5)) {
    alert('Le code postal doit être un nombre de 5 chiffres'); 
  } else {
    result = true;
  }
  return result;
}

function ValideFormRecherche(form) {
  cref = form.elements['cref'].value;
	rub = form.elements['rub'].value;
	if ((cref != '') && (rub != '')) {
	  alert('Vous devez remplir un seul des deux champs du formulaire de recherche');
	  return false;
	} else if ((cref == '') && (rub == '')) {
	  alert('Vous devez remplir un des deux champs du formulaire de recherche');
	  return false;
	} else if (cref != '') {
	  if (isNaN(cref)) {
		  alert('La référence de l\'article doit être un nombre');
			return false;
		} else {
		form.action = '/boutique/art.php';
	  }
	} else if (rub != '') {
	  form.action = '/boutique/resultat.php';
	}
	return true;
}

//---------------------------- Fin Modifications ----------------------------------------------