function checkMail(from)
{
	var re = /^[A-Za-z0-9.-_--]+@[A-Za-z0-9.-_--]+\.[A-Za-z]{2,5}$/;
	if (re.test(from.value)) {	return true;}
	else	{alert("Format adresse e-mail invalide.");	}
	return false;
}
function razValue(obj, vlDef)
{
	if (obj.value == vlDef)
		obj.value="";
}
function isIE()
{
	return (navigator.appName.match(/Explorer/i));
}
var shortcut = '';
function myInit(wuVerticalJS) {	
	if (document.getElementById('wuInHeader')) { var wuInHeader = document.getElementById('wuInHeader').clientHeight; }
	else { var wuInHeader = 0; }
	if (document.getElementById('wuInFooter')) { var wuInFooter = document.getElementById('wuInFooter').clientHeight; }
	else { var wuInFooter = 0; }
	var contentHeight = document.getElementById('wuAll').clientHeight - wuInHeader - wuInFooter;
	if (document.getElementById('wuContent').clientHeight < contentHeight) document.getElementById('wuContent').height = contentHeight;
	if (document.getElementById('wuAllContent').clientHeight < contentHeight) document.getElementById('wuAllContent').height = contentHeight;
	if (shortcut != '') {		
		if(shortcutPos == 'left') { document.getElementById(shortcut).style.left = '0px'; }
		if(shortcutPos == 'right') { document.getElementById(shortcutDiv).style.left = document.getElementById(shortcut).clientWidth - shortcutWidth; }	
	}	
	if(isIE() != 'Explorer' && wuVerticalJS == true) {
	  if (window.innerWidth != screen.width) {	   
      window.resizeBy(1,1);
      window.resizeBy(-1, -1);
    }
  }
}

// Fonction nav html
function menu (id, alignImg, img, imgWidth, imgHeight, imgAlt, ewResources, unvisible, font, pcolor, color, bgpcolor, bgcolor, align, textdecoration, fontweight, fontstyle, textsize, borderstyle, borderpx, borderpcolor, bordercolor, bordermg)
{
	var quote = '\'\"';
	var qquote = ' ';	
	//Image
	if (img !='' ) {
		if (alignImg ==  'fond') {
			document.getElementById('cadre'+id).style.backgroundPosition='center center';
			document.getElementById('cadre'+id).style.backgroundRepeat='no-repeat';
			document.getElementById('cadre'+id).style.backgroundImage='url('+ewResources+img+')';
			//document.getElementById('cadre'+id).style.width=imgWidth;
			//document.getElementById('cadre'+id).style.height=imgHeight;
			document.getElementById('cadre'+id).title=imgAlt.replace(quote, qquote);
			document.getElementById('cadre'+id).style.cursor=isIE()? 'hand' : 'pointer';
		} else {
			document.getElementById('img'+id).src=ewResources+img;
			document.getElementById('img'+id).width=imgWidth;
			document.getElementById('img'+id).height=imgHeight;
			document.getElementById('img'+id).title=imgAlt.replace(quote, qquote);
			document.getElementById('img'+id).style.display='block';
			document.getElementById('cadre'+id).style.cursor=isIE()? 'hand' : 'pointer';
		}
	} else {
		if (alignImg == 'fond') {
			document.getElementById('cadre'+id).style.backgroundImage='url()';
			//document.getElementById('cadre'+id).style.width='';
			//document.getElementById('cadre'+id).style.height='';
			document.getElementById('cadre'+id).title='';
		} else {
			if (img != '' ) {
				document.getElementById('img'+id).src='';
				document.getElementById('img'+id).width='';
				document.getElementById('img'+id).height='';
				document.getElementById('img'+id).title='';
				document.getElementById('img'+id).style.display='block';
			}
		}
	}
	//Visibilite texte
	if (unvisible =='on') {
		document.getElementById('divLink'+id).style.display='none';
	} else {
		document.getElementById('divLink'+id).style.display='block';
	}
	//alignement du texte
	if (align != '' ) {
		document.getElementById('divLink'+id).style.textAlign=align;
	} else {
		document.getElementById('divLink'+id).style.textAlign='left';
	}
	//Cadre
	if (borderstyle != '')
	{
		if (borderpcolor != '' && borderpcolor != 'none') {
			document.getElementById('divLink'+id).style.border=borderpx+'px '+borderstyle+' '+borderpcolor;
		} else {
			if (bordercolor != '' && bordercolor != 'none') {
				document.getElementById('divLink'+id).style.border=borderpx+'px '+borderstyle+' '+bordercolor;
			} else {
				document.getElementById('divLink'+id).style.border=borderpx+'px '+borderstyle+' black';
			}
		}
	}
	//Marge 
	if (bordermg != '') {
		document.getElementById('spanLink'+id).style.padding=bordermg+'px' ;
	} else {
		document.getElementById('spanLink'+id).style.padding='0px' ;
	}
	//Curseur  -->
	document.getElementById('divLink'+id).style.cursor=isIE()? 'hand' : 'pointer';
	//Class du texte
	if (font != '') {
		document.getElementById('spanLink'+id).className=font;
	} else {
		document.getElementById('spanLink'+id).className= 'wuDefaultText';
	}
	//Couleur du texte
	if (pcolor != '' ) {
		document.getElementById('spanLink'+id).style.color=pcolor;
	} else {
		if (color != 'none' && color != '') {
			document.getElementById('spanLink'+id).style.color=color;
		}
	}
	//Couleur de fond du texte
	if (bgpcolor != '' ) {
		document.getElementById('spanLink'+id).style.backgroundColor=bgpcolor;
	} else {
		if (bgcolor != 'none' && bgcolor != '') {
			document.getElementById('spanLink'+id).style.backgroundColor=bgcolor;
		}
	}				
	//soulignement 
	if (textdecoration != '' ) {
		document.getElementById('spanLink'+id).style.textdecoration=textdecoration;
	}
	//bold du texte
	if (fontweight != '' ) {
		document.getElementById('spanLink'+id).style.fontWeight=fontweight;
	}
	//italique du texte
	if (fontstyle != '' ) {
		document.getElementById('spanLink'+id).style.fontStyle=fontstyle;
	}
	//taille du texte
	if (textsize != '' ) {
		document.getElementById('spanLink'+id).style.fontSize=textsize;
	}
	
}

function changeStatus(obj, imgOpen, imgClose, ArboID, wuOpenObjects) {	
	document.getElementById(obj).style.display = document.getElementById(obj).style.display == "none" ? "block" : "none";
	document.getElementById('i'+obj).src = document.getElementById(obj).style.display == "none" ? imgClose : imgOpen;	
	if (document.getElementById(obj).style.display == "none") {
		 wuOpenObjects = wuOpenObjects.replace(obj, "");
	} else {
		if (wuOpenObjects.indexOf(obj) <= 0) {
			wuOpenObjects += obj;
		}
	}	
	document.getElementById('wuTempOpenObjects_'+ArboID).value = wuOpenObjects;
	doRequest('wuOpenArbo.php?arboID='+ArboID+'&wuOpen='+wuOpenObjects , 'wuDivOpenObjects_'+ArboID );					
}

function navAgenda(opp, agID) {
  doRequest('wuAjax.php?phpFile=plugins/agenda/wuAgenda-utils.php&location=1&agID='+agID+'&action=nav&opp='+opp, 'wuAgenda_'+agID);				
}

function detailAgenda(div, agID, events, widthDiv, masqueBgColor, masqueOpacity) {
  if (isIE()) {
    //alert(document.body.clientHeight); 
    if(document.body.clientHeight > document.getElementById('index').offsetHeight) var height = document.body.clientHeight;
    else var height = document.getElementById('index').offsetHeight;
    var width = document.body.offsetWidth + document.body.scrollLeft;
    document.getElementById(div).style.left = document.body.scrollLeft + (document.body.offsetWidth - widthDiv) / 2;
    document.getElementById(div).style.top = document.body.scrollTop + 50;
    document.getElementById('masque').style.filter = 'alpha(opacity='+masqueOpacity+')';
  } else {
    //alert(window.innerHeight); 
    if(window.innerHeight > document.height) var height = window.innerHeight;
    else var height = document.height;
    var width = document.width;
    document.getElementById(div).style.left = window.pageXOffset + (window.innerWidth - widthDiv) / 2;
    document.getElementById(div).style.top = window.pageYOffset + 50;
    document.getElementById('masque').style.opacity = '0.5';
  }
  document.getElementById('masque').style.width = width+'px';
  document.getElementById('masque').style.height = height+'px';
  document.getElementById('masque').style.backgroundColor = masqueBgColor;
  document.getElementById('masque').style.zIndex = '3000';
  document.getElementById('masque').style.left = 0;
  document.getElementById('masque').style.top = 0
  document.getElementById(div).style.zIndex = '5000';
  document.getElementById(div).style.display = 'block'; 
  doRequest('wuAjax.php?phpFile=plugins/agenda/wuAgenda-utils.php&location=1&agID='+agID+'&action=detail&events='+events, div);  
}
function closeDetailAgenda(div) {
  document.getElementById(div).style.display = 'none';
  document.getElementById('masque').style.width = 0;
  document.getElementById('masque').style.height = 0;
}
var defil = '1';
function defilDiv(div, sens) {
  if(defil == '1') {
    var scroll = document.getElementById(div).scrollTop;
    if(sens == 'top') { var newScroll = scroll - 5; }
    if(sens == 'bottom') { var newScroll = scroll + 5; }
    document.getElementById(div).scrollTop = newScroll;  
    setTimeout("defilDiv('"+div+"', '"+sens+"')", 100);
  }
}
function clickDefilDiv(div, sens) {
  var scroll = document.getElementById(div).scrollTop;
  if(sens == 'top') { var newScroll = scroll - 75; }
  if(sens == 'bottom') { var newScroll = scroll + 75; }
  document.getElementById(div).scrollTop = newScroll;  
}
function startDefil(div, sens) {
	defil = '1';
	defilDiv(div, sens);
}
function stopDefil() {
	defil = '0';
}

