var previous=null

dj = new Date()
jrs = ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi']
ms = ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','Décembre']
var ddj = jrs[dj.getDay()]+' '+dj.getDate()+' '+ms[dj.getMonth()]


var largeur = 0, hauteur = 0;
if( typeof( window.innerWidth ) == 'number' ) {
  largeur = window.innerWidth;
  hauteur = window.innerHeight;
  } 
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  largeur = document.documentElement.clientWidth;
  hauteur = document.documentElement.clientHeight;
  } 
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  largeur = document.body.clientWidth;
  hauteur = document.body.clientHeight;
  }
else {
  largeur = -1;
  hauteur = -1;
  } 

function showFlip(n,pg)
{
	popUp('popflip.asp?numero='+n+'&page='+((pg)?pg:''),558,800)
}

function AfficherImage(img) { Image1= new Image();  Image1.src=(img);  Control(img); } 
function Control(img) {  if((Image1.width!=0)&&(Image1.height!=0)) {    VoirImage(img);  }  else {    fonction="Control('"+img+"')";    intervalle=setTimeout(fonction,20);  } } 
function VoirImage(img) {  
largeur=Image1.width+20;  hauteur=Image1.height+20;  
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
proprietes="width="+ largeur +",height="+ hauteur+",top="+top+",left="+left;  
win=window.open(img,"",proprietes); }

AlphaChars = "ôéàçèâîïùabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .@,-_";
NumChars = "0123456789";
HexaChars = "ABCDEFabcdef";

function popUp(url,h,l)
{
	var top=(screen.height-h)/2;
	var left=(screen.width-l)/2;
	proprietes="width="+ l +",height="+ h+",top="+top+",left="+left+",menubar=no,scrollbars=no,statusbar=no";  
	win=window.open(url,"",proprietes);
}

function checkValue(champ, typ)
{
 
 erreur=false;
 if (champ.value != '')
 {
	 result = CheckField(champ.value,typ)
	 if (result!=true)
		{	if (typ=='DAT' && result!=false)
				{champ.value = result}
			else {erreur=true
			}
		}
	}
else erreur=true
if (erreur) {
alert("Une erreur est détectée sur le champ "+champ.name+' --- '+champ.value)
champ.focus()
}
else return true


	
}
function checkEmail(emailAddr) {
	
	var i;
	i = emailAddr.indexOf("@");	if (i == -1) {	return false;	}
	var username = emailAddr.substring(0, i);
	var domain = emailAddr.substring(i + 1, emailAddr.length)
	i = 0;while ((username.substring(i, i + 1) == " ") && (i < username.length)) {	i++;	}
	if (i > 0) {username = username.substring(i, username.length);}
	i = domain.length - 1;
	while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {	i--;}
	if (i < (domain.length - 1)) {domain = domain.substring(0, i + 1);}
	prefix=domain.split('.')[0]
	if ((username == "") || (domain == "") || (prefix=="")) {return false;}
	var ch;
	for (i = 0; i < username.length; i++) {
		ch = (username.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || ((ch >= "0") && (ch <= "9")) ||	(ch == "_") || (ch == "-") || (ch == "."))) {	return false;}}
	for (i = 0; i < domain.length; i++) {
		ch = (domain.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
/*var aSuffix = new Array("com","net","int","aero","biz","museum","name","info","coop","pro","eu","edu","org","gov","mil","bj","dz","de","ad","be","ca","bf","bi","cm","cf","cg","cd","ci","dj","fr","ga","gp","gf","lu","mg","ml","ma","mq","mr","mc","nc","pf","re","pm","sn","ch","td","tf","tn");
	var bFoundSuffix = false;
	i = 0;
	while (i < aSuffix.length) {
		if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
			return true;
		}
		i++;
	}*/
	return true;
	// Si le nom de domaine est inconnu  : return false
	/*return false;*/
	
}	

function IsMail(Data)
{
	car=Data.indexOf(' ')==-1
	alias=Data.split("@")[0] !=null
	domain=Data.split("@")[1] !=null
	if (domain) suffix=Data.split("@")[1].split(".")[1] !=null
	if (domain) suffix=Data.split("@")[1].split(".")[0] !=null
	if (!car || !alias || !domain || !suffix) {return false;}
	return true
}

function IsNumeric(Data) {
	var It = true;
	var c;
	for (var x = 0; x < Data.length; x++)
		if (It) {
			c = Data.charAt(x);
			It = ( NumChars.indexOf(c) != -1);
		}
	return It;
}

function IsDecimal(Data) {
	var It = true;
	var virgule = false;
	var c;
	c = Data.charAt(0);	
	It = (  (AlphaChars.indexOf(c) != -1) || (NumChars.indexOf(c) != -1) || (c == "+") || (c=="-") );
	for (var x = 1; x < Data.length; x++)
		if (It) {
			c = Data.charAt(x);
			if ( (c==".") || (c == ",") )
				if (virgule) 
					It = false;
				else {
					It = true;
					virgule = true;
				}
			else
				It = (  (AlphaChars.indexOf(c) != -1) || (NumChars.indexOf(c) != -1) );
		}
	return It;
}

function IsAlphaNumeric(Data) {
	var It = true;
	var c;
	for (var x = 0; x < Data.length; x++)
		if (It) {
			c = Data.toLowerCase().charAt(x);
			It = (  (AlphaChars.indexOf(c) != -1) || (NumChars.indexOf(c) != -1) );
		}
	return It;
}

function IsHexa(Data) {
	var It = true;
	var c;
	for (var x = 0; x < Data.length; x++)
		if (It) {
			c = Data.charAt(x);
			It = (  (HexaChars.indexOf(c) != -1) || (NumChars.indexOf(c) != -1) );
		}
	return It;
}

function IsSome(Data) {if (Data.length==0) {return false} else {return true};}

function IsAlpha(Data) {
	var It = true;
	if (Data.length==0) It=false;
	var c;
	for (var x = 0; x < Data.length; x++)
		if (It) {
			c = Data.charAt(x);
			It = ( AlphaChars.indexOf(c) != -1);
		}
	return It;
}

function CheckField(Data,Format) {
	var exact = false;
	if (Data.length > 0) {
		if (Format == "NUM")
			exact = IsNumeric(Data);
		if (Format == "TXT")
			exact = IsAlphaNumeric(Data);
		if (Format == "PCT")
			exact = IsDecimal(Data);
		if (Format == "DEC")
			exact = IsDecimal(Data);
		if (Format == "HEXA")
			exact = IsHexa(Data);
		if (Format == "ALPHA")
			exact = IsAlpha(Data);
		if (Format == "DAT")
			exact = IsDate(Data);
		if (Format == "MAIL")
			exact = IsMail(Data);
		if (Format == "SOME")
			exact = IsSome(Data);

	}
	return exact;
}
  
function jsStringReplacejsCheckDate(strOriginal , strFind, strReplace)  {
  var intPos = 0;
  var intLen = strFind.length;
  intPos = strOriginal.indexOf(strFind);
  while (intPos != -1) {
    strOriginal = strOriginal.substring(0, intPos) + strReplace + strOriginal.substring(intPos+intLen, strOriginal.length);
    intPos = strOriginal.indexOf(strFind);
  };
  return strOriginal;
}
function jsTestCeiljsCheckDateFormat(Nbre)  {
 if (Nbre==Math.ceil(Nbre)) {
    return true; 
 } else { 
    return false;
 }
}
function jsStringReplacejsCheckDateFormat(strOriginal , strFind, strReplace)  {
  var intPos = 0;
  var intLen = strFind.length;
  intPos = strOriginal.indexOf(strFind);
  while (intPos != -1) {
    strOriginal = strOriginal.substring(0, intPos) + strReplace + strOriginal.substring(intPos+intLen, strOriginal.length);
    intPos = strOriginal.indexOf(strFind);
  };
  return strOriginal;
}
function jsCheckDateFormat(strDate, strFormat)  {
 var D;
 var M;
 var Y;
 var div4;
 var div100;
 var div400;
 var bTest = false;
  bTest = false;  if ((strFormat=='dd.mm.yyyy') || (strFormat=='dd.mm.yy') || (strFormat=='mm.dd.yyyy') || (strFormat=='mm.dd.yy') || (strFormat=='d.m.yyyy') || (strFormat=='d.m.yy') || (strFormat=='m.d.yyyy') || (strFormat=='m.d.yy'))
  {    bTest = true;    strDate = jsStringReplacejsCheckDateFormat(strDate, '.', '/');
    strFormat = jsStringReplacejsCheckDateFormat(strFormat, '.', '/');
  }  if (!bTest && ((strFormat=='dd-mm-yyyy') || (strFormat=='dd-mm-yy') || (strFormat=='mm-dd-yyyy') || (strFormat=='mm-dd-yy') || (strFormat=='d-m-yyyy') || (strFormat=='d-m-yy') || (strFormat=='m-d-yyyy') || (strFormat=='m-d-yy')))
  {    bTest = true;    strDate = jsStringReplacejsCheckDateFormat(strDate, '-', '/');
    strFormat = jsStringReplacejsCheckDateFormat(strFormat, '-', '/');
  }  if (!bTest && ((strFormat=='ddmmyyyy') || (strFormat=='mmddyyyy') || (strFormat=='ddmmyy') || (strFormat=='mmddyy')))
  {    strDate = strDate.substring(0, 2) + '/' + strDate.substring(2, 4) +  '/' + strDate.substring(4, strDate.length);
    strFormat = strFormat.substring(0, 2) + '/' + strFormat.substring(2, 4) +  '/' + strFormat.substring(4, strFormat.length);
  } p1 = strDate.indexOf('/');
 p2 = strDate.lastIndexOf('/');
 LenY = strDate.length - p2 - 1;
 bTest = false;  if ((strFormat=='dd/mm/yy') || (strFormat=='d/m/yy'))
  {    bTest = true;    D = parseFloat(strDate.substring(0,p1));
    M = parseFloat(strDate.substring(p1+1,p2));
    Y = parseFloat(strDate.substring(p2+1,strDate.length));
    if (LenY!=2) {Y=-1;} 
  }  if (!bTest && ((strFormat=='mm/dd/yy') || (strFormat=='m/d/yy')))
  {    bTest = true;    M = parseFloat(strDate.substring(0,p1));
    D = parseFloat(strDate.substring(p1+1,p2));
    Y = parseFloat(strDate.substring(p2+1,strDate.length));
    if (LenY!=2) {Y=-1;} 
  }  if (!bTest && ((strFormat=='mm/dd/yyyy') || (strFormat=='m/d/yyyy')))
  {    bTest = true;    M = parseFloat(strDate.substring(0,p1));
    D = parseFloat(strDate.substring(p1+1,p2));
    Y = parseFloat(strDate.substring(p2+1,strDate.length));
    if (LenY!=4) {Y=-1;} 
  }  if (!bTest && ((strFormat=='dd/mm/yyyy') || (strFormat=='d/m/yyyy')))
  {    bTest = true;    D = parseFloat(strDate.substring(0,p1));
    M = parseFloat(strDate.substring(p1+1,p2));
    Y = parseFloat(strDate.substring(p2+1,strDate.length));
    if (LenY!=4) {Y=-1;} 
  }  if (!bTest)
  {    D = parseFloat(strDate.substring(0,p1));
    M = parseFloat(strDate.substring(p1+1,p2));
    Y = parseFloat(strDate.substring(p2+1,strDate.length));
    if (LenY!=4) {Y=-1;} 
  }
 if ((D==0)||!jsTestCeiljsCheckDateFormat(D)) {D=-1;}
 if ((M==0)||!jsTestCeiljsCheckDateFormat(M)||(M>=13)) {M=-1;}
 if (!jsTestCeiljsCheckDateFormat(Y)) {Y=-1;}
 if (Y==0) {Y=2000;}
 div4=jsTestCeiljsCheckDateFormat(Y/4);
 div100=jsTestCeiljsCheckDateFormat(Y/100);
 div400=jsTestCeiljsCheckDateFormat(Y/400);
 if ((Y>=0) && (Y<=9999)) { 
   if ((M==1)||(M==3)||(M==5)||(M==7)||(M==8)||(M==10)||(M==12)) {
     if ((D>0)&&(D<=31)) { 
       return true;
     } else { return false; }
   }
   if ((M==4)||(M==6)||(M==9)||(M==11)) {
     if ((D>0)&&(D<=30)) { 
       return true; 
     } else { return false; }
   }
   if (M==02) {1
     if ((div4)&&!(div100)||(div400)) {
       if ((D>0)&&(D<=29)) {
         return true; 
       } else { return false; }
     } else {
       if ((D>0)&&(D<=28)) {
         return true; 
       }else { return false; }
     } 
   } else { return false; }
 } else { return false; }
 return true;
}
function IsDate(strDate)  {
 strDate = jsStringReplacejsCheckDate(strDate, '.', '/');
 strDate = jsStringReplacejsCheckDate(strDate, '-', '/');
 if (strDate.indexOf('/')==-1)
   { 
   if (strDate.length == 6)
     strDate = strDate.substring(0, 2) + '/' + strDate.substring(2, 4) + '/' + strDate.substring(4, 6);
   else if (strDate.length==8)
     strDate = strDate.substring(0, 2) + '/' + strDate.substring(2, 4) + '/' + strDate.substring(4, 8);
   }
 if ((jsCheckDateFormat(strDate, 'dd/mm/yy')) || (jsCheckDateFormat(strDate, 'dd/mm/yyyy')) || (jsCheckDateFormat(strDate, 'mm/dd/yy')) || (jsCheckDateFormat(strDate, 'mm/dd/yyyy')))
   return strDate;
 else {
   return false;
  };
}

function ajaxLoader(url,id)
{	if (document.getElementById) 
			{var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();}
			if (x){
				x.onreadystatechange = function()
				{
				if (x.readyState == 4 && x.status == 200){
				//alert(x.responseText);
				el = document.getElementById(id);el.innerHTML = x.responseText;}
				}
				x.open("GET", url, true);
				x.send(null);
				}
}


function showFlip(n,p)
{
	popupOpen("flip.asp",{numero:n,page:p})
}

function popupOpen(url,prms)
{	dejaouverte=false //$('popup').innerHTML=!''
	new Ajax.Updater('popup',url,{evalScripts:true,method:'post',
		parameters:prms,
		onComplete:function(transport) 
			{ if (!dejaouverte) {
				posX= (screen.availWidth/2)-($('popup').getWidth()/2)
				posY=document.viewport.getScrollOffsets().top+20
				//posY= (screen.availHeight/3)-($('popup').getHeight()/3)
				$('popup').style.left=posX+'px'
				$('popup').style.top=posY+'px'
				$('popup').style.zIndex=10000
				$('popup').show()
			}
			}}
		)
}

function popupClose() {Effect.BlindUp('popup'); $('popup').update('')}

function themesShow()
{
	posX= (screen.availWidth/2)-($('divthemes').getWidth()/2)
	posY= (screen.availHeight/3)-($('divthemes').getHeight()/3)
	$('divthemes').style.left=posX+'px'
	$('divthemes').style.top=posY+'px'
	$('divthemes').style.zIndex=1000
	$('divthemes').show()
}

