var url = String(document.location);
var dev = false ;
if(url.indexOf("z6creation.net") >=0 ){
	var dev = true;
}
window.onload = function() { 
	try{
		$('cp').observe('change', searchDep);
		$('cp').observe('blur', searchDep);
		$('country').observe('change', searchDep);
	}catch(e){}

}

function searchDep(){
	//var url = "http://www.batimentsmoinschers.com/devis/check_dep.php?codepost="+$F('cp')+"&pays="+$F('country'); //url distant
	url = "";
	if(dev){ url = "/www.easybuilding.eu"; }
	url += "/devis/check_dep.php?codepost="+$F('cp')+"&pays="+$F('country'); // local
	
	if(($F('cp') != "") && ($F('country') != "")){
		new Ajax.Request(url, { 
			method: 'get',
			onSuccess: function(transport) {
				notificationDepartement(transport.responseText);
			}
		});
	}	
}

function notificationDepartement(zoneGeo){
		
		if(lang == 'fr'){ var text = "<br /><strong>Prix du transport : </strong><p style='font-size:11px;'>Le prix du transport sera calcul&eacute; en fonction de la zone g&eacute;ographique suivante : </p><strong style='text-align:center'>"+zoneGeo+"</strong>"; }	
		if(lang == 'en'){ var text = "<br /><strong>Transport prices : </strong><p style='font-size:11px;'>The fare will be calculated based on the geographical area as follows: </p><strong style='text-align:center'>"+zoneGeo+"</strong>"; }
		
		if($('name_dep')){
			//div existe
			if(zoneGeo != ""){
				$('name_dep').innerHTML = text;
				if($('name_dep').hasClassName('up')){
					Effect.BlindDown('name_dep');
					$('name_dep').removeClassName("up");
				}
			}else{
				try{
					Effect.BlindUp('name_dep');
					$('name_dep').addClassName("up");
				}catch(e){}
				return;
			}
		}else{
			//div n'existe pas
			if(zoneGeo != ""){
				$('fieldvalue_country').insert({after: '<br /><div id="name_dep" style="font-size:12px;display:none;width:389px;margin-top:0px;padding:0px 10px 0px 10px; height:70px;border:1px solid #ee8116;color:#222;">'+text+'</div>'})
				Effect.BlindDown('name_dep'); return false;	
			}	
		}
}
