
function initdisplayjours()
{
		cacher('jourdiv2');
		cacher('jourdiv3');
		cacher('jourdiv4');
		cacher('jourdiv5');
}

function eraseDate(jour,mois,an,debut,fin)
{
	document.getElementById(jour).value="";
	document.getElementById(mois).value="";
	document.getElementById(an).value="";
	document.getElementById(debut).value="";
	document.getElementById(fin).value="";
}

function cacher(obj)
{
	document.getElementById(obj).style.display = "none";
        document.getElementById(obj).style.visibility = "hidden";
}

function afficher(obj){
    document.getElementById(obj).style.display = "block";
   document.getElementById(obj).style.visibility = "visible";
}


function checkrequired(which) {
var pass=true;
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.id.length>8 && tempobj.id.substr(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
ignoreSpaces(tempobj.value)=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }

if (!pass) {
shortFieldName=tempobj.id.substr(8,30).toUpperCase();
alert("Merci de renseigner le champ "+shortFieldName);
return false;
}
else
return true;
}


function checkformat()
{
	var value= window.document.forms[0].requiredJour.value;
	 value = value.toString().replace(/ /gi,'');
	if(isNaN(value) || value>31 || value==0 || value=="00")
	{
		alert("Merci de saisir un jour compris entre 1 et 31");
		return false;
	}
	value= window.document.forms[0].requiredMois.value;
	if(isNaN(value)|| value>12 || value==0 || value=="00")
	{
		alert("Merci de saisir un mois compris entre 1 et 12");
		return false;
	}
	value= window.document.forms[0].requiredAn.value;
	if(isNaN(value) || value.length!=4)
	{
		alert("Merci de saisir une année valide.");
		return false;	
	}
	if(value<2006)
	{
		alert("Merci de saisir une année supérieure à l'année en cours.");
		return false;
	}
	return true;	
}

//ignore les blancs
function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(j = 0; j < splitstring.length; j++)
temp += splitstring[j];
return temp;
}

function ouvre(page,target)
{
window.open(page,target);
}

function resetConfForm()
{
	
	window.document.forms[0].requiredJour.value='';
	window.document.forms[0].requiredMois.value='';
	window.document.forms[0].requiredAn.value='';
	window.document.forms[0].Jour2.value='';
	window.document.forms[0].Mois2.value='';
	window.document.forms[0].An2.value='';
	window.document.forms[0].Jour3.value='';
	window.document.forms[0].Mois3.value='';
	window.document.forms[0].An3.value='';
	window.document.forms[0].Jour4.value='';
	window.document.forms[0].Mois4.value='';
	window.document.forms[0].An4.value='';
	window.document.forms[0].Jour5.value='';
	window.document.forms[0].Mois5.value='';
	window.document.forms[0].An5.value='';
	window.document.forms[0].debut.value='';
	window.document.forms[0].fin.value='';
	window.document.forms[0].debut2.value='';
	window.document.forms[0].fin2.value='';
	window.document.forms[0].debut3.value='';
	window.document.forms[0].fin3.value='';
	window.document.forms[0].debut4.value='';
	window.document.forms[0].fin4.value='';
	window.document.forms[0].debut5.value='';
	window.document.forms[0].fin5.value='';
	window.document.forms[0].nbjour.value='';
	window.document.forms[0].inscription.value='';
}


function montre(object)
  {
  if (document.layers && document.layers[object])
    { 
    document.layers[object].visibility = 'visible';
    } 
  else if (document.all)
    {
    document.all[object].style.visibility = 'visible';
    document.all[object].style.zIndex = 100;
    }
  else if (document.getElementById) 
    {
    document.getElementById(object).style.visibility = 'visible';     
    document.getElementById(object).style.zIndex = 100; 
    } 
  }

function cache(object)
  {
  if (document.layers && document.layers[object])
    { 
    document.layers[object].visibility = 'hidden';
    } 
  else if (document.all)
    { 
    document.all[object].style.visibility = 'hidden';
    }
  else if (document.getElementById) 
    {
    document.getElementById(object).style.visibility = 'hidden'; 
    } 
  }
  


function remplacechaine(text1,text2,text3){
// text1 = chaine départ
// text2 = chaine à replacer
// text3 = chaine de remplacement
var longueur = text2.length;
var debut= text1.lastIndexOf(text2);
while( debut != -1){
	mot = text1.substring(debut,debut+longueur);
        var avant=text1.substr(0,debut);
	var suite=text1.substr(debut+longueur,text1.length);
	text1 = avant + text3 + suite 
	
	debut= text1.lastIndexOf(text2);	
}
return text1;
}

function remplaceGuillemets(text)
{
	text = remplacechaine(text,"\"","&#34;");
	text = remplacechaine(text,"\'","&#39;");
	return text;
}



function changeGuillemets()
{
	document.getElementById("requiredTitre").value=remplaceGuillemets(document.getElementById("requiredTitre").value);
	document.getElementById("requiredLieu").value=remplaceGuillemets(document.getElementById("requiredLieu").value);
	document.getElementById("auteur").value=remplaceGuillemets(document.getElementById("auteur").value);
	document.getElementById("tarif").value=remplaceGuillemets(document.getElementById("tarif").value);
	document.getElementById("requiredAdresse").value=remplaceGuillemets(document.getElementById("requiredAdresse").value);
	document.getElementById("des").value=remplaceGuillemets(document.getElementById("des").value);
}


function reloadModif()
{
	 document.forms[0].modif.value="false";
	 changeGuillemets();
 	 document.forms[0].submit();	
}

function reloadAddConf()
{
 document.forms[0].add.value="false";
 changeGuillemets();
 document.forms[0].submit();	
}

//parametre de resolution de la page
var resolution;
function getResolution()
{
	if (screen.width > 1000)
	resolution=1000;
	else
	resolution=770;
}

function writeWithResolution()
{
	if(resolution==770){
		document.write("<table width='770' height='100%' border='0' cellpadding='0' cellspacing='0'>");
	}else{
		document.write("<table width='1000' height='100%' border='0' cellpadding='0' cellspacing='0'>");
	}
}

function presence_frame()
{
 if(!parent.frames[2])
 {	
  top.location.replace('http://www.artconf.com/index.html');
 }
}




function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

javasript:javascript:alert("L'adresse email saisie est invalide.");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
javasript:javascript:alert("L'adresse email saisie est invalide.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
javascript:alert("L'adresse email saisie est invalide.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

javascript:alert("L'adresse email saisie est invalide.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
javascript:alert("L'adresse email saisie est invalide.");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
javascript:alert("L'adresse email saisie est invalide.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
javascript:alert("L'adresse email saisie est invalide.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
javascript:alert("L'adresse email saisie est invalide.");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}


