var COOKIE_LANGUE="CookieLangue";
var HOTKEY_OPENADMIN="Ctrl+g";
var HOTKEY_CLOSEADMIN="Ctrl+q";
var SITE_URL="/";
var HOTKEY_ANALYTICS="Ctrl+t";
var DOMAINE="http://www.golf-albret.fr";

$(document).ready(function(){

	var htkeyadmin = (HOTKEY_OPENADMIN)?HOTKEY_OPENADMIN:"Ctrl+g";
	$.hotkeys.add(htkeyadmin, function(){
		$.fn.colorbox({
		width:"80%",
		height:"80%",
		iframe:true,
		href:"http://www.golf-albret.fr/backme",
		opacity: 0.6,
		onClosed: function(){
				window.location.reload();
			}
		});
	});
	
	var htkeyclose = (HOTKEY_CLOSEADMIN)?HOTKEY_CLOSEADMIN:"Ctrl+q";
	$.hotkeys.add(htkeyclose, function(){
		$.fn.colorbox.close();
	}); 
	
	$("#BlocPlan").click(function(){
		return false;	//window.open("http://maps.google.fr/maps?f=q&source=s_q&hl=fr&geocode=&q=Le+Pusocq+-+47230+BARBASTE&sll=46.75984,1.738281&sspn=10.854382,19.753418&ie=UTF8&hq=&hnear=Pusocq,+47230+Barbaste,+Lot-et-Garonne,+Aquitaine&t=h&z=16");
	});

	$("a[rel='golf']").colorbox();
	$("a[rel='residence']").colorbox();
	
	/*PARCOURS*/
	
	$("#trou_start").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_start",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_start").css("display","block");
		return false;
	});
	$("#trou_1").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_1",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_1").css("display","block");
		return false;
	});
	$("#trou_2").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_2",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_2").css("display","block");
		return false;
	});
	$("#trou_3").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_3",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_3").css("display","block");
		return false;
	});
	$("#trou_4").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_4",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_4").css("display","block");
		return false;
	});
	$("#trou_5").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_5",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_5").css("display","block");
		return false;
	});
	$("#trou_6").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_6",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_6").css("display","block");
		return false;
	});
	$("#trou_7").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_7",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_7").css("display","block");
		return false;
	});
	$("#trou_8").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_8",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_8").css("display","block");
		return false;
	});
	$("#trou_9").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_9",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_9").css("display","block");
		return false;
	});
	$("#trou_10").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_10",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_10").css("display","block");
		return false;
	});
	$("#trou_11").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_11",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_11").css("display","block");
		return false;
	});
	$("#trou_12").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_12",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_12").css("display","block");
		return false;
	});
	$("#trou_13").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_13",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_13").css("display","block");
		return false;
	});
	$("#trou_14").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_14",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_14").css("display","block");
		return false;
	});
	$("#trou_15").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_15",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_15").css("display","block");
		return false;
	});
	$("#trou_16").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_16",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_16").css("display","block");
		return false;
	});
	$("#trou_17").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_17",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_17").css("display","block");
		return false;
	});
	$("#trou_18").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_18",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_18").css("display","block");
		return false;
	});
	

 	if($.cookie(COOKIE_LANGUE)==null){
		$.cookie(COOKIE_LANGUE,"fr");
		document.location.reload();
	}
	
	$(".ChangeEN").click(function(){
		$.cookie(COOKIE_LANGUE,"en");
		document.location.reload();
	});
	
	$(".ChangeFR").click(function(){
		$.cookie(COOKIE_LANGUE,"fr");
		document.location.reload();
	});
	
	$('#slideshow').cycle({fx: 'fade'});
	
	$('#meteo').weatherfeed(['FRXX5376']);
	$('#meteo-en').weatherfeed(['FRXX5376']);
	$('#meteo-london').weatherfeed(['UKXX0085']);
	$('#meteo-london-en').weatherfeed(['UKXX0085']);
	//$('#meteo').weatherfeed(['FRXX0135']);
	
	$(".pushPlan").click(function(){
		$("#BlocPlan").slideToggle();
		$(".pushPlan").css("display","none");
		$(".pushPlan2").css("display","block");
	});
	
	$(".pushPlan2").click(function(){
		$("#BlocPlan").slideToggle();
		$(".pushPlan2").css("display","none");
		$(".pushPlan").css("display","block");
	});
	
	$("#next_2").click(function(){
		$.fn.colorbox({
			width:'870',
			height:'720',
			inline:true,
			href:"#my_trou_2",
			onClosed: function(){
				$(".MyGolf").css("display","none");
			}
		});
		$("#my_trou_2").css("display","block");
		return false;
	});
	
	
	$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
		
	$('ul.gallery_demo').galleria({
		history   : true, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
			
			// fade in the image & caption
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
				image.css('display','none').fadeIn(1000);
			}
			caption.css('display','none').fadeIn(1000);
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// fade out inactive thumbnail
			_li.siblings().children('img.selected').fadeTo(500,0.3);
			
			// fade in active thumbnail
			thumb.fadeTo('fast',1).addClass('selected');
			
			// add a title for the clickable image
			image.attr('title','Next image >>');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// if thumbnail is active, fade all the way.
			var _fadeTo = _li.is('.active') ? '1' : '0.3';
			
			// fade in the thumbnail when finnished loading
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});
	
	$("#SubmitContact").click(function(){
	 var name = document.getElementById("f_contact_name").value;
	 var email = document.getElementById("f_contact_email").value;
	 var message = document.getElementById("f_contact_sms").value;
		if(name=="" || email=="" || message ==""){
			$("#callError").css("display","block");
			return false;
		}else{
			return true;
		}
		return false;
	});

});


