window.targetUrlDomain = 'lsa';

/* fonction qui remplace la value en valeur vide du champ input text */
function changeCouleurRecherche(champ) {
	if (champ.value == 'Saisissez votre recherche')
		champ.value = '';
}

function changeTextHeaderNewsLetter(champ) {
	if (champ.value == 'Votre e-mail')
		champ.value = '';
}

var recHead = true;
function inputRecherche(recherche) {
	if (recHead == true && recherche.value == 'Saisissez votre recherche') {
		recHead = false;
		recherche.value = '';
		recherche.className = 'inputTextHead';
	}
}

/* fonction de popup des outil des articles */
function montre(id) {
var d = document.getElementById(id);
     for (var i = 1; i<=80; i++) {
          if (document.getElementById('popdiv'+i)) {document.getElementById('popdiv'+i).style.display='none';}
     }
	if (d) {d.style.display='block';}
}

function onlyNumericKeyPress(input) {
	console.debug(input);
	if (input) {
		console.debug(new String(input.value).replace(/[^0-9]+/, ''));
		input.value = new String(input.value).replace(/[^0-9]+/, '');
	}
	return true;
}

function outilReseau(id){
	if (document.getElementById(id).className == "visible"){
		document.getElementById(id).className = "invisible";
	}
	else {
		document.getElementById(id).className = "visible";	
	}
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

function closeTimer(){   //Timer de 5 secondes (5000 milisecondes)
   timeoutID = setTimeout("document.getElementById('envoieArticleReaction').className='invisible'",5000);
}

function closeTimer2(){   //Timer de 5 secondes (5000 milisecondes)
   timeoutID = setTimeout("document.getElementById('envoieArticleReaction2').className='invisible'",5000);
}

// Vérification du mot de passe
function testMotCle(champ){
	if (champ.value.length == 0){
		 return false;
	}
	else{ 
		if (champ.value == 'Saisissez votre recherche'){
			return false;
		}
		else{ 
			return true;
		}
	}
}

function urlencode(str) {

	var reg1 = / & /g;
	var reg2 = / /g;
	
    return (str.replace(reg1, '+').replace(reg2, '+'));
}

// V�rification du mot de passe
function testRecherche(form, root) {
	var recherche = form.q.value;
	if (form.numero) {
		var numero = form.numero.value;
	} else {
		numero = "";
	}
	if (form.date) {
		var date = '&date=' + form.date.value;
	} else {
		date = "";
	}
	if ((recherche.length == 0 || recherche == 'Saisissez votre recherche') && numero.length == 0 && date.length == 0){
		 return false;
	}
	else {
		if (recherche == 'Saisissez votre recherche') {
			recherche = '';
		}
		if (numero.length != 0) {
			if (numero != parseInt(numero)) {
				alert("Veuillez entrer un num\351ro valide");
				return false;
			} else  {
				numero = '&numero=' + numero;
			}
		}
		document.location.href = root + 'recherche=' + urlencode(recherche) + numero + date + '?sort=pertinence';
		return false;
	}
}

function in_array(needle, haystack, argStrict) {
    var key = '', strict = !!argStrict;

    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }

    return false;
}

function php_trim (str) {
	return String(str).replace(/((^\s*)|(\s*$))/, '');
}


function afficheconnexion(){
	var statusconnexion = document.getElementById('boite-connexion-contenu').style.display;
	
	if (statusconnexion == 'block') {
		document.getElementById('boite-connexion-contenu').style.display='none';
	}
	else {
		document.getElementById('boite-connexion-contenu').style.display='block';
		}
}

function soumettre(id,cible){
	document.getElementById(id).target = "_blank";
	window.open(cible, '_blank');
}
