var newWin = null;
function popUp(strURL,strWidth,strHeight,strScrollbars) {
	if (newWin !== null) {
		if(!newWin.closed) {
			newWin.close();
		}
	}
	var strOptions="";
	strOptions="toolbar=no,menubar=no,scrollbars="+strScrollbars+",resizable,location=no,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

function affiliation(page) {
	popUp(page, 567, 600, "yes");
}
function aide(page) {
	popUp(page, 567, 600, "yes");
}
function assurance(page) {
	popUp(page, 567, 600, "yes");
}
function cadeau(page) {
	popUp(page, 567, 620, "yes");
}
function charteq(page) {
	popUp(page, 567, 600, "yes");
}
function chartesecu(page) {
	popUp(page, 567, 600, "yes");
}
function cgv(page) {
	popUp(page, 567, 600, "yes");
}
function commande(page) {
	popUp(page, 567, 350, "yes");
}
function contact(page) {
	popUp(page, 567, 530, "yes");
}
function emploi(page) {
	popUp(page, 567, 400, "yes");
}
function faq(page) {
	popUp(page, 567, 600, "yes");
}
function fournisseur(page) {
	popUp(page, 567, 550, "yes");
}
function mention(page) {
	popUp(page, 567, 400, "yes");
}
function plansite(page) {
	popUp(page, 567, 300, "yes");
}
function presse(page) {
	popUp(page, 567, 550, "yes");
}
function publicite(page) {
	popUp(page, 567, 350, "yes");
}
function service(page) {
	popUp(page, 567, 500, "yes");
}
function guide(page) {
	popUp(page, 567, 530, "yes");
}
function noscompagnies(page) {
	popUp(page, 567, 480, "yes");
}
function financement(page) {
	popUp(page, 560, 600, "yes");
}
function popup_email(page,email){
	var url = page/* + '?ref=th&email=' + email*/;
	popUp(url,567, 600, "yes");
}

function eraseMail(oInput){
	if(oInput.value=='Adresse email') {
		oInput.value='';
	}
}
function fillTextMail(oInput){
	if(oInput.value==='') {
		oInput.value='Adresse email';
	}
}
function checkMail(str) {
	var patern = /^[_a-z0-9\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]{2,}\.)+([a-z]{2,}){1,}$/ ;
	return patern.test(str) ;
}

function checkNewsletterForm(oForm) {
	var parternInt = /^[0-9]+$/;     // Verif birthyear -> integer

/*
	if((oForm.civilite[0].checked==false) && (oForm.civilite[1].checked==false) && (oForm.civilite[2].checked==false)){
		window.alert("Merci de nous indiquer votre civilite");
		oForm.civilite[0].focus();
		return false;
	}
	if(oForm.prenom.value=="")  {
		window.alert("Veuillez entrer votre prenom");
		oForm.prenom.focus();
		return false;
	}
	if(oForm.nom.value=="")  {
		window.alert("Veuillez entrer votre nom");
		oForm.nom.focus();
		return false;
	}
	if(oForm.adresse.value=="") {
		window.alert("Veuillez entrer votre adresse");
		oForm.adresse.focus();
		return false;
	}
	if(oForm.codepostal.value=="") {
		window.alert("Veuillez entrer votre code postal");
		oForm.codepostal.focus();
		return false;
	}
	if(oForm.ville.value=="") {
		window.alert("Veuillez entrer votre ville");
		oForm.ville.focus();
		return false;
	}
	*/
	if(oForm.mail.value==="") {
		window.alert("Veuillez entrer votre email");
		oForm.mail.focus();
		return false;
	}
	if(!checkMail(oForm.mail.value)) {
		window.alert("Merci de nous indiquer une adresse email valide");
		oForm.mail.focus();
		return false;
	}
	if (parternInt.exec(oForm.year.value)===null) {
		window.alert("Merci de nous indiquer une annee de naissance valide");
		oForm.year.focus();
		return false;
	}
	/*
	if(!isNaN(oForm.year.value)) {
		window.alert("Merci de nous indiquer une annee de naissance valide");
		oForm.year.focus();
		return false;
	}
	*/
	if((oForm.partenaireoffre[0].checked===false) && (oForm.partenaireoffre[1].checked===false)) {
		window.alert("Merci de nous indiquer si vous souhaitez recevoir les offres des partenaires de Thalasseo");
		oForm.partenaireoffre[0].focus();
		return false;
	} else {
		//window.alert("formulaire valide");
		oForm.submit();
	}
}

// script de PUB
//window.onload = popOnce() ;

function popOnce () {
	var sTarget = "http://www.thalasseo.com/CS/enquete/" ;
	var sWinProps = "resizable=1,scrollbars=1,status=1,menubar=1,toolbar=1" ;
	var oExp = new Date() ;
	oExp.setTime(oExp.getTime() + (2*365*24*60*60*1000)) ;

	if (getCookie('pubTha1')==null) {
		if (popunder(sTarget, "thaPubWindow", sWinProps)) {
			setCookie('pubTha1', 1, oExp, "/") ;
		}
	}
}
function popunder (sUrl, sName, sProps) {
	var w = window.open(sUrl, sName, sProps) ;
	if (w!=null) {
		w.blur() ;
		window.focus() ;
		return true ;
	} else {
		return false ;
	}
}

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 getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset) ;
  if (endstr==-1) endstr = document.cookie.length ;
  return unescape(document.cookie.substring(offset, endstr)) ;
}
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 delCookie(name) {
  var oExp = new Date() ;
  oExp.setTime(oExp.getTime() - 1) ;
  var cval = getCookie(name) ;
  document.cookie = name + "=" + cval + "; expires=" + oExp.toGMTString() ;
}
