//
// openPopUps v1.01 Copyright (c) 2006 openWebWare.com
// This copyright notice MUST stay intact for use.
//
// The perfect pop up window replacement for your advertisements and web 
// applications. Pop up blockers will fail to prevent an openPopUp window 
// from opening. 
//
// This library is free software; you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation; either version 2.1 of the License, or 
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
// License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along 
// with this library; if not, write to the Free Software Foundation, Inc., 59 
// Temple Place, Suite 330, Boston, MA 02111-1307 USA 

// CSS Diretory
//cssDir = "styles/";

// Images Directory
imageDir = "/images/popup/";

// Include Style Sheet
//document.write('<link rel="stylesheet" type="text/css" href="' +cssDir+ 'styles.css">\n');

/* ---------------------------------------------------------------------- *\
  Function    : JSWindow()
  Description : creates a new window
  Usage       : JSWindow("title", oContent, [x], [y], [id], [width])
  Arguments   : title    - The title of the window as displayed in the titlebar
	              oContent - The content of the Div called using getElementbyID
								x        - The number of pixels from the left the window appears when first open
								y        - The number of pixels from the top the window appears when first open
	              id       - The <div> this window will use for its content
                width    - The default width of the window                
\* ---------------------------------------------------------------------- */

function JSWindow(title, oContent, x, y, id, width, popupColor, minimizeIcon)
{
	
	// define variables
	this.title = title;
	this.oContent = oContent;
  this.width = width;
	this.x = x;
	this.y = y;
  this.id = id;
	this.bgcolor = popupColor;
	
	
	// create the table window and define CSS properties
	this.oTable = document.createElement("table");
  this.oTable.id = "Window " + this.id;
	this.oTable.style.width = this.width + "px";
	this.oTable.style.border = "1px solid #000000";
  this.oTable.cellSpacing = 0;
	this.oTable.cellPadding = 2;
	this.oTable.border = 0;
	this.oTable.style.backgroundColor = "#FFFFFF";

	// determine the windows position when first open
	this.oTable.style.position = "absolute";
	this.oTable.style.zIndex="100";
	this.oTable.style.left = this.x + "px";
	this.oTable.style.top = this.y + "px";

	// link from the table to the JSWindow object
	this.oTable.jsWindow = this;

	// if the table is clicked anywhere, show the table in front of other open windows
	this.oTable.onmousedown = JSWindow.prototype.onBringToFront;

	// append to document body
	document.body.appendChild(this.oTable);

	// add a row for the titlebar
	var oTR = this.oTable.insertRow(0);
	oTR.className = "JSWindowTitleStyle";
	
	
	// Title: add the title to the titlebar	
	oTD = oTR.insertCell(0);
	oTD.innerHTML = title;
	oTD.jsWindow = this;
	oTD.onmousedown = JSWindow.prototype.tdOnMouseDown;
	oTD.style.borderBottom = "1px solid #000000";
	oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	oTD.height = "20";
	oTD.width = "98%";
	
	// Minimize: add the minimize button to the titlebar
	if (minimizeIcon == 1) {
    this.oMinTD = oTR.insertCell(1);
	  this.oMinTD.innerHTML = "<img src='" + imageDir + "minimize.jpg'>";
	  this.oMinTD.onmousedown = JSWindow.prototype.onMinimize;
	  this.oMinTD.jsWindow = this;
    this.oMinTD.style.borderBottom = "1px solid #000000";
	  this.oMinTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
	  this.oMinTD.width = "1%";
	  this.oMinTD.style.paddingRight = "1px";	
  }
	
	// Close: add the close button to the titlebar
	if (minimizeIcon == 1) {
	  oTD = oTR.insertCell(2);
	}
	else {
	  oTD = oTR.insertCell(1); 
	}
	oTD.innerHTML = "<img src='" + imageDir + "close.jpg'>";
	oTD.jsWindow = this;
	oTD.onmousedown = JSWindow.prototype.onClose;
	oTD.style.borderBottom = "1px solid #000000";
	oTD.style.backgroundImage = "url(" + imageDir + "title_bg.jpg)";
  oTD.width = "1%";
	oTD.style.paddingLeft = "1px";
	
	// add a row for the window's content
	oTR = this.oTable.insertRow(1);
	
	this.oContentTD = oTR.insertCell(0);
	if (minimizeIcon == 1) {
	  this.oContentTD.colSpan = 3;
	}
	else {
	  this.oContentTD.colSpan = 2;
	}  
	this.oContentTD.style.backgroundColor = this.bgcolor;
	this.oContentTD.className = "JSWindowContentStyle";
 
 
	// use the content from the referenced div as the content for the window   //document.all["Div" + this.id].innerHTML;
	
var str = '<div style="margin-left:10px; padding-right:10px;">';
str += '<p style="font-size:14px;text-align:center"><strong>R&eacute;clamez votre livre GRATUIT !<br><i>Les d&eacute;lices de l\'alimentation vivante</i></strong><br><span style="font-size:12px;">de Jalissa Letendre</span></p>';
str += '<img class="imgr" src="http://www.aliv-e.com/images/popup/livre.jpg" width="110" height="160" align="Right" border="0" vspace="3" hspace="3">';
str += '<p><strong>Rien de plus simple!</strong> Remplissez, cliquez, et v&eacute;rifiez votre email!</p>';	
str += '<form name="oemProSubscription" method="post" action="http://smtp.aliv-e.com/oemp35/subscribe.php" style="text-align:right" onSubmit=\'if(this.FormValue_CustomField12.value=="0"){alert("S.V.P. Veuillez choisir un pays.");return false;};\'>';
str += 'Pr&eacute;nom: <input type="text" name="FormValue_CustomField14" style="width: 120px;"  /> <br />';
str += '<select name="FormValue_CustomField12" style="width: 160px;"><option value="0">Choisissez votre pays</option><option>Belgique</option><option>Canada</option><option>&Eacute;tats-Unis</option><option>France</option><option>Afghanistan</option><option>Afrique du Sud </option>      <option>Albanie</option>      <option>Alg&eacute;rie</option>      <option>Allemagne</option>      <option>Andorre</option>      <option>Angola</option>      <option>Anguille</option>      <option>Arabie Saoudite</option>      <option>Argentine</option>      <option>Arm&eacute;nie </option>      <option>Aruba</option>      <option>Ascension (Ile)</option>      <option>Australie</option>      <option>Autriche</option>      <option>Azerba&iuml;djan</option>      <option>Bahamas</option>      <option>Bahrein</option>      <option>Bangladesh</option>      <option>Belgique</option>      <option>Belize</option>      <option>B&eacute;nin</option>      <option>Bermudes</option>      <option>Bhoutan</option>      <option>Bolivie</option>      <option>Bosnie Herz&eacute;govine</option>      <option>Botswana </option>      <option>Br&eacute;sil </option>      <option>Brunei</option>      <option>Bulgarie</option>      <option>Burkina Faso</option>      <option>Burundi</option>      <option>Cambodge</option>      <option>Cameroun</option>      <option>Canada</option>      <option>Canarie (Iles)</option>      <option>Cap Vert (Iles)</option>      <option>Cayman</option>      <option>Centrafricaine </option>      <option>Chili</option>      <option>Chine (RP)</option>      <option>Chypre</option>      <option>Colombie</option>     <option>Comores</option>      <option>Congo</option>      <option>Cor&eacute;e du Sud </option>      <option>Cor&eacute;e du Nord</option>      <option>Costa Rica</option>      <option>C&ocirc;te d&rsquo;Ivoire</option>      <option>Croatie</option>      <option>Cuba</option>      <option>Danemark</option>      <option>Djibouti</option>      <option>Dominicaine (R&eacute;p)</option>      <option>Dominique</option>      <option>Egypte</option>      <option>El Salvador</option>      <option>Emirats Ar. Unis</option>      <option>Equateur</option>      <option>Erythr&eacute;e</option>      <option>Espagne</option>      <option>Estonie</option>     <option>Etats-Unis </option>      <option>Ethiopie</option>      <option>Falkand</option>      <option>Feroe</option>      <option>Fidji</option>     <option>Finlande</option>      <option>France</option>      <option>Futuna </option>      <option>Gabon</option>      <option>Gambie</option>      <option>G&eacute;orgie</option>      <option>Ghana</option>      <option>Gibraltar</option>      <option>Grande Bretagne</option>      <option>Gr&egrave;ce</option>     <option>Groenland</option>      <option>Guadeloupe</option>      <option>Guam</option>      <option>Guatamela</option>      <option>Guin&eacute;e</option>     <option>Guin&eacute;eEquatoriale</option>      <option>Guyana</option>      <option>Guyane Fran&ccedil;aise</option>      <option>Ha&iuml;ti</option>      <option>Hawai</option>     <option>Honduras</option>      <option>Hong Kong</option>      <option>Hongrie</option>      <option>Inde</option>      <option>Indon&eacute;sie</option>     <option>Iran</option>      <option>Iraq</option>      <option>Irlande</option>      <option>Islande</option>      <option>Isra&euml;l</option>      <option>Italie</option>     <option>Jama&iuml;que</option>      <option>Japon</option>      <option>Jordanie</option>      <option>Kazakhstan</option>      <option>Kenya</option>     <option>Kowe&iuml;t</option>      <option>Laos</option>      <option>Lesotho</option>      <option>Lettonie</option>      <option>Liban</option>     <option>Lib&eacute;ria</option>      <option>Libye</option>      <option>Lithuanie</option>      <option>Luxembourg</option>      <option>Macao</option>     <option>Mac&eacute;doine</option>      <option>Madagascar</option>      <option>Malaisie</option>      <option>Malawi</option>      <option>Mali</option>     <option>Malte</option>      <option>Maroc</option>      <option>Martinique</option>      <option>Maurice</option>      <option>Mauritanie</option>     <option>Mayotte</option>      <option>Mexique</option>      <option>Monaco</option>      <option>Mozambique</option>      <option>N&eacute;pal </option>     <option>Nicaragua</option>      <option>Niger</option>      <option>Nig&eacute;ria</option>      <option>Norv&egrave;ge</option>      <option>Nlle Cal&eacute;donie</option>     <option>Nouvelle Z&eacute;lande</option>      <option>Oman</option>      <option>Ouganda</option>      <option>Ouzb&eacute;kistan</option>      <option>Pakistan </option>     <option>Panama</option>      <option>Paraguay</option>      <option>Pays Bas</option>      <option>P&eacute;rou</option>      <option>Philippines</option>     <option>Pologne</option>      <option>Polyn&eacute;sie Fran&ccedil;aise</option>      <option>Portugal</option>      <option>Porto Rico</option>      <option>Qatar </option>     <option>R&eacute;union</option>      <option>Roumanie</option>      <option>Russie</option>      <option>Rwanda</option>      <option>S&eacute;n&eacute;gal </option>     <option>Seychelles</option>      <option>Sierra L&eacute;one </option>      <option>Singapour</option>      <option>Slovaquie</option>      <option>Slov&eacute;nie</option>     <option>Somalie</option>      <option>Soudan</option>      <option>Sri Lanka</option>	  <option>St Martin</option>      <option>St Pierre Miquelon</option>	 <option>Su&egrave;de</option>      <option>Suisse</option>      <option>Suriname</option>      <option>Swaziland</option>      <option>Syrie</option>     <option>Tadjikistan</option>      <option>Ta&iuml;wan </option>      <option>Tanzanie</option>      <option>Tchad</option>      <option>Tch&egrave;que R&eacute;p.</option>     <option>Thailande</option>      <option>Togo</option>      <option>Tonga</option>      <option>Tunisie</option>      <option>Turquie</option>     <option>Ukraine</option>      <option>Uruguay</option>      <option>Vatican</option>      <option>V&eacute;n&eacute;zu&eacute;la</option>      <option>Vietnam </option>     <option>Walliset Futuna </option>      <option>Yemen</option>      <option>Yougoslavie</option>      <option>Za&iuml;re</option>      <option>Zambie</option>     <option>Zimbabw&eacute;</option>      <option>Autre pays</option></select> <br>';
	
str += 'Email:  <input type="text" name="FormValue_Email" style="width: 131px;" /> <br />';
str += '<input type="hidden" name="FormValue_MailListIDs[]" value="1"><input type="hidden" name="lastname" value="-" /><input type="hidden" name="FormValue_SuccessScreenID" value="MTg%3D"><input type="hidden" name="FormValue_FailureScreenID" value="Mg%3D%3D">';
str += '<input type="submit" name="Subscribe" style="background:#4B66AB;border:1px solid #bebebe;color:#ffffff;" onmouseover="this.style.backgroundColor=\'#35488A\';" onmouseout="this.style.backgroundColor=\'#4B66AB\';" value="Soumettre &raquo;" />&nbsp;&nbsp;&nbsp;';	
str += '</form>';	
str += '<p>En prime: votre abonnement gratuit &agrave; <strong>Contact Sant&eacute;</strong>. La meilleure source d\'information en fran&ccedil;ais!</p>';	
str += '<p style="font-size:9px"><strong>Vie priv&eacute;e&nbsp;:</strong> <br>Votre adresse email ne sera jamais vendue, lou&eacute;e, ni pr&ecirc;t&eacute;e. Et vous pouvez vous d&eacute;sinscrire &agrave; tout moment, d\'un simple clic!</p>';	
str += '</div>';	
	
	this.oContentTD.innerHTML = str;
	
}

JSWindow.prototype.onBringToFront = function()
{
	this.jsWindow.bringToFront();
}

JSWindow.prototype.bringToFront = function()
{
	// if not already the last child of the document.body, make it so
	if ( document.body.childNodes[document.body.childNodes.length-1] !== this.oTable )
	{
		// move to bottom of document
		document.body.appendChild(this.oTable);
	}
}

JSWindow.prototype.tdOnMouseDown = function()
{
	this.jsWindow.onMouseDown();
}

JSWindow.prototype.onMouseDown = function()
{
	// record that an onmousedown has just occurred
	this.bDown = true;
	
	// link from body to this JSWindow object
	document.body.jsWindow = this;

	// save body mouse handlers
	this.saveMouseMove = document.body.onmousemove;
	this.saveMouseUp = document.body.onmouseup;

	// set new handlers.
	document.body.onmousemove = JSWindow.prototype.bodyOnMouseMove;
	document.body.onmouseup = JSWindow.prototype.bodyOnMouseUp;
}

JSWindow.prototype.bodyOnMouseMove = function(evt)
{
	var e = window.event ? window.event : evt;
	this.jsWindow.onMouseMove(e);
}

JSWindow.prototype.onMouseMove = function(evt)
{
	// if mouse not down, stop the move (for IE only)
	if ( (document.all) && !(evt.button & 1) )
	{
		this.onMouseUp();
		return;
	}
	if ( this.bDown )
	{
		this.dx = parseInt(this.oTable.style.left, 10) - evt.clientX;
		this.dy = parseInt(this.oTable.style.top, 10) - evt.clientY;
		this.bDown = false;
	}
	else
	{
		this.oTable.style.left = Math.max((this.dx + evt.clientX),0) + "px";
		this.oTable.style.top = Math.max((this.dy + evt.clientY),0) + "px";
	}
}

JSWindow.prototype.bodyOnMouseUp = function()
{
	this.jsWindow.onMouseUp();
}

JSWindow.prototype.onMouseUp = function()
{
	document.body.onmouseup = this.saveMouseUp;
	document.body.onmousemove = this.saveMouseMove;
	document.body.jsWindow = null;
}


JSWindow.prototype.onMinimize = function()
{
  this.jsWindow.minimize();
}



JSWindow.prototype.minimize = function()
{
	// hide the content
	this.oContent.style.visibility = "hidden";
	this.oContent.style.position = "absolute";
	document.body.appendChild(this.oContent);
	
	this.oTable.deleteRow(1);
	
	// save current position
	this.saveX = this.oTable.style.left;
	this.saveY = this.oTable.style.top;
	
  // get the "window bar"
	if ( !window.jsWindowBar )
	{
		window.jsWindowBar = document.createElement("span");
	  document.body.appendChild(window.jsWindowBar);
	}
	
	window.jsWindowBar.appendChild(this.oTable);
	this.oTable.style.position = "static";
	this.oTable.style.left = "0px";
	this.oTable.style.top = "0px";
	
	this.oMinTD.innerHTML = "<img src='" + imageDir + "maximize.jpg'>";
	this.oMinTD.onmousedown = JSWindow.prototype.onMaximize;
	this.oTable.style.width = "220px";
  this.oTable.style.borderBottom = "0px";
	
}


JSWindow.prototype.onMaximize = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.maximize = function()
{
	document.body.appendChild(this.oTable);
	this.oTable.style.position = "absolute";
	this.oTable.style.zIndex="100";
	
	this.oTable.style.left = this.saveX;
	this.oTable.style.top = this.saveY;
	this.oTable.style.width = this.width + "px"
	this.oTable.style.borderBottom = "1px solid #000000";
	
	// add the content again.
	oTR = this.oTable.insertRow(1);
	
  this.oContentTD = oTR.insertCell(0);
	this.oContentTD.colSpan = 3;
	this.oContentTD.innerHTML = document.all["Div" + this.id].innerHTML;
	
	//oTD.appendChild(this.oContent);
	this.oContent.style.position = "static";
	this.oContent.style.visibility = "visible";
	this.oContentTD.style.backgroundColor = this.bgcolor;
	this.oContentTD.className = "JSWindowContentStyle";
	
  this.oMinTD.style.paddingRight = "1px";	
	this.oMinTD.innerHTML = "<img src='" + imageDir + "minimize.jpg'>";
	this.oMinTD.onmousedown = JSWindow.prototype.onMinimize;

}

JSWindow.prototype.onMaximize = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.close = function()
{	
	// remove from browser document
	//this.oTable.parentNode.removeChild(this.oTable);
	this.oTable.style.display = "none";
}

JSWindow.prototype.onClose = function()
{
	this.jsWindow.close();
}



/* ---------------------------------------------------------------------- *\
  Function    : hideDiv()
  Description : Hides all Divs on the page.
  Usage       : hideDiv([divNumber])
  Arguments   : divNumber - The number of Divs in the page that must be hidden
\* ---------------------------------------------------------------------- */

function hideDiv(divNumber) {
	for (var count = 1; count <= divNumber;) {
    document.getElementById('Div' + count).style.display = 'none';
		count++;
	}
}



/* ---------------------------------------------------------------------- *\
  Function    : createWindows()
  Description : determines if Window already exists, else calls JSWindow
  Usage       : createWindows([windowID], [width], "title")
  Arguments   : windowID - The <div> this window will use for its content
                width    - The default width of the window
                title    - The title of the window as displayed in the titlebar
\* ---------------------------------------------------------------------- */

function createWindow(title, width, popupColor, windowID, minimizeIcon, x, y)
{
if (document.getElementById('Window ' + windowID)) {
  }
else {
  new JSWindow("&nbsp;" + title, document.getElementById("Div" + windowID), x, y, windowID, width, popupColor, minimizeIcon); 
  }
}

//<!-- START POPUP EBOOK -->
//var expDays = 1; // number of days the cookie should last
//var exp = new Date();
//exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

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 null;
}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}


function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function popupebook() {
//			createWindow('<font color=white>Recevez votre eBook gratuit!</font>', 350, '#E3AC31', 1, 1, 220, 140); //'#D6E1F5 C8DCEC'
	if (GetCookie("MailUser") == null) {
		if (GetCookie("ebookpopup") == null) {
			//SetCookie("ebookpopup", "y", exp);
			SetCookie("ebookpopup", "y");
			createWindow('<font color=white>Recevez votre eBook gratuit!</font>', 350, '#E3AC31', 1, 1, 220, 140);
		}
	}
}

//<!-- FINISH POPUP EBOOK -->

