

var msg_blocked = 'Vous devez activer les ouvertures de fenêtre javascript';
function display() {    
	var args=display.arguments;
	var url = '/display.php?contribId='+args[0];
	if(args.length>1) url+="&search="+args[1];
	var iWin = window.open(url, 'displayWindow', 'scrollbars=yes,width=620,height=450,resizable=1');
  if (!iWin) alert(msg_blocked);
  iWin.window.focus();
}

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_openBrWindow(theURL,winName,features) {
  var oWin = window.open(theURL,winName,features);
  if (!oWin) alert(msg_blocked);
}

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_reloadPage(init) {
}
MM_reloadPage(true);

function toInt ( x ) { return ( x > 0 ? Math.floor( x ) : Math.ceil ( x ) ) }
function MM_validateForm() {
  var name,i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
    test=args[i+2]; val=MM_findObj(args[i]); name=args[i+1]
    if (val) { 
      nm=val.name; 
      if(val.length) {
        var isChecked=0;
        for(k=0;k<val.length;k++) {          
          if(val[k].checked) isChecked=1;
        }        
        if(isChecked==0) {
          if(test.indexOf('R')!=-1) {
            errors +='- '+name+' doit contenir au minimum une sélection\n';
          }
        }
      } else {
        if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { 
            p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+name+' doit être une adresse e-mail valide (au format nom@hote.domaine)\n';
          } else if (test!='R') {
            if (isNaN(val)) errors+='- '+name+' doit être un nombre\n';
            if (test.indexOf('inRange') != -1) { 
              s=test.indexOf('inRange');p=test.indexOf(':');              
              min=toInt(test.substring(s+7,p));max=toInt(test.substring(p+1));
              val=toInt(val);
              if (val<min || max<val) errors+='- '+name+' doit être un nombre entre '+min+' et '+max+'.\n';
            } 
          } 
        } else if (test.charAt(0) == 'R') errors += '- '+name+' est nécessaire.\n'; 
      }
    }
  } 
  if (errors) alert('Le formulaire contient les erreurs suivantes :\n'+errors);
  document.MM_returnValue = (errors == '');
}

var MyBox = null;
function InitMyBox() {
	MyBox = new Box('MyBox','conteneur',1,40,1000,10);	  
	if(MyBox!=null) { MyBox.start(); }
}

function AjoutFiche(admurl,opt) {
	var addCtWindow;
	var url = '/EXTRANET/';
	if(admurl) { url+=admurl+".php";url+="?xxpopup=1";if(opt) url+="&"+opt; }
	addCtWindow = window.open(url, 'ajouter', 'width=650,height=540,resizable=1,scrollbars=yes');	
}

function RemoveContent(cid) {
	var editWindow;
	var url = '/EXTRANET/outils/editor.php?ou=disable&contribId='+cid;
	editWindow =window.open(url, 'editer', 'width=300,height=250,resizable=0,scrollbars=no');
}
function AdminFiche(contribId) {
	var editWindow;
	var url = '/EXTRANET/outils/editor.php?ou=edit&contribId='+contribId;
	window.open(url, 'editer', 'width=650,height=540,resizable=1,scrollbars=yes');
}
function AdminRubrique(admurl,opt) {
	var editWindow;
	var url = '/EXTRANET/';
	if(admurl) { url+=admurl+".php"; url+="?xxpopup=1"; if(opt) url+="&"+opt; }
	window.open(url, 'AdmSite', 'toolbar=1,status=1,resizable=1,scrollbars=yes');
}

function borderize(elem,status) {
  if(status) {    
    elem.oldstyle = elem.style.backgroundColor ;
    elem.style.backgroundColor ="#C0C0C0";  
  } else {
    elem.style.backgroundColor  = elem.oldstyle;
  }
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  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 menu(layer,mode) { MM_showHideLayers(layer,'',mode) }

function ShowPicture(ImageId,thewidth,theheight)
{
  var maxWidth;
  var maxHeight;
  var popwidth;
  var popheight;
  var moveit=0;  
  
  maxWidth=screen.availWidth;
  if(maxWidth<=0) maxWidth=thewidth;
  if(maxHeight<=0) maxHeight=theheight
  maxHeight=screen.availHeight;
  if((thewidth+48)>maxWidth) { popwidth=maxWidth-16;moveit=1; }
  else  { popwidth=thewidth+48;}
  if((theheight+64)>maxHeight) { popheight=maxHeight-16;moveit=1; }
  else { popheight=theheight+64; }
	var copyWindow;
	var url = ImageId;
	mywin = window.open('', '', 'width='+(popwidth)+',height='+(popheight)+',resizable=1,scrollbars=yes');
	mywin.document.write('<html><head><title>Photo</title></head><b'+'ody>');
	mywin.document.write('<center><img style="cursor:hand" onClick="javascript:window.close()" alt="cliquez pour fermer" src='+escape(ImageId)+' width='+thewidth+' height='+theheight+' border=0>');
	mywin.document.write('<br><font face="arial,helvetica,sans-serif" size="2">[<a href="javascript:window.close()">Fermer</a>]</font>');
	mywin.document.write('</center></b'+'ody></html>');
	if(moveit) mywin.moveTo(0,0);
}

function checkemail(valStr) {
  var current=MM_findObj(valStr);  
  var varMail=current.value;   
  if (varMail.match(/^[a-z][a-z_0-9\.\-]+@[a-z_=>0-9\.\-]+\.[a-z]{2,4}$/i) != varMail) {
    return false ;
  } else { return true ; } 
}

function AddToFavorite() {
  window.external.AddFavorite('http://www.nicephore.net','Galeries Virtuelles Nic&eacute;phore')
}

function AddToStart(Quid){
  Quid.style.behavior='url(#default#homepage)';
  Quid.setHomePage('http://www.nicephore.net');
}

function autoSize() {
  IE5=NN4=NN6=false
  if (self.document.all) IE5=true;
  else if (self.document.getElementById)  NN6=true;
  else if (self.document.layers)  NN4=true;
  if (IE5) {
    winHeight=(self.document.body.scrollHeight - self.document.body.clientHeight);        
    winWidth=(self.document.body.scrollWidth - self.document.body.clientWidth);         
    self.resizeBy(winWidth, winHeight);
  }
  else  if (NN6) self.sizeToContent();
  self.focus()
}

var mlPopup = null;
function newsletter(elem) {
 var mlPopup = window.open('','newsletter','width=500,height=450,scrollbars=yes');
 if (!mlPopup) { alert(msg_blocked); return false; }  
 elem.target = 'newsletter';
 return true;
}

function poll_vote(id) {
  var poll =MM_findObj('poll_'+id)
  popup_window = window.open('','sondage', 'width=350,height=160,resizable=1,scrollbars=yes'); 
  if (!popup_window) { alert(msg_blocked); }    
  poll.target="sondage";
  poll.submit();  
  return true;
}

function poll_results(id) {
  var url="/?module=sondages&id="+id+"&popup=1&cmd=cmVzdWx0cw%3D%3D";
  popup_window = window.open(url,'resultats', 'width=620,height=350,resizable=1,scrollbars=yes'); 
  if (!popup_window) { alert(msg_blocked); }      
}


function imprimer(url) {
 popup_window =window.open(url, '', 'scrollbars=yes,width=740,height=400,menubar=1,titlebar=0,toolbar=1,resizable=1');
}

var stdFuncLoaded=1;
var js_loaded=1;
