$(document).ready(function() {
	//Annulation du click sur remorque
	$("#menu .horizontal a:eq(2)").click(function() {
		return false;
	});
	
	//Gestion du menu déroulant
	$("#menu .horizontal a:eq(2)").mouseover(function() {
		if($(this).hasClass("selected")) {
			$("#menu .remorque").css("display", "block");
		}
		else {
			$(this).css("background", "url(http://sun-way.fr/images/menu/bck_hover.png) repeat-x");
			$("#menu .remorque").css("display", "block");
		}
	});
		
	$("#menu .remorque").mouseover(function() {
		$(this).css("display", "block");
		$("#menu .horizontal a:eq(2)").css("background", "url(http://sun-way.fr/images/menu/bck_hover.png) repeat-x");
	});
		
	$("#menu .horizontal a:eq(2)").mouseout(function() {
		if($(this).hasClass("select")) {
			$("#menu .remorque").css("display", "none");
		}
		else {
			$(this).css("background", "url(http://sun-way.fr/images/menu/bck.png) repeat-x");
			$("#menu .remorque").css("display", "none");
		}
	});
		
	$("#menu .remorque").mouseout(function() {
		if($("#menu .horizontal a:eq(2)").hasClass("select")) {
			$(this).css("display", "none");
		}
		else {
			$(this).css("display", "none");
			$("#menu .horizontal a:eq(2)").css("background", "url(http://sun-way.fr/images/menu/bck.png) repeat-x");
		}
	});
	
	
		//Annulation du click sur remorque
	$("#menu .horizontal a:eq(3)").click(function() {
		return false;
	});
	
	//Gestion du menu déroulant
	$("#menu .horizontal a:eq(3)").mouseover(function() {
		if($(this).hasClass("selected")) {
			$("#menu .international").css("display", "block");
		}
		else {
			$(this).css("background", "url(http://sun-way.fr/images/menu/bck_hover.png) repeat-x");
			$("#menu .international").css("display", "block");
		}
	});
		
	$("#menu .international").mouseover(function() {
		$(this).css("display", "block");
		$("#menu .horizontal a:eq(3)").css("background", "url(http://sun-way.fr/images/menu/bck_hover.png) repeat-x");
	});
		
	$("#menu .horizontal a:eq(3)").mouseout(function() {
		if($(this).hasClass("select")) {
			$("#menu .international").css("display", "none");
		}
		else {
			$(this).css("background", "url(http://sun-way.fr/images/menu/bck.png) repeat-x");
			$("#menu .international").css("display", "none");
		}
	});
		
	$("#menu .international").mouseout(function() {
		if($("#menu .horizontal a:eq(3)").hasClass("select")) {
			$(this).css("display", "none");
		}
		else {
			$(this).css("display", "none");
			$("#menu .horizontal a:eq(3)").css("background", "url(http://sun-way.fr/images/menu/bck.png) repeat-x");
		}
	});
	
	
	//Gestion des inputs
	$(".autoEmpty").each(function() {
		var defaultText = $(this).val();
		$(this).focus(function() {
			if($(this).val() == defaultText) {
				$(this).val("");
			}
		});
		$(this).blur(function() {
			if($(this).val() == "") {
				$(this).val(defaultText);
			}
		});
	});
	
	//Changement de langue
	var url = document.location.href;
		
	$("#bck_header a").each(function() {
		if($(this).hasClass("langue_en")) {
			url = url.replace("sun-way.fr/", "sun-way.fr/en/");
			$(this).click(function() {
				window.location.href=url;
				return false;
			});
		}

		else if($(this).hasClass("langue_fr")) {
			url = url.replace("sun-way.fr/en/", "sun-way.fr/");
			$(this).click(function() {
				window.location.href=url;
				return false;
			});
		}
	});
});


//Ouverture popup
function openPopup(url, width, height) {
	var nbTop = (screen.height - height) / 2;
	var nbLeft = (screen.width - width) / 2;
	var winPopup = window.open(url, "", "top="+nbTop+", left="+nbLeft+", width="+width+", height="+height); 
}
