

function clientRedirect(elem){
	if(elem.value.length != 0){
		document.location.href = elem.value;
	}
}

jQuery(document).ready(function() {

    try{jQuery('#mycarousel').jcarousel();}catch(e){};
    
    jQuery("#tabs").tabs();
    
    //focus sur le champ passe en parametre
	var fieldToFocus = getFocusField();
    if (fieldToFocus != "")
    {
    	document.getElementById(fieldToFocus).focus();
    }
	
	function getFocusField()
	{
	    param = window.location.search.slice(1,window.location.search.length);
	    first = param.split("&");
	    for(i=0;i<first.length;i++){
	        second = first[i].split("=");
	        if (second[0] == "focus")
	        {
	        	return second[1];
	    	}
	    }
	    return "";
	}
});

String.prototype.startsWith = function(str)
{
	return (this.match("^"+str)==str);
}

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

// Ajout ABY pour controle de la saisie des champs pour les demarches
function ctrlRechDem(formRechDemarche){
	var valProfil = document.formRechDemarche.profil.value;
	var valMMVie = document.formRechDemarche.momentDeVie.value;
	
	if ((valProfil != "") && (valMMVie != "")){
        alert("Veuillez choisir un profil ou un moment de vie pour effectuer la recherche.");
	    return false;
	}else{
		return true;
	}
}
