
var PopUpWindow;
function PopUp(src,name,width, height, screenx, screeny, scrollbar, resize, toolbar, status, menubar, location, directories) {
	var size, pos;
	size = '';
	pos = '';
	if (width > 0)		size = ',width='+width;
	if (height > 0)		size = size + ',height='+height;
	if (screenx >= 0)	pos = ',screenX='+screenx+',left='+screenx;
	if (screeny >= 0)	pos = pos + ',screenY='+screeny+',top='+screeny;
	scrollbar = (scrollbar == 1)?'yes':'no';
	resize = (resize == 1)?'yes':'no';
	toolbar = (toolbar == 1)?'yes':'no';
	status = (status == 1)?'yes':'no';
	menubar = (menubar == 1)?'yes':'no';
	location = (location == 1)?'yes':'no';
	directories = (directories == 1)?'yes':'no';
	//Ouverture de la pop-up
	//PopUpWindow = 
	window.open(src, name,'scrollbars='+scrollbar+',resizable='+resize+',toolbar='+toolbar+',status='+status+',menubar='+menubar+',location='+location+',directories='+directories+size+pos);
	//if (PopUpWindow != null)
	//	PopUpWindow.focus();

}
function checkDroitNav(id) {
	if (confirm("Cette page est réservée aux personnes majeures.\nSi vous n\'êtes pas majeur, cliquez sur Annuler.\nContinuer ?")) {
		
			document.location.href=id;
															
	}
}	

// retardateur = servira a enchainer les defilements
	var retardateur;
// encours = donne l'etat du defilement
	var encours = false;
// delaiattente = delai d'attente entre 2 passages du texte
	var delaiattente = 130;
// marge = emplacement ou demarre le texte
	var marge = 50;
// message= variable contenant le message      
	var message;
// cette fonction permet de faire demarrer le texte plus loin que la gauche de la barre d'etat
// elle peut etre supprimee mais le defilement ne permettra pas la lecture du debut du message       

var text1 = '';
var text2 = '';

function defileur(texte)
{
	var i = 0;
	var Mess=new Array();

    for (i = 0; i <= 20; i++)
    {       
        //text1 = text1 + '1.000 € à GAGNER sur Cdiscount  +  2.000 BONS D\’ACHAT!! Envoyez JACKPOT au 72626 (0,5€/envoi +1 SMS)-1 gain tous les 15 SMS!                                                       ';
        //text1 = text1 + 'EXCEPTIONNEL !!! - 10% DE REMISE sur votre première commande réglée avec la CARTE CDISCOUNT. Offre soumise à conditions. DEMANDEZ-LA vite au N°Azur 0810 106 206 (prix d\’un appel local).                                ';
        //text1 = text1 + 'DU JAMAIS VU !!! 100€ OFFERTS pour toute ouverture d\’un compte CARTE CDISCOUNT. Offre soumise à conditions. DEMANDEZ-LA vite au N°Azur 0810 106 206 (prix d\’un appel local).                                 ';
        //text1 = text1 + 'Exceptionnel ! 1 gagnant tous les 15 participants. Envoyez CASH au 7 26 26 (coût d\’un SMS + 0.5€) et tentez de gagner l\’un des nombreux bons d\’achats de 1000€. (déjà plus de 5000 gagnants !)                                ';
        //text1 = text1 + 'Exceptionnel ! 1 gagnant tous les 30 participants. Envoyez JACKPOT au 7 26 26 (coût d\’un SMS + 0.5€) et tentez de gagner l\’un des nombreux bons d\’achats de 1000€. (déjà plus de 5000 gagnants !)                                ';
        //text1 = text1 + 'Incroyable : 1 gagnant tous les 30 participants. Envoyez JACKPOT au 7 26 26 (coût d’un SMS+0.5€) (déjà plus de 15 000 gagnants !) et tentez de gagner l’un des nombreux bons d’achat de 1000€.                                 ';
        //text1 = text1 + '--- Bon plan Cdiscount: 250 Cartes de Visite GRATUITES + 5 produits GRATUITS - rendez-vous vite sur www.vistaprint.fr/sms1 ---                                 ';
        //text1 = text1 + '--- Bon plan Cdiscount: 6 produits GRATUITS sur www.vistaprint.fr/sms1  -   durée limitée! ---                                 ';
        //text1 = text1 + 'ATTENTION ! Des sms sont envoyés par STARPOST annonçant un gain sur Cdiscount. N\'APPELEZ PAS !!!!! Ce message mensonger n\'est pas envoyé par Cdiscount                                  ';
        //text1 = text1 + 'Incroyable : 1 gagnant tous les 30 participants. Envoyez CASH au 7 26 26 (coût d&39;un SMS+0.5€) (déjà plus de 15 000 gagnants !) et tentez de gagner l&39;un des nombreux bons d&39;achat de 1000€.                                 ';
        text1 = text1 + 'Cdiscount : Envoyez JACKPOT au 72626 (prix un SMS+0.50E) et tentez de gagner des bons de 1000Euros ';
    } 

    Mess[0]= text1;
    //Mess[1]= text2
    //Mess[2]= 'ici le texte 3'
    MessNb = Math.round(Math.random() * (Mess.length-1));

    message = Mess[0]; //Mess[MessNb];
    for (i = 0 ; i < marge ; i++)
        message = " " + message;
    encours = true;
    retardateur = window.setTimeout("defilement(0)",delaiattente);
}

// cette fonction est le defilement a proprement parler
function defilement(position)
{
	encours = false;
	if (position < message.length) window.status = message.substring(position, message.length);
	else position = -5;
	++position;

	encours = true;
	retardateur = window.setTimeout("defilement("+position+")",delaiattente);
}
defileur();
	

//////////////////////////////////////////////////////////////////////////////
//			 Fonction horloges pour ventes flash (TV)						//
//////////////////////////////////////////////////////////////////////////////

function formatageDate(chaine) {
	var resultat;
 	if (chaine<=9) {
 		resultat="0"+chaine;
	}
	else {
		resultat = chaine;
	}
	return resultat;
}

function calculdiff(idclock,datedeb,datefin,op) {
	var T1=datedeb.split('-');
	var T2=datefin.split('-');

	var NewDateDeb = new Date('20' + T1[0] + '/' + T1[1] + '/' + T1[2] + ' ' + T1[3] + ':' + T1[4] + ':' + T1[5]);
	var NewDateFin = new Date('20' + T2[0] + '/' + T2[1] + '/' + T2[2] + ' ' + T2[3] + ':' + T2[4] + ':' + T2[5]);

	var Diff = Math.floor((NewDateFin - NewDateDeb)/1000);
	
	//Gestion du probl? de fin de mois dans le calcul de la date
	//if ((T1[1] == '05' && T2[1] == '06')||(T1[1] == '08' && T2[1] == '09')) {
	//	Diff = Diff + 86400
	//	}
	//if ((T1[1] == '06' && T2[1] == '07')||(T1[1] == '09' && T2[1] == '10')) {
	//	Diff = Diff - 86400
	//	}
		
    if (datefin=='') Diff = 0;
	affReste(idclock,Diff,op);
}

function affReste(idclock,reste,op) {
	var texte = '';
	var id_clock = 'clock' + idclock;
	//On garde le temps restant pour le timeout
	var sec_reste = reste - 1;
	
	//On transforme les secondes en date j/hh/mm/sec
	var j;
	var h;
	var m;
	var s;
	var tps = reste - 1;

 	if (tps>3600) { 
  		h=Math.floor(tps/3600);
 		tps=tps % 3600;
  	}
  	else {
  		h=0;
  	}

  	if (tps>60) { 
  		m=Math.floor(tps/60);
  		tps=tps % 60;
  	}
  	else {
  		m=0;
  	}

 	s=Math.floor(tps);

	//On construit la chaine

	if (j>0) {
		texte = j + "j " + formatageDate(h) +":" + formatageDate(m) +":" + formatageDate(s); //+"s"
	}
	else if (h>0) {
		texte = texte + formatageDate(h) +"h " + formatageDate(m) +"m " + formatageDate(s) +"s";
	}
	else if (m>0) {
		texte = texte + formatageDate(m) +"m " + formatageDate(s) +"s";
	}
	else {
		texte = texte + formatageDate(s) +"s";
	}
	
	//On affiche maintenant
	if (idclock=='nes') { 
	  	// Pas IE 
	 
	  	if (reste == 0) 
	  	{
		texte = 'Trop tard !';    
        }
        
        //document.getElementById("id_clock").innerHTML = texte;
        if (op=='op')
        {
		    document.writeln('<font style="font:bold 15pt Arial;color:#FF0078;font-style:italic;"><b>'+ texte + '</b></font>');
		}
		else document.writeln('<font style="font:bold 21pt Arial;color:white;font-style:italic;"><b>'+ texte + '</b></font>'); 
  	} 
	else {
	  	// Internet Explorer 
		if (sec_reste >= 0) {
  			document.all[id_clock].innerHTML=texte;
			setTimeout("affReste('"+idclock+"','"+sec_reste+"')", 1000);
			}
		else {
  			document.all[id_clock].innerHTML='Trop tard !';
		}	
	}
}

function disp_clock (idclock,dateact,datefin) {
	if (document.all) { 
	  	// Internet Explorer 
  		document.writeln('<div id="clock' + idclock + '" style="font:bold 18pt Arial;color:white;font-style:italic;display:inline"></div>');
		setTimeout("calculdiff('"+idclock+"','"+dateact+"','"+datefin+"','n')",200);
	}
	else {
	  	// Le reste
		calculdiff('nes',dateact,datefin,'n');
	}
	
}

function  disp_clock_op (idclock,dateact,datefin) {
	if (document.all) { 
	  	// Internet Explorer 
	  	
  		document.writeln('<div id="clock' + idclock + '" style="font:bold 15pt Arial;color:#FF0078;font-style:italic;"></div>');
		setTimeout("calculdiff('"+idclock+"','"+dateact+"','"+datefin+"','op')",200);
	}
	else {
	  	// Le reste
		calculdiff('nes',dateact,datefin,'op');
	}
	
}
 
function LinkToDemo(VideoNB,CompanyID,TemplateID)
{
    var win='toolbar=0,location=0,directories=0,menubar=0,status=0,resizable=0,scrollbars=0,target=_blank,width=352,height=400,left=250,top=100';
    var theurl="http://demo.cedemo.com/php3/videoshow.php3?CompanyID="+CompanyID+"&amp;VideoNB="+VideoNB+"&amp;TemplateID="+TemplateID;
    PPCVisionWin=window.open (theurl,'PPCVision',win);
}
