function str_replace(search,replace,subject){var s=subject;var ra=r instanceof Array,sa=s instanceof Array;var f=[].concat(search);var r=[].concat(replace);var i=(s=[].concat(s)).length;var j=0;while(j=0,i--){if(s[i]){while(s[i]=(s[i]+'').split(f[j]).join(ra?r[j]||"":r[0]),++j in f){};}}
return sa?s:s[0];}

function substr(f_string,f_start,f_length){
	f_string += '';
	if(f_start<0) {
		f_start += f_string.length;
	}
}

function sUrlPropre(sString) {
	sString = sString.toLowerCase();
	var aSearch = ["à", "á", "â", "&agrave;", "À", "ç", "&ccedil;", "Ç", "é", "è", "ê", "ë", "É", "È", "&eacute;", "&egrave;", "&ecirc;", "í", "ï", "ï", "î", "ñ", "ô", "ò", "ö", "ô", "ó", "Ó", "ù", "û"];
	var aReplace = ["a", "a", "a", "a", "A", "c", "c", "C", "e", "e", "e", "e", "E", "E", "e", "e", "e", "i", "i", "i", "n", "o", "o", "o", "o", "o", "O", "u", "u"];
	sString = str_replace("à", "a", sString);
	sString = str_replace("á", "a", sString);
	sString = str_replace("â", "a", sString);
	sString = str_replace("é", "e", sString);
	sString = str_replace("è", "e", sString);	
	sString = str_replace("î", "i", sString);

	aSearch = [" ", "&", ":", ";", ".", "?", "!", "'", ",", "`", "'", "\"", "\/", "\\", "--"];
	aReplace = ["-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"];
	sString = str_replace(aSearch, aReplace, sString);
	// si la derniere lettre du mot est un - on le supprime
	var sDerniere = substr(sString, -1, 1);
	if(sDerniere == '-') {
		sString = substr(sString, 0, -1);
	}
	return sString;	
}

function getXhr(){
	var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else { // XMLHttpRequest non support� par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		xhr = false; 
	} 
	return xhr;
}
var country_adresse = '';

function getCountry(countryName, officeName){
	if (countryName != '')
		url = 'location-' + countryName;
	if (officeName != '')
		url = 'location-' + officeName;
	url += '.html';
	window.location = 'http://location-voiture.holidayautos.fr/' + url;
}

function changeLocation(country,city) {
	if (country == "none") return;
	getCountry(country,city);
}

function checkForm() {
	var tlocation = document.getElementById("start_city");
	if (tlocation.options[tlocation.selectedIndex].value == 'none') {
		return false;
	}
	var tdropoff = document.getElementById("stop_city");
	if (tdropoff.options[tdropoff.selectedIndex].value == "none")
		return false;
	return true;
}
