// Fonction ouvreFenetre (Pop Up)
// url,nom,dimx,dimy,menus,centrer,masque

var browser = 0; var version = parseInt(navigator.appVersion);
if (navigator.appName.substring(0,8) == "Netscape" && version > 3 ) browser = 1;
if (navigator.appName.substring(0,9) == "Microsoft" &&  version >= 4 ) browser = 1;
if (navigator.appName.substring(0,9) == "Microsoft" &&  version > 3 && navigator.appVersion.indexOf("Mac") > 0 ) browser = 1;

var newwindow;

function ouvreFenetre(url1,nom,dimx,dimy,menus,centrer,masque) {
  if (browser == 0 && navigator.appVersion.indexOf("Win") > 0) dimy=dimy-19;
  if (centrer == 2){ LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-dimx)):100;
                     TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-dimy)-75)):100;}
  if (centrer == 1){ LeftPosition=(screen.width)?(screen.width-dimx)/2:100;
                     TopPosition=(screen.height)?(screen.height-dimy)/2:100;}
       if (menus == 1) { featur = "toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,"; } 
  else if (menus == 2) { featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,"; }
  else if (menus == 3) { featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,"; }
  else if (menus == 4) { featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,"; }
                  else { featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,"; }
  featur = featur + "width="+ dimx + ",height=" + dimy + ",top="+TopPosition+",left="+LeftPosition+',screenX='+LeftPosition+',screenY='+TopPosition;
  if (masque == 1) { 
	  newwindow = window.open("",nom,featur); self.focus(); 
	  if(newwindow) { 
	  	newwindow.blur(); newwindow.location=url1;
	  } 
  }
  else { 
	newwindow = window.open(url1,nom,featur); 
		if (window.focus && newwindow) { 
			newwindow.focus();
		} 
  }
}


// Teste si formulaire de recherche non vide
function Recherche(requete) {
	if(requete=='Rechercher') return false;
	if(!requete) return false;
	return true;
}



// Fonction Flyer
// par Michel Poulain (La Shampoo)

var FlyerWin=new Date(); var gauche=0; var haut=0; 

function Flyer(image,largeur,hauteur,couleur,titre) {
	
	hauteur = (hauteur*1)-1; // to avoid vetical lift 
	largeur = (largeur*1)-2; // turn into numerical

	if( (screen.width-(largeur+gauche))<0 ) 
			{ gauche=0; haut=haut+200; }
	if( (screen.height-(hauteur+haut))<0 ) 
			{ gauche=0; haut=0; }

    FlyerWin++; page = window.open('about:blank',FlyerWin,
    'width='+largeur+',height='+hauteur+
    ',menubar=no,status=no,toolbar=no,scrollbars=no'+
    ',resizable=no,dependent=yes,left='+gauche+',top='+haut+
    ',screenX='+gauche+',screenY='+haut);

    setTimeout('AfficheFlyer("'+image+'","'+titre+
    '","'+largeur+'","'+hauteur+'","'+couleur+'")',20); 
    
	gauche=gauche+largeur; //window.focus();


}


function AfficheFlyer(image,titre,largeur,hauteur,couleur) {

    var contenu = "<HTML><HEAD><TITLE>"+titre+"</TITLE>\n"+
    '<BASE href="http://www.gay-party.net/"></HEAD>' + "\n" +
    '<BODY bgcolor="'+couleur+'" LEFTMARGIN="0" MARGINWIDTH="0" ' +
    'TOPMARGIN="0" MARGINHEIGHT="0"><CENTER>' + "\n" +
    '<IMG src="'+image+'" alt="'+titre+'" border="0" ' +
    'onclick="window.close()" title="Cliquez ici pour fermer">' + 
    "\n" +'</CENTER></BODY></HTML>';
    page.document.write(contenu);

}


// Teste si le pop est déjà affiché, sinon l'ouvre
function POPUP () {
	var deja = GetCookie('mailing'); 
	if(!deja) {
		SetCookie ('mailing', 1, 1); // Nb de jours sans popup après affichage
		ouvreFenetre('http://www.gay-party.net/mailing','Popup',300,200,3,1,0);
	}
}


// Enregistre les cookies
function SetCookie (name,value,days) {
	var expires = new Date ();
	expires.setTime(expires.getTime() + (days * 24 * 3600 * 1000));
	document.cookie = name + "=" + escape (value) + "; path=/; expires=" + expires.toGMTString() ;
}

// Récupère les cookies
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

// Récupère les valeurs des cookies
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return false;
}

