function showHidSubCity(select){
	
	object = document.getElementById("trips");
	link = document.getElementById("linkshowHidSubCity");
	
	
	if (object.style.display == 'block'){
		object.style.display = 'none';
		link.innerHTML = 'Montrer les zones';
		var file = "index.php?showHidSubCity=0";
	} else {
		object.style.display = 'block';
		link.innerHTML = 'Masquer les zones';
		var file = "index.php?showHidSubCity=1";
	}
	
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox
				xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else { // XMLHttpRequest non supporté par le navigateur
				alert("Problem of navigator, contact SUPPORT");
		}
			
		xhr_object.open("GET", file, true);
		xhr_object.send(null);
	
	return false;
}
/*************************************************************Popup*************************************************************/
// 0 = hidden; 1 = on screen
var popupStatus = 0;

// Popup display
function loadPopup(){
	// Loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#contentPopup").fadeIn("slow");
		popupStatus = 1;
	}
}

// Popup close with effect
function disablePopup(){
	// Close only if it on screen
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#contentPopup").fadeOut("slow");
		popupStatus = 0;
	}
}

// Centering popup
function centerPopup(){
	// Request data for centering
	// IE alternative for pageYOffset
	if(window.pageXOffset === undefined) {   
    	var offset = Math.round (document.documentElement.scrollTop);
    }else{
     	var offset = window.pageYOffset;
    }
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#contentPopup").height();
	var popupWidth = $("#contentPopup").width();
	// Centering calculation
	$("#contentPopup").css({
		"position": "absolute",
		"top": (windowHeight/2-popupHeight/2)+offset,
		"left": windowWidth/2-popupWidth/2
	});
	
	// Only need force for IE6
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


// Events listener
$(document).ready(function(){
	
	// Item click -> Popup on screen
	$('.blockEnd').click(function(){
		// Details page
		$("#insidePopup").load('lib/otherServices.php');
		// Centering
		centerPopup();
		// Display
		loadPopup();
		return false;
	});
	
	// Close link
	$(".linkClose").click(function(){
		disablePopup();
	});
				
	// Background click
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	// Escape key
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
