var faq;
// **************************************
// Suivi Insight XE
// Variables et fonctions
//
// ATTENTION : mise à jour de global.js
//
// **************************************

// ajout popunder 23 02 05
// ajout variables simulation et envoi data

// variables spécifiques à Insight
	var mep1="";				// data renvoyées sur Insight	
	var if_Site_ID="finaref";	
	var if_protocol=window.location.protocol; 
	var if_sid="1";
	
// variable pour suivi générique
	var sOrigine="";			// origine : data cookie 21 jours
	var sEvent="";				// événement - valeur == sOrigine
	var pathname="";			// répertoire
	var fichier="";				// nom fichier
	var categorie="";			// categorie
	var rubrique="";			// rubrique (variable url)
	var produit="";				// produit (variable url)
	var flagIdent="";			// true or false
	
// variables pour suivi specifique -- questionnaires	
	var n_client 	= "";
	var nom 		= "";
	var prenom 		= "";
	var code_p 		= "";
	var date_naiss 	= "";
	var email 		= "";
	// ajout if_xtransCategory= et if_xtransItem=
	
//	data pour suivi specifique -- faq
	var listCat 	= "";		// liste des catégories (variable url)
	var listRub		= "";		// liste des rubriques (variable url)
	var quest		= "";		// liste des questions (variable url)
	// + ajout Billboard attribute if_nt_LISTCAT, if_nt_LISTRUB, if_nt_QUEST
	
// variables pour suivi specifique -- simulateur
	var simu_prop	= "";
	var simu_rea	= "";
	// + ajout Billboard attribute if_nt_SIMULATEUR
	

// variables pour fonctions annexes	
	var dte=new Date;			//
	var madate = jjmmaaaa(dte); // date format jjmmaaaa pour enregistrement transaction
// fonction date format jjmmaaaa
// ** formatage date pour enregistrement des transactions
	
// variable pour désactiver le menu haut
// pour un message particulier sur une page précise, il faut la redéfinir dans la page même
	var message = 'Voulez-vous vraiment annuler votre opération ?';
	
function jjmmaaaa(datefull){ 			
			return (datefull.getDate()<10?"0"+datefull.getDate():datefull.getDate())+(datefull.getMonth()<9?"0"+(datefull.getMonth()+1):datefull.getMonth()+1)+datefull.getFullYear();
			} 

	
	
	var insight_var = "";		// variable pour fonction debug
	var WWS_var = "";		// variable pour fonction debug

	//scrollit(100);
	//Exécution du jeu "T'es beau t'es disco"
//loadPopup()
	
// fonction debug
// ** affichage mep1 pour debug

function debug_insight() { 
			  //insight_var = mep1;
			  //insight_var = "<br><b>mep1 :</b><br>" + insight_var + " <br><br><b>Data cookie :</b><br> " + getCookieVal();
			} 

// **************************************


function afficheFaq (url) {			
	if(faq == undefined){				
		faq = window.open(url,'f','scrollbars=yes,resizable=yes,width=515,height=500');
	}else{
		faq.close();
		faq = window.open(url,'f','scrollbars=yes,resizable=yes,width=515,height=500');
	}
}
	
function MM_swapImgRestore() {
  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_preloadImages() {
  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_findObj(n, d) {
  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() {
  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 MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function MM_openBrWindow_jeu(theURL,winName,features) {
  f = window.open(theURL,winName,features);
  f.blur();
  window.focus();
}


function popupwindow(nomfichier, w, h) {
	var a;
	a=window.open(nomfichier, 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + w +',height=' + h);
}

/*function MM_openBrWindow_jeu(theURL,winName,features) {
  f = window.open(theURL,winName,features);
  //f.blur();
  //window.focus();
}*/

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function EcrireCookie(nom, valeur)
{
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.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=nom+"="+escape(valeur)+
	((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 lireCookie(nom){
   var arg=nom+"=";
   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 effaceCookie(nom){
	date=new Date;
	date.setFullYear(date.getFullYear()-1);
    EcrireCookie(nom,null,date);
}

function queryParam(chaine, nom, separateur){	
	var temp='';
	var i=chaine.indexOf(nom+'=') + nom.length+1;	
	while ((chaine.charAt(i) != separateur) && (i != chaine.length)){			
		temp += chaine.charAt(i);
		i++;
		if(i==100) break;
	}
	temp.replace(separateur, '');	
	return temp;
}


function scrollit(seed) {
			var msg = 'Découvrez une offre exceptionnelle jusqu\'au 9 octobre en cliquant dans le menu sur le bouton \"Offre spéciale\" !!!';
			var out = " ";
			var c = 1;
			if (seed > 100) {
			seed--;
			cmd="scrollit("+seed+")";
			timerTwo=window.setTimeout(cmd,100);
		}else if (seed <= 100 && seed > 0) {
			for (c=0 ; c < seed ; c++) {
			out+=" ";
		}
			out+=msg;
			seed--;
			window.status=out;
			cmd="scrollit("+seed+")";
			timerTwo=window.setTimeout(cmd,100);
		}
		else if (seed <= 0) {
			if (-seed < msg.length) {
				out+=msg.substring(-seed,msg.length);
				seed--;
				window.status=out;
				cmd="scrollit("+seed+")";
				timerTwo=window.setTimeout(cmd,100);
			}
		else{
			window.status=" ";
			timerTwo=window.setTimeout("scrollit(100)",100);
		}
	}
}

function loadPopup(){
	if(lireCookie('POPUPJEU') != '1'){
		EcrireCookie('POPUPJEU', '1');
		MM_openBrWindow_jeu('http://www.finaref.fr/emailing/200801_tbeautdisco.html','tbeautdisco','top=10,left=120,width=990,height=640,statusbar=yes,menubar=yes,toolbar=yes,titlebar=yes');
	}
}
		
function decision(){	
	if(confirm(message)){
		return true;
	}else{
		return false;
	}
}
