String.prototype.trim = function()
{
    return this.replace(/(?:^\s+|\s+$)/g, "");
}

function setRecherche(type,kw_default){
	switch(type){
		case 1:
			document.getElementById('recheText').value = kw_default;
			break;
		case 2:
			document.getElementById('rechEvnt').value = -1;
			document.getElementById('rechBenf').value = "";
			break;
	}
}

function recup_var(){
	var filename = "";
	var requete = window.location.search;
	if (requete) {
		requete=requete.substring(1);
		requete = unescape(requete);
		return(requete);
	}
}

function reinit(val, test){
	return val==test ? "": val;
}

function chgBan(num){
	i = 1;
	var disp = "";
	while(document.getElementById("home_image_" + i)){
		disp = i==num ? "block" : "none";
		document.getElementById("home_image_" + i).style.display = disp;
		i++;
	}
}

function arreter(id) {
	switch(id){
		case 1: window.clearTimeout(actif); break;
		case 2:	window.clearTimeout(actif2); break;
	}
}

function checkCAP(cap){
	var cap_test = new Array([88020,88100],[87010,87100],[88811,88900],[89010,89069],[89121,89135],[89812,89900],[90010,90049],[90121,90151],[91010,91100],[92010,92100],[93010,93100],[94010,94100],[95010,95049],[95121,95131],[96010,96100],[97010,97100],[98020,98079],[98121,98168],[08030,09049],[09121,09134],[09010,09017],[09020,09040],[08010,08100],[08037,08049],[07020,08020],[08010,09170],[07010,07100]);
	var min = 0;
	var max = cap_test.length;
	var tmp_cp = parseInt(cap);
	for(i=min;i<max;i++){
		if(cap_test[i][0]<=tmp_cp && tmp_cp<=cap_test[i][1])
			return true;
	}
	return false;
}

function fiscaliser(type,val1,val2){
	var disp = "none";
	var html = "";
	if(val1==null) val1 = "";
	if(val2==null) val2 = "";
	switch(type){
		case '0':
			disp = "none";
			html = "";
			break;
		case '1':
			html+= "Codice fiscale <input type='text' value='" + val1 + "' name='cf_membre' id='cf_membre' maxlength='16' />";
			disp = "block";
			break;
		case '2':
			//html+= "Codice fiscale <input type='text' value='" + val1 + "' name='cf_membre' id='cf_membre' maxlength='16' />";
			//html+= "&nbsp;Partita IVA <input type='text' value='" + val2 + "' name='iva_membre' id='iva_membre' maxlength='11' /> ";
			html+= "Se desiderate una fattura per la vostra azienda, non esitare a contattarci via mail";
			disp = "block";
			break;
	}
	document.getElementById('div_fisca').style.display = disp;
	document.getElementById('div_fisca').innerHTML = html;
}

function getRadioVal(r_name,r_min){
	var ret = "";
	if(r_min==null) r_min = 0;
	r_min--;
	while(document.getElementsByName(r_name)[++r_min]){
		if(document.getElementsByName(r_name)[r_min].checked)
			ret = document.getElementsByName(r_name)[r_min].value;
	}
	return ret;
}

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 is_numeric(num){
	var exp = new RegExp("^[0-9-.]*$","g");
	return exp.test(num);
}