function OpenRefWin( url )
{
	var options = "toolbar=no,location=no,directories=no,status=no," + "menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes," + "width=560,height=300";
	maFenetre = window.open(url,"",options);
}
function ConfirmDownload( url, str )
{
	if ( ! confirm( str ) ) return;
	location.href = "download.php?&NoHit=1&TheUrl=" + url;
}

function SetFocusSearch( )
{
	window.frmSearch.BotWrd.focus();
	return;
}

function SelectAll( chk, num )
{
	if ( document.frmDelete.chkDelOpt1.checked == 1 )
	{
	    document.frmDelete.chkDelOpt2.checked = 1;
	    document.frmDelete.chkDelOpt3.checked = 1;
	}
}

function LoadMLE ()
{
	if ( document.formDetail.cmbModel.value == "default.txt" )
	{
		document.formDetail.mleComment.value = "<H5>INFORMATION</H5>\n\n   (saisissez ici le détail de votre publication)\n\n<H5>COMPLEMENTS</H5>\n\n    (saisissez ici vos remarques supplémentaires)";
	} else {
		document.formDetail.mleComment.value = "<H5>INFORMATION</H5>\n\n    (saisissez ici le détail de votre publication)\n\n<UL>\r\n\t<LI>Elément de liste 1\r\n\t<LI>Elément de liste 2\r\n\t<LI>Elément de liste 3\n</UL>\n\n<H5>COMPLEMENTS</H5>\n\n    (saisissez ici vos remarques supplémentaires)";
	}
}

function Visualiser()
{
	var options = "toolbar=no,location=no,directories=no,status=no,"
		+ "menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,"
		+ "width=500,height=600";
	var corps = "<CENTER><FORM>"
		+ "<INPUT TYPE=BUTTON VALUE=Fermer onClick='self.close();'>"
		+ "</FORM></CENTER>";
	maFenetre = window.open("","Détail",options);
	maFenetre.document.write( document.formDetail.mleComment.value + corps);
	maFenetre.document.close();
}

function replacestring( searchstring, old_char, new_char )
{
  // Découpage du fichier en fonction du caractère
  tmp = searchstring.split( old_char );
  searchstring = '';
  for (var i = 0; i < tmp.length; i++)
  {
    searchstring = searchstring + tmp[i];
    if (i != tmp.length - 1)
      searchstring = searchstring + new_char;
  }
  return(searchstring);
}

function popUp(menuName,on)
{
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	ver4 = (NS4 || IE4) ? 1 : 0;

	if (on) {
		if (NS4) {
			document.layers[menuName].visibility = "show";
		} else {
			document.all[menuName].style.visibility = "visible";
		}
	} else {
		if (NS4) {
			document.layers[menuName].visibility = "hide";
		} else {
			document.all[menuName].style.visibility = "hidden";
		}
	}
}

function Permut (flag,img) {
   if (document.images) {
      if (document.images[img].permloaded) {
         if (flag==1) document.images[img].src = document.images[img].perm.src
         else document.images[img].src = document.images[img].perm.oldsrc
      }
   }
}

function preloadPermut (img,adresse) {
   if (document.images) {
      img.onload = null;
      img.perm = new Image ();
      img.perm.oldsrc = img.src;
      img.perm.src = adresse;
      img.permloaded = true;
   }
}

function changeColor( dst, obj )
{
	//	alert( dst + obj.value );
	//	document.all[dst].backcolor = obj.value;
}


/*******************************************************************************
***   DEBUT - P R O J E T   - C N P L A B   - " CDU "										     ***
*******************************************************************************/
function open_mini_word(chemin,repertoire,numcalque)
{
	window.open( "./miniword/mini_word.php?strGetNumCal="+numcalque+"&strGetUrlImg="+chemin+"&strGetRepImg="+repertoire,"InterligoWebEditor",toolbar="menubar=no,scrollbars=yes,resizable=yes,width=630,left=32,top=32");
}
/*******************************************************************************
***   FIN - P R O J E T   - C N P L A B   - " CDU "										     ***
*******************************************************************************/



//?fenetre="+variable
/***************Johann Lemaitre 13-08-2001**************************/
function open_mini_word2(numcalque,zone_form,zone_saisie)
{
	window.open( "./miniword_new/mini_word_new.php?strGetNumCal="+numcalque+"&form="+zone_form+"&fenetre="+zone_saisie,"InterligoWebEditor",toolbar="scrollbars=yes,resizable=yes,width=630,left=32,top=32");
}
/***************Johann Lemaitre 13-08-2001**************************/

/*Fthilliez, on passe le chemin de limage directement comme ça Upload image OK !*/
function open_mini_word_new(numcalque,zone_form,zone_saisie, imagePath)
{
	//window.open( "./miniword_new/mini_word_new.php?strGetNumCal="+numcalque+"&form="+zone_form+"&fenetre="+zone_saisie+"&imageRep="+imagePath,"InterligoWebEditor",toolbar="scrollbars=yes,resizable=yes,width=630,left=32,top=32");
   //Nouveau Miniword !
   window.open( "../miniwordnew/admin_DocEdit.php?page="+numcalque+"&form="+zone_form+"&fenetre="+zone_saisie+"&imageRep="+imagePath,"InterligoWebEditor",toolbar="status=yes,scrollbars=no,resizable=yes,height=555,width=580,left=32,top=32");
}

function open_mini_word_field(chemin,repertoire,calque,form,field)
{
	window.open( "./miniword/my_mini_word.php?strGetCal="+calque+"&strGetUrlImg="+chemin+"&strGetRepImg="+repertoire+"&strGetForm="+form+"&strGetField="+field,"InterligoWebEditor",toolbar="menubar=no,scrollbars=yes,resizable=yes,width=630,left=32,top=32");
}

function open_editor()
{
	window.open( "editeur.php","HtmlEditor",toolbar="menubar=no,scrollbars=yes,resizable=yes,width=640,left=32,top=32");
}
function open_tagscleaner()
{
	window.open( "tags_remove.php?First=1","TagsCleaner",toolbar="menubar=no,scrollbars=yes,resizable=yes,width=600,left=32,top=32");
}
function open_tablebuilder()
{
	window.open( "table_builder.php","TableBuilder",toolbar="menubar=no,scrollbars=yes,resizable=yes,width=680,left=32,top=32");
}
function launchpeg(page)
{
        peg=window.open( page,"peg",'statusbar=1,toolbar=0,menubar=0,scrollbars=0,resizable=no,width=700,height=550');
}
// Spécifique CUDL !
// -----------------
// Validation du formulaire "Mon Web"
function validMyWebForm(frm, msg)
{
   if(frm.civilite.value == 0)
   {
      alert(msg);
      frm.civilite.focus();
      return -1;
   }
   if (frm.nom.value.length <= 0)
   {
      alert(msg);
      frm.nom.focus();
      return -1;
   }
   if (frm.prenom.value.length <= 0)
   {
      alert(msg);
      frm.prenom.focus();
      return -1;
   }
   frm.submit();
}

function turnGray() {
  what = window.event.srcElement;
  if (what.tagName == "IMG") {
	what.src = what.src.substring(0,(what.src.indexOf("1.gif"))) + "0.gif";
	event.cancelBubble = true;
  }
}

function turnColored() {
  what = window.event.srcElement
  if (what.tagName == "IMG") {
	what.src = what.src.substring(0,(what.src.indexOf("0.gif"))) + "1.gif";
	event.cancelBubble = true;
  }
}

function communeListChanged(oSel) {
  pth = oSel.options[oSel.selectedIndex].value;
  if (pth != '0') {
    document.communeList.action = document.communeList.action + pth;
    document.communeList.submit();
  }
}


function viewDetails(valeur)
{
    document.formulaire.id_art.value = ""+valeur;
    document.formulaire.submit();
}

function validDownloadDossierConsult(art_id)
{
    sTarget = "./formulairedossierconsultation.php?&art_id="+art_id;
    maFen = window.open(sTarget ,"Dossier",'statusbar=1,toolbar=0,menubar=0,scrollbars=0,resizable=no,width=450,height=550');
}

// Fonction qui verife la validite d'un champ email d'un formulaire
function verifEmail(mail)
{
    var test_email = /^[a-z0-9_-]+[.]?[a-z0-9_-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/ ;
    mail = mail.toLowerCase();
    if(test_email.test(mail) == true)
    {
        return true;
    }
    else
    {
        return false;
    }
}









