// **********************************
// * Fonctions ouvertures de popUps *
// **********************************

// Détail du vin
function DetailWindow(str)
{
var adresse
adresse = "../popup/detail.asp?ref="+str
window.open(adresse,"detail","status=no,scrollbars=yes,height=600,width=540,top=60,left=140")
}

// Détail Assortiment
function DetailAssort(str)
{
var adresse
adresse = "../popup/assort.asp?ref="+str
window.open(adresse,"assort","status=no,scrollbars=yes,height=600,width=540,top=60,left=140")
}

// Fiche infos
function FicheWindow(adresse)
{
window.open(adresse,"fiche","status=no,scrollbars=yes,height=350,width=450,top=60,left=140")
}

// ***********************************
// * Fonctions de contrôle de champs *
// ***********************************

// Vérification de l'email
function verifEmail(str)
{
var a=str
var test="" + a;
	for(var k = 0; k < test.length;k++)
	{
	var c = test.substring(k,k+1);
		if(c == "@")
		{return false;}
	}
alert("Adresse Email incorrecte");
return true;
}

// Vérification du numero telephone
function verifTel(num)
{
var a=parseFloat(num)
	if (isNaN(a)==false && num.length==10)
	{return false;}
alert("Numéro de téléphone incorrect (ex: 0325385091)");
return true;
}

// Vérification du code postal
function verifCP(num)
{
var a=parseFloat(num)
	if (isNaN(a)==false && num.length==5)
	{return false;}
alert("Code postal incorrect (5 chiffres)");
return true;
}

// ********************************
// * Fonctions d'affichages       *
// ********************************

// Fonctions d'affichage de layers
function MM_findObj(n, d) { //v3.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); return x;
}

function MM_showHideLayers() { //v3.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; }
}

// Fonction de la bulle d'aide
var IB=new Object;
var posX=0;posY=0;
var xOffset=10;yOffset=8;
function AffBulle(texte) {
  contenu="<TABLE border=0 cellspacing=0 cellpadding="+IB.NbPixel+"><TR bgcolor='"+IB.ColContour+"'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='"+IB.ColFond+"'><TR><TD><FONT size='-1' face='arial' color='"+IB.ColTexte+"'>"+texte+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";

if(navigator.appVersion.indexOf("MSIE")>0){
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=event.y+yOffset;
    document.getElementById("bulle").style.left=event.x+xOffset;
    document.getElementById("bulle").style.visibility="visible";
}else{
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset+'px';
    document.getElementById("bulle").style.left=posX+xOffset+'px';
    document.getElementById("bulle").style.visibility="visible";
}
}
function getMousePos(e) {
  posX=e.pageX;
  posY=e.pageY;
}
function HideBulle() {
	document.getElementById("bulle").style.visibility="hidden";
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) {
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
  if(navigator.appVersion.indexOf("MSIE")<0)document.onmousemove=getMousePos;
  document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
}

// Fonction Message status
var msg="MESSAGE";
var index=0;
var delay=200

function defil() {
	// Fonction récursive pour le décalage du texte du message
	var nb_char=msg.length;
	index++;
	if (index>nb_char) index=0;
	window.status=msg.substring(index)+msg;
	setTimeout("defil()",delay);
}

function defiler(txt,tps) {
	//Cette fonction est appelée pour déclencher le défilement.
	msg=txt + "   -   " + txt + "   -   " ;
	delay=tps;
	defil();
}

//Fonction de recuperation données cookies
function donnecookie(nom)
{
  var recherche=nom+'=';                    // pour recherche nom dans la liste
  if (document.cookie.length>0)             // si il existe des cookies
  {
    position=document.cookie.indexOf(recherche);   // donne la position du nom
    if (position!=-1)                              // si une position existe
      {
        position=position+recherche.length;        // on passe après nom=
        fin=document.cookie.indexOf(';',position); // on cherche la fin (";")
        if (fin==-1)                               // si le ";" n'existe pas
        {
          fin=document.cookie.length;       // alors le cookie va jusqu'au bout
        }
        return unescape(document.cookie.substring(position,fin));// donne texte
      }
      else {return '';}                     // retourne du 'vide'
  }
  else {return '';}                         // retourne du 'vide'
}

//Fonction d'ecriture du cookie
function ecritcookie(texte, jours)
{
  var datecourante=new Date();              // lit la date
  var expires=new Date();
  expires.setTime(datecourante.getTime()+1000*60*60*24*jours);
  document.cookie=texte+'; expires='+expires.toGMTString();
}

function shtmblock(d){
	var o = document.getElementById(d);
	var i = document.getElementById(d+'img');
	if(o.style.display==''){
		o.style.display='none';
		i.src='/images/plus.gif';
	}else{
		o.style.display='';
		i.src='/images/moins.gif';
	}
	
	
}

function shtmnavigl(pm,pc,surl,prm){
	var str='';
	var shtml='';
	
	for(var i=1;i<=pm;i++){
		if(i==pc){
			str+='<td width=14 align=center class=normal><div style="width:18px;height:16px;overflow:hidden;border:1px solid #000000;background:#FAFAFA;"><b>'+i+'</b></div></td>';
		}else if(pc-i<3&&i-pc<3){
			str+='<td width=14 align=center class=htmfocus><div style="width:18px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;"><a href="'+surl+'?page='+i+prm+'" class=lien>'+i+'</a></div></td>';
		}
	}
	
	if(pc>3){
		str='<td width=14 align=center class=htmfocus><div style="width:18px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;"><a href="'+surl+'?page=1'+prm+'" class=lien>1</a></div></td><td class=htmfocus><div style="width:18px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page='+(pc-3)+prm+'" class=lien>...</a></div></td>'+str;
	}
	if(pm-pc>2){
		str+='<td class=htmfocus><div style="width:18px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page='+(pc+3)+prm+'" class=lien>...</a></div></td><td width=14 align=center class=htmfocus><div style="width:18px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;"><a href="'+surl+'?page='+pm+prm+'" class=lien>'+pm+'</a></div></td>';
	}
	
	if(pm>1){
		shtml+='<table border=0 align=right height=14 cellpadding=0 cellspacing=4><tr>';
		if(pc!=1){
			shtml+='<td class=htmfocus><div style="width:40px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page=1'+prm+'" class=lien>début</a></div></td>';
			shtml+='<td class=htmfocus><div style="width:65px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page='+(pc-1)+prm+'" class=lien>précédent</a></div></td>';
		}
		shtml+=str;
		if(pc<pm){
			shtml+='<td class=htmfocus><div style="width:65px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page='+(pc+1)+prm+'" class=lien>suivant</a></div></td>';
			shtml+='<td class=htmfocus><div style="width:40px;height:16px;overflow:hidden;border:1px solid #992222;background:#FAFAFA;" align=center><a href="'+surl+'?page='+pm+prm+'" class=lien>fin</a></div></td>';
		}
		shtml+='</tr></table>';
	}
	return shtml;
}