/* PERMET LA VALIDATION D'UN FORMULAIRE EN APPUYANT SUR LA TOUCHE ENTER */
function getCodeValue($arg) {
	if (event.keyCode == 13) document.forms[$arg].submit();
}

/* LECTURE DU COOKIKE ACCESSIBILITE pour les racourcies */
var res1 = '';
var res2 = '';
var res3 = '';
var res4 = '';

function GetCookie (nom)
{
  var arg = nom + "=";
  var alen = arg.length;
  var i = 0;
  
  while (i < document.cookie.length) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      var endstr = document.cookie.indexOf (";", j);
      if (endstr == -1) endstr = document.cookie.length;
      chaine = unescape (document.cookie.substring(j, endstr));
      var reg=new RegExp("[:]+", "g");
      var tableau=chaine.split(reg);
      res1 = tableau[0];
      res2 = tableau[1];
      res3 = tableau[2];
      res4 = tableau[3];
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
}
GetCookie('AVH');



function MajCookiesForm()
{
	var pathname='';
	var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
	var date_exp = new Date();
//date_exp.setTime(date_exp.getTime()+(365*24*3600*1000));
	date_exp.setTime(date_exp.getTime()+(5184000));
	var nomCookie='ScreenInfos';

	function EcrireCookie(nom, valeur) {
		var argv=EcrireCookie.arguments;
		var argc=EcrireCookie.arguments.length;
		var expires=(argc > 2) ? argv[2] : null;
		var path=(argc > 3) ? argv[3] : null;
		var domain=(argc > 4) ? argv[4] : null;
		var secure=(argc > 5) ? argv[5] : false;
		
		document.cookie=nom+'='+escape(valeur)+
		((expires==null) ? '' : ('; expires='+expires.toGMTString()))+
		((path==null) ? '' : ('; path='+path))+
		((domain==null) ? '' : ('; domain='+domain))+
		((secure==true) ? '; secure' : '');
	}
	
	EcrireCookie(nomCookie,screen.width,date_exp,myDomain);
}
MajCookiesForm();


/* DÉFINI LES RACCOURCIES CLAVIER POUR LES UTILISATEURS */
function getKey(keyStroke) {
  if (window.event.altKey) {
    var accessibilite = '';
    
		if (res1 != '' && res2 != '' && res3 != '' && res4 != '') { accessibilite = "?deficient="+res1+"&amp;tailleTexte="+res2+"&amp;colorTexte="+res3+"&amp;colorFond="+res4;	}
		var key = new Array();
		key['48'] = key['96'] = "http://www.avh.asso.fr/index.php"+accessibilite;
		key['49'] = key['97'] = "#contentRub";
		key['50'] = key['98'] = "#menuSite";
		key['51'] = key['99'] = "#sousmenu";
    key['52'] = key['100'] = "http://www.avh.asso.fr/rubriques/plan/plan_site.php"+accessibilite;
		key['53'] = key['101'] = "#search";
		key['54'] = key['102'] = "#top";
	
		isNetscape=(document.layers);
		eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
		//alert(eventChooser);
    //if (eventChooser == 97) window.location = key['97'];
		//which = String.fromCharCode(eventChooser).toLowerCase();
		for (var i in key) if (eventChooser == i) window.location = key[i];
	}
}
document.onkeydown = getKey;



/* LIENS EXTERNES */
function liensExt(link) {
  return window.open(link);
}


/* LIENS MENU de la COLONNE DE DROITE */
function linksOver(path_images_theme, optLI, i) {
  document.getElementById('menuID_span'+i).style.backgroundRepeat='no-repeat';
  document.getElementById('menuID_span'+i).style.backgroundColor='#E39D3C';
  document.getElementById('menuID_span'+i).style.backgroundImage='url('+path_images_theme+'picto_flecheMenu'+optLI+'.gif)';
  document.getElementById('menuID_span'+i).style.cursor='hand';
  document.getElementById('menuID'+i).style.color='#000';
  document.getElementById('menuID'+i).style.textDecoration='none';
}
function linksOut(i) {
  document.getElementById('menuID_span'+i).style.backgroundColor='';
  document.getElementById('menuID_span'+i).style.backgroundImage='';
  document.getElementById('menuID'+i).style.color='#FFF';
}
function linksOverBis(i) {
  document.getElementById('menuID'+i).style.color='#000';
  document.getElementById('menuID'+i).style.textDecoration='none';
}
function linksOutBis(i) {
  document.getElementById('menuID'+i).style.color='#FFF';
}
function LIover(path_images_theme, i) {
  document.getElementById('menuID_li'+i).style.backgroundColor='#E39D3C';
  document.getElementById('menuID_li'+i).style.backgroundImage='url('+path_images_theme+'picto_flecheMenuSelect.gif)';
}
function LIout(i) {
  document.getElementById('menuID_li'+i).style.backgroundColor='';
  document.getElementById('menuID_li'+i).style.backgroundImage='';
}


function linksOver2(i) {
  document.getElementById('menu2IDz'+i).style.color='#000';
  document.getElementById('menu2IDz'+i).style.textDecoration='none';
}
function linksOut2(i) {
  document.getElementById('menu2IDz'+i).style.color='#FFF';
}
function OLover(path_images_theme, i) {
  document.getElementById('menu2ID_ol'+i).style.backgroundColor='#E39D3C';
  document.getElementById('menu2ID_ol'+i).style.backgroundImage='url('+path_images_theme+'picto_flecheMenu3Select.gif)';
}
function OLout(i) {
  document.getElementById('menu2ID_ol'+i).style.backgroundColor='';
  document.getElementById('menu2ID_ol'+i).style.backgroundImage='';
}



function linksOverMenuLeft(path_images_theme, i) {
  document.getElementById('menuLeft'+i).style.backgroundRepeat='no-repeat';
  document.getElementById('menuLeft'+i).style.backgroundImage='url('+path_images_theme+'menu_serv'+i+'.gif)';
  document.getElementById('menuLeft'+i).style.backgroundColor='#E39D3C';
}
function linksOutMenuLeft(path_images_theme, i) {
  document.getElementById('menuLeft'+i).style.backgroundRepeat='no-repeat';
  document.getElementById('menuLeft'+i).style.backgroundImage='url('+path_images_theme+'menu2_serv'+i+'.gif)';
  document.getElementById('menuLeft'+i).style.backgroundColor='';
}
function SpanOverMenuLeft(i) {
  document.getElementById('linkID'+i).style.color='#FFF';
  document.getElementById('linkID'+i).style.textDecoration='none';
}
function SpanOutMenuLeft(i) {
  document.getElementById('linkID'+i).style.color='';
}




/* PAGE NOUS AIDER */
reg = new RegExp("(nous_aider)");
if (reg.test(location)==true) {
  window.onload=montre;
  window.onload=mbase;
}

function mplan(id) {
var d = document.getElementById(id);
	for (var i = 0; i<=10; i++) {
  if (document.getElementById('L'+i)) {document.getElementById('L'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function montre(id) {
var d = document.getElementById(id);
	for (var i = 0; i<=10; i++) {
  if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
    
function mbase() {
  if (document.getElementById('smenu0')) {
    link = document.location.href;
    lmax = link.length;
    file = link.substring(link.lastIndexOf('/')+1, lmax);
    if (file == "don.php" || file == "don_ponctuel_ligne.php") document.getElementById('smenu0').style.display='block';
  }
  if (document.getElementById('smenu3')) document.getElementById('smenu3').style.display='block';
}



/* PAGE NOUS AIDER - Réduction ISF */
function reductionISF() {
  don = document.getElementById('mydon').value;
  if (isNaN(don)) {
    document.getElementById('myreduc').value = "";
  }else{
    document.getElementById('myreduc').value = eval(don*0.75);
  }
}


