function switchImage(location, image) {
  document[location].src = image;
}

function OnClickCustom(myform) {
  //alert("**");
  //this.submit(); 
  myform.submit();
}

function SearchPostal(postal,langid) {
    var redirect_url;
    redirect_url="/Succursales.aspx?";
    var arg_lang="langtype="+langid;
    var arg_postal= "&ReqAddress="+postal;
    window.location="http://"+location.hostname+redirect_url+arg_lang+arg_postal;
}
//Onglets Conseils d'ami
function tabCA(numero,id) {
    var redirect_url;
    var langtype;
    var arg_lang;
    var arg_section;
    var arg_id;
    var menu_id;
    langtype=getParameter('langtype');
    if ((langtype!='3084') && (langtype!='1033')){langtype='3084'}
    menu_id="&ekmensel=15074e5e_36_0_72_3";
    if (langtype=='1033') {menu_id="&ekmensel=15074e5e_36_0_406_3"; }
    redirect_url="/sante_conseils_ami.aspx?";
    arg_lang="langtype="+langtype;
    arg_section= "&sectionID="+numero;
    arg_id= "&id="+id
    window.location="http://"+location.hostname+redirect_url+arg_lang+arg_section+arg_id+menu_id;
}

function getParameter(paramName) {
	var currentUrl = window.location.search.toLowerCase()
	var strBegin = currentUrl.indexOf(paramName) + (paramName.length+1)
	var strEnd = currentUrl.indexOf("&",strBegin)

	if (strEnd==-1)
		strEnd = currentUrl.length

	return currentUrl.substring(strBegin,strEnd)
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 


/*function veriflength(postal){
	if (postal.value.length==3){
		document.getElementById('postal_last').focus();
	}
}*/

function ValidateEnterKey(postal,event,langid){
if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
    SearchPostal(postal,langid);
}

function clearText(field){
    if (field.defaultValue == field.value) {field.value = '';
    field.style.color = 'black';
    }
    //else if (field.value == '') field.value = field.defaultValue;

}
// MC 20/11/2007 - Valide la touche 'Enter' et lance la recherche (GJCHeader)
function checkKeycode(event,langid) {
    if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
       if (document.getElementById('txtSearchText').value!='') {
            //MC 22/01/2008 -  Empêche le double-submit
            if (event.preventDefault) { 
              event.preventDefault();  // FF
            }
            event.returnValue = false;  // IE
            var searchText = document.getElementById('txtSearchText').value;
            if (langid=='1033') {
                window.location.href="http://"+location.host+"/CorpSearch.aspx?searchtext=" + searchText + "&folderid=16&orderby=id&searchfor=html&orderdirection=ascending";
            }
            else{
                window.location.href="http://"+location.host+"/CorpRecherche.aspx?searchtext=" + searchText + "&folderid=16&orderby=id&searchfor=html&orderdirection=ascending";
            }
        }
    }
}
// MC 20/11/2007 - Lance la recherche sur le click du bouton (GJCHeader)
function CallSearch(langid) {
    if (document.getElementById('txtSearchText').value!='') {
      var searchText = document.getElementById('txtSearchText').value;
      if (langid=='1033') {
          window.location.href="http://"+location.host+"/CorpSearch.aspx?searchtext=" + searchText + "&folderid=16&orderby=id&searchfor=html&orderdirection=ascending";
      }
      else{
          window.location.href="http://"+location.host+"/CorpRecherche.aspx?searchtext=" + searchText + "&folderid=16&orderby=id&searchfor=html&orderdirection=ascending";
      }
    }
}

// MC 20/11/2007 - Consultation des archives (CorpDefault.aspx)
function CallArchive(theyear,theyearid) {
    window.location.href="http://"+location.host+"/CorpPresse_Coll_"+theyear+".aspx?coll_id="+theyearid;
}

