//var	path_modules	=	'http://bacchus/www.operanationaldurhin.fr/modules/';
var deployLocation = false;
var deployType = false;
var deployMain = false;

$(document).ready(function() {

	if ( $("#errorPad") )
	{
		$("#errorPad").click(function(){
			$(this).css('display', 'none');
			$("#erlogPad").css('display', 'none');
		});
		$("#erlogPad").click(function(){
			$(this).css('display', 'none');
			$("#errorPad").css('display', 'none');
		});
	}
	
	$(".type_spec").mouseenter(function(){
		$(".filterByType").slideDown();
		deployType = true;
	});
	$(".type_spec").mouseleave(function(){
		if (deployType == true)
		{
			$(".filterByType").slideUp();
			deployType = false;
		}
	});
	$(".filterByType").mouseleave(function(){
		$(".filterByType").slideUp();
	});
	
	
	
	$(".lieu").mouseenter(function(){
		$(".filterByLocation").slideDown();
		deployLocation = true;
	});
	$(".lieu").mouseleave(function(){
		if (deployLocation == true)
		{
			$(".filterByLocation").slideUp();
			deployLocation = false;
		}
	});
	$(".filterByLocation").mouseleave(function(){
		$(".filterByLocation").slideUp();
		
	});
	
	
	
	
	$(".launchVid").click(function(){
		$(".wrapper-video-IE").css('display','block');
		$("#inner-video-IE").css('display','block');
	});
	
	$(".wrapper-video-IE").click(function(){
		$(".wrapper-video-IE").css('display','none');
		$("#inner-video-IE").css('display','none');
	});
	
	$(".test").mouseenter(function(){
		var elem = $(this).parent("li");
		
		if (elem.hasClass("sub") )
		{
			var toShow	=	elem.children("ul").attr('class').replace(" menu", "" );
			$('.panel-'+toShow).css('display','block');
			elem.children("ul").animate({width:'show'});
		}
	});
	$(".menu").children("li").mouseleave(function(){
		if ($(this).hasClass("sub") )
		{
			var toHide	=	$(this).children("ul").attr('class').replace(" menu", "" );
			$('.panel-'+toHide).css('display', 'none');
			$(this).children("ul").fadeOut('fast');
			
		}
	});
	
	
	$("#closeVideo").click( function() {
		$(".wrapper-video").fadeOut();
		$(".close-wrapper-video").fadeOut();
		$("#conteneur-video").css('left', '-50%');
		document.getElementById("innerVideo").echo("stopVideo");
	});
	
	$(".wrapper-video").click( function() {
		$(".wrapper-video").fadeOut();
		$(".close-wrapper-video").fadeOut();
		$("#conteneur-video").css('left', '-50%');
		document.getElementById("innerVideo").echo("stopVideo");
	});
	
	

	
	
	
});

function loadVideo(urlVid, widthVideo, heightVideo) {
		widthVideo = (widthVideo == undefined) ? flashvars.widthVid : widthVideo;
		heightVideo = (heightVideo == undefined) ? flashvars.heightVid : heightVideo;
	
		// -> Calcul position dynamique
		scrollTop 		= 	$(window).scrollTop();
		positionMiddle	=	Math.ceil(scrollTop + ($(window).height() / 2 ) );
    var newHeight = parseInt(heightVideo) + 30;
		
		$("#conteneur-video").css('width', parseInt(widthVideo));
		$("#conteneur-video").css('height', parseInt(heightVideo));
		
    playerMiddleX = 	Math.ceil($("#conteneur-video").width() / 2) * -1;
		playerMiddleY = 	Math.ceil($("#conteneur-video").height() / 2) * -1;
	
	// -> Placement des div
		// --> fond-noir
		$(".wrapper-video").css('top', scrollTop);
		
		// -> conteneur de la video
		$("#conteneur-video").css('top', positionMiddle);
		$("#conteneur-video").css('left', '50%');
		$("#conteneur-video").css('margin-left', playerMiddleX);
		$("#conteneur-video").css('margin-top', playerMiddleY);
		
		$(".close-wrapper-video").css('top', $("#conteneur-video").offset().top - 50);
		var posLeft = Math.ceil($(window).width() / 2) +  ($("#conteneur-video").width() / 2) - Math.ceil($(".close-wrapper-video").width());
		$(".close-wrapper-video").css('left', posLeft);
		
	// -> Affichage des divs
		$(".wrapper-video").fadeIn();
		$(".close-wrapper-video").fadeIn();
		$("#conteneur-video").fadeIn();
		
	// -> Appel Video
	  //urlVid = 'http://www.operanationaldurhin.eu.preprod/medias/File/_doc_dyn/french/aladin_bande-annonce1252403148.flv';
	  document.getElementById("innerVideo").echo(urlVid);
	 
		
		
		
		/*
		
	
	
		
	
		
		
		
		
		
	
		*/
}


function get_event_days(day)
{
	$('#day-'+day).toggleClass('event-highlight');
	var year 	=	$("#year_evt").attr('value');
	var month	=	$("#month_evt").attr('value');
	var date	=	year + '-' + month + '-' + day;
	$.get(
		path_modules+"agenda/ajax_calendrier.php",
		{ date: date, action:'getDaysEvent', iso_lang: iso_lang, id_lang: id_lang},
		function(data){
			if ($("#innerEvents").is(":visible")) {
				$("#innerEvents").fadeOut("slow", function(){ $("#innerEvents").html(data).fadeIn("slow"); });
			}
			else
			{
				$("#innerEvents").html(data).fadeIn("slow");
			}
			if ($(".calendarDetail").is(":hidden")) {
				$(".calendarDetail").animate({width:'toggle'},180);
			}
		}
	)
}



function resetPad(day)
{
	$('#day-'+day).toggleClass('event-highlight');
}

function updateCalendar(year, month, insIsoLang) {
	$.get(
		path_modules+"agenda/fcts_calendrier.php",
		{ year: year, month: month, conf: false, insIsoLang: insIsoLang },
		function(data){
			$("#event-calendar").html(data).fadeIn("slow");
		}
	)
}

function closeCalendar()
{
	$(".calendarDetail").fadeOut("slow");
}

function refreshCal(location)
{
	document.location=location;
}


function GetFocus(theElement)
{
	theElement.value="";
}

function GetBlur(theElement)
{
	if ( (theElement.value=="") && (iso_lang == 'fr') )
	{
		theElement.value="recherche";
	}
	else if ( (theElement.value=="") && (iso_lang == 'en') )
	{
		theElement.value="search";
	}
	else if ( (theElement.value=="") && (iso_lang == 'en') )
	{
		theElement.value="suche";
	}
}
