// © ATELIER 33 / ALL RIGHTS RESERVED / 2001 / http://www.atelier33.com / contact@atelier33.com
// Toute copie complete ou partielle de ce code est interdite
//----------------------------
function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//----------------------------
function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}
//----------------------------
function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}
//----------------------------
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_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_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 tmt_swapFlash(id,file){
	var fun = (document.getElementById) ? "tmt_findObj" : "MM_findObj";
	obj = eval(fun+"(id)");if(obj){eval("obj.LoadMovie(0,'"+file+"')");}
	//alert("Je swap "+file+" !");
}
//----------------------------
function MM_callJS(jsStr) {return eval(jsStr)}
//----------------------------
function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
//----------------------------
function MM_goToURL() { 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//----------------------------
function Add()
{
browserName = navigator.appName; browserVer = parseInt(navigator.appVersion);
if (browserName == "Microsoft Internet Explorer" && browserVer >= 4){window.external.AddFavorite(location.href, document.title);}
else{alert('Utilisateurs de Netscape Communicator : \rPresser Ctrl + D pour bookmarquer ce site.')}
}
//----------------------------
function Resizeit(new_h, new_w)
{
var h = screen.height ; var w = screen.width;
//var newhe=h/2-150; var newwe=w/2-375;	
self.resizeTo(new_h, new_w);
}
//----------------------------
function MoveitToCenter()
{
var h = screen.height ; var w = screen.width;
//var new_x=h/2-150; var new_y=w/2-375;
top.moveTo(new_x, new_y);
}
//----------------------------
function SelfMoveTo(DaX, DaY){self.moveTo(DaX, DaY)}
//----------------------------
function check_empty(text){return (text.length > 0);} 
//----------------------------
function check_email(adresse)
{
 if ((adresse == "") || (adresse.indexOf ('@') == -1) || (adresse.indexOf ('.') == -1))
      return false;
    return true;
}
//----------------------------
function Validate()
{
	validity=true; var ici=document.form01;	var i=0; var bFlag=false;
	if (!check_empty(ici.Nom.value)){validity=false; alert("Indiquez votre nom, svp."); ici.Nom.focus(); return validity;}
	if (!check_empty(ici.Prenom.value)){validity=false; alert("Indiquez votre prénom, svp."); ici.Prenom.focus(); return validity;}
	if (!check_empty(ici.Societe.value)){validity=false; alert("Indiquez le nom de votre société, svp."); ici.Societe.focus(); return validity;}
	if (!check_email(ici.Email.value)){validity=false; alert("Indiquez correctement votre email, svp."); ici.Email.focus(); return validity;}
	if (!check_empty(ici.Ville.value)){validity=false; alert("Indiquez la ville, svp."); ici.Ville.focus();  return validity;}
	
	for(i=0; i<ici.S1.length; i++){DaAction=eval("ici.S1[i].checked"); if (DaAction==true){bFlag=true;}}
	if (!bFlag && !check_empty(ici.Comment.value))
		{validity=false; alert("Vous n'avez spécifié aucune requête !\n(Aucune demande, aucun message)"); ici.Comment.focus(); return validity;}
}
//----------------------------
function tmt_winPrint(id){ 
	if(window.print()){
	var d=eval(id)==null||eval(id+".closed");
	if(!d){eval(id+".print()");}}
}
//----------------------------
function ArticleZoom(DaUrl)
{ window.open (DaUrl,'LIRE','scrollbars=auto,resizable=yes,status=yes,width=540,height=475')}
//----------------------------
function SendItToFriend(DaUrl2)
{
 //MM_openBrWindow('/bat_adm/friend.asp?page='+DaUrl2+' ','FRIEND','scrollbars=no,resizable=yes,status=no,width=390,height=325')
 window.open ('friend.asp?page='+DaUrl2+' ','FRIEND','scrollbars=yes,resizable=yes,status=no,width=400,height=330')
}
//----------------------------
function ValidateFriend()
{
validity = true;
var ici = document.form01;
	
if (!check_email(ici.From.value))
     { validity = false; alert("Indiquez correctement votre email, svp.");
       ici.From.focus();
       return validity;
     }

if (!check_empty(ici.FromName.value) || (ici.FromName.value == "Votre nom"))
     { validity = false; alert("Indiquez votre nom, svp.");
       ici.FromName.focus();
       return validity;
     } 

if (!check_email(ici.To.value))
     { validity = false; alert("Indiquez correctement l'email du destinataire, svp.");
       ici.To.focus();
       return validity;
     }
}
//----------------------------

function SaveArticle(DaAction)
{
document.Form01.ArticleDataText.value=document.frames('myEditor').document.frames('textEdit').document.body.innerText ;
document.Form01.ArticleDataHtml.value=document.frames('myEditor').document.frames('textEdit').document.body.innerHTML ;
document.Form01.Action.value= DaAction;
}
//----------------------------
function EraseAll() {newFile() ;}
//-----------------------------
function PreviewArticle()
{
 var ici = document.Form01; 
 ici.ArticleDataHtml.value=document.frames('myEditor').document.frames('textEdit').document.body.innerHTML ;
 
 TempPrev = "";
 TempPrev = "<b>&nbsp;" + ici.ArticleName.value + "</b><br>";
 
 if ( ici.ArticleID.value =="")
 { TempPrev = TempPrev + "(Nouvel article)"};
 else
 { TempPrev = TempPrev + "(ID : " + ici.ArticleID.value + ")"};
 
 TempPrev = TempPrev + " Le " + ici.ArticleActive.value + " par : "+ ici.ArticleAuthor.value + " ";
 TempPrev = TempPrev + "<br><br>" + ici.ArticleDataHtml.value + "";

 ici.PreviewDataHtml.value = TempPrev;
 
 window.open('actu_preview.asp','LIRE','scrollbars=auto,resizable=yes,status=yes,width=540,height=475')	
}
//-----------------------------
function ValidateData()
{
validity = true;
var ici = document.Form01;
	
if (!check_empty(ici.ArticleName.value))
     { validity = false; alert("Indiquez le titre de votre article, svp.");
       ici.ArticleName.focus();
       return validity;
     }
     
if (!check_empty(ici.ArticleAuthor.value))
     { validity = false; alert("Indiquez le nom de l'auteur, svp.");
       ici.ArticleAuthor.focus();
       return validity;
     }

if (!check_empty(ici.ArticleActive.value))
     { validity = false; alert("Indiquez la date ce mise en activité\nde votre article, svp.\n\nFormat : jj/mm/aaa");
       ici.ArticleAuthor.focus();
       return validity;
     }
     
if (!check_empty(ici.ArticleDataHtml.value))
     { validity = false; alert("Entez le texte de votre article svp.");
       document.frames('myEditor').document.frames('textEdit').focus()
       return validity;
     } 


}
