// JavaScript Document
  <!--
  
////////////////////////////////////////////////////////////////////////////  
//*************************** Flash function *****************************//
////////////////////////////////////////////////////////////////////////////
var player = null;
function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
	addListeners();
}

function afficheType(){
	$("#info_type").slideDown("slow",function(){
 		$(".blocType").slideDown("fast");
 	});
}	

function afficheInfo(type){
	$("#infoTrajet").show();
}  	
function recherche(pays, type, lang, variable){
	$("#rechercheTrajet").show();
	$("#pays").text(pays);
}
function addListeners() {
	if (player) { 
		player.addModelListener("TIME", "timeListener");
	} else {
		setTimeout("addListeners()",100);
	}
}
function timeListener(obj) {
	if(obj.position == (obj.duration-0.2)){
		player.sendEvent("PLAY",false);
	}
}

function flashPlayer(file,width, height, name , div, params, flashvars, version ) {
	
		var attributes = {id:name,  name:name}
        swfobject.embedSWF(file, div, width, height, version, false, flashvars, params, attributes);
}
	

	function deleteVideo(theWrapper, thePlaceholder, thePlayerId) { 
		swfobject.removeSWF(thePlayerId);
		var tmp=document.getElementById(theWrapper);
		if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; }
	}


	
	
	
	
////////////////////////////////////////////////////////////////////////////
//*********************** Fin Flash function *****************************//
////////////////////////////////////////////////////////////////////////////


var obj = null;
	function checkHover() {
		if (obj) {
			obj.find('dl').fadeOut('fast');	
		} //if
	} //checkHover

$(document).ready(function(){


////////////////////////////////////////////////////////////////////////////
//*************************** Venir function *****************************//
////////////////////////////////////////////////////////////////////////////
	function initAffichage(){
		$("#info_type").hide();
		$(".blocType").hide();
		$("#infoTrajet").hide();
		$(".avion").hide();
		$(".bateau").hide();
		$("#rechercheTrajet").hide();
	}

	$('.testaffichage').click(function() {
			afficheType();
			return false;
			
	});

	$(function(){
		initAffichage();
		swfobject.removeSWF('player1');
		var tmp=document.getElementById('wrapper2');
		if (tmp) { tmp.innerHTML = '<div id="carteVenir"></div>'; }
		
		
		flashPlayer("http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/carte_venir.swf",389, 333, "player1" , "carteVenir", {allowfullscreen:"true", allowscriptaccess:"always",wmode:"transparent"}, {},"8" );
	});
	
	$(".blocType  a, #infoTrajet a").click(function(){
		var lang ="fr";
		var path="flash"
			
			 
		swfobject.removeSWF('player1');
		var tmp=document.getElementById('wrapper2');
		if (tmp) { tmp.innerHTML = '<div id="europe"><div id="carteVenir"></div></div>'; }
			
		flashPlayer("http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/europe.swf",200, 237, "player1" , "carteVenir", 
			{
				allowfullscreen:"true", 
				allowscriptaccess:"always",
				wmode:"transparent"
			}, 
			{
				type:$(this).attr("href"),
				lang:lang,
				path:path
			}
			,"8" 
		);
	
		$('#info_type').hide();
		$('.blocType').hide();
		$("#rechercheTrajet").hide();
		$('#infoTrajet div').hide();
		$("."+$(this).attr("href")).show();
		$('.h2titre').text("Venir en Corse par "+$(this).attr("href"))
			
		$('#ariane').html('<img src="http://fr.franceguide.com/GetV4FO/Styles/Corse/images/pictos/ariane.gif" alt="" />  <a href="#">Accueil</a> :<a href="#">Venir</a> : <strong>Venir en Corse par '+$(this).attr("href")+'</strong>');
			
		return false;
	});

////////////////////////////////////////////////////////////////////////////
//*********************** Fin venir function *****************************//
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
//**************************** font function *****************************//
////////////////////////////////////////////////////////////////////////////
	var arrStyle = ["body","h1", "h2", "#menu", "#menu_lang", "div.drawer-handle"];
	$(".increaseFont").click(function(){
		var increase = 2;
		
		$.each( arrStyle, function(i, n){
			var current = $(n).css('font-size');
			var currentNum = parseFloat(current, 10);
			var newSize = currentNum+increase;
			$(n).css('font-size', newSize);
		});
		return false;
  });
	
  // Decrease Font Size
  $(".decreaseFont").click(function(){
  	var increase = 2;
   $.each( arrStyle, function(i, n){
	
		var current = $(n).css('font-size');
		var currentNum = parseFloat(current, 10);
		 var newSize = currentNum-increase;
		 $(n).css('font-size', newSize);
	});
    return false;
  });

////////////////////////////////////////////////////////////////////////////
//*********************** fin  font function *****************************//
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
//*************************** menus function *****************************//
////////////////////////////////////////////////////////////////////////////



	

	$('.flecheLang > img').click(function() {
		$("#menu_lang").slideDown('fast');
		
	});
	
	$('#menu_lang').hover(function() {
		
		}, function() {
		setTimeout(function() {
                $("#menu_lang").slideUp('fast')
            },500);
	});
	
	$('#Nav > li').hover(function() {
		if (obj) {
			obj.find('dl').fadeOut('fast');
			obj = null;
		} 
		
		$(this).find('dl').fadeIn('fast');
	}, function() {
		obj = $(this);
		setTimeout(
			"checkHover()",
			0);
	});
	
////////////////////////////////////////////////////////////////////////////
//************************ fin menu function *****************************//
////////////////////////////////////////////////////////////////////////////	


	$(function(){ 
		$(".addCarnet").click(function(){
			if($(".addCarnet img").attr("src") == "http://fr.franceguide.com/GetV4FO/Styles/Corse/images/pictos/ajouter.png"){
				
				$(".message").css("display", "block");
			
				$(".message").append('L’information a été rajoutée à votre carnet de voyages. Vous pouvez consulter votre carnet en cliquant sur le bouton ci-dessous');
				
				
				$(".message").css("top", $(".action").offset().top - $(".message").height()-20);
				$(".message").css("left", $(".action").offset().left - $(".message").width()/2);
		
				setTimeout(function() {
							$(".message").fadeOut('fast')
						},5000);
				$(".addCarnet img").attr({ src: "http://fr.franceguide.com/GetV4FO/Styles/Corse/images/pictos/carnet.png" });
			}else{
			
			
			}
			return false;
		})
	});
	$(function(){ 

		 $(".smallOnglet:eq(0)").addClass('on'); 
		
	}); 

	$(function(){ 
		$("#formRecherche .smallOnglet a").click(function(){ 
			$(".smallOnglet").removeClass("on");
			$(this).parent(".smallOnglet").addClass("on"); 
			$(".ongletContent").hide(); 
			$(this.hash).show(); 
			this.blur(); 
			return false; 
		}); 
	}); 
	$(function(){ 
		$(".items").click(function(){
		if($(this.hash).attr("src") == "http://fr.franceguide.com/GetV4FO/Styles/Corse/images/pictos/ajouter.png"){
			
			$(".message").css("display", "block");
		
			$(".message").text('L’information a été rajoutée à votre carnet de voyages. Vous pouvez consulter votre carnet en cliquant sur le bouton ci-dessous');
			
			
			$(".message").css("top", $(this.hash).offset().top - $(".message").height()-20);
			$(".message").css("left", $(this.hash).offset().left - $(".message").width()/2);
		
			setTimeout(function() {
						$(".message").fadeOut('fast')
					},2000);
			$(this.hash).attr({ src: "http://fr.franceguide.com/GetV4FO/Styles/Corse/images/pictos/carnet.png" });
			 return false;
		}else{
		$(this).attr({ href: "#" });
		
		}
		})
	});
	
	$(function() {
        $('.blocImage a').lightBox({
		imageLoading: 'http://fr.franceguide.com/GetV4FO/Styles/Corse/images/lightbox-ico-loading.gif',
		imageBtnClose: 'http://fr.franceguide.com/GetV4FO/Styles/Corse/images/lightbox-btn-close.gif',
		imageBlank : 'http://fr.franceguide.com/GetV4FO/Styles/Corse/images/lightbox-blank.gif'
	   });
    });
	
	
	$(function(){
			$('#rechercheAvance').hide();   
	$('.critere a').toggle(function(){
				$('#rechercheAvance').slideDown("fast",function(){$(".blocRecherche").backgroundCanvasPaint(blocCanvas); });	
				$(this).css('background-position','120px -50px' )
		}, function(){
				$('#rechercheAvance').slideUp("fast",function(){$(".blocRecherche").backgroundCanvasPaint(blocCanvas); });	
				$(this).css('background-position','120px 10px' )	
		});
	});
	
	
	$(".infoRegion").hide();
	$("#menuAncre a").toggle(function(){
		$("#menuAncre  a").css("color", "#6a6a6a");
		$("#menuAncre span").css("color", "#fbbd1e");
		$(this).css("color", "#0063ac");
		$("#introRegion").hide();
		$(".infoRegion").hide();
		$(this.hash).show()
		 
		$("#menuAncre span").click(function(){
			$("#introRegion").show();
			$(".infoRegion").hide();
			$("#menuAncre  a").css("color", "#6a6a6a");
			$("#menuAncre span").css("color", "#0063ac");
		});
		
		$("#menuAncre span").hover(function(){
			if($("#introRegion").css("display") == "none"){
				$(this).css("text-decoration", "underline");
				$(this).css("cursor", "pointer");
			}else{
				$(this).css("text-decoration", "none");
				$(this).css("cursor", "auto");
			}
		 },function(){
			$(this).css("text-decoration", "none");
			$(this).css("cursor", "auto");
		 });
	 
	 },function(){ 
		if($(this.hash).css("display") == "none"){
			$("#menuAncre  a").css("color", "#6a6a6a");
			$("#menuAncre span").css("color", "#fbbd1e");
			$(this).css("color", "#0063ac");
			$("#introRegion").hide();
			$(".infoRegion").hide();
			$(this.hash).show()
		}else{
			$("#menuAncre span").css("color", "#0063ac");
			$("#menuAncre  a").css("color", "#6a6a6a");
			$(".infoRegion").hide();
			$("#introRegion").show();
		}
	});
	
	
	$(function(){ 
		$(".onglet:eq(0)").addClass('on'); 
		$("#espacePerso .onglet a").click(function(){ 
		
			$(".onglet").removeClass("on");
			
		//$(".smallOnglet").removeClass("off");
		
			$(this).parent(".onglet").addClass("on"); 
			$(".ongletContent").hide(); 
			$(this.hash).show(); 
			this.blur(); 
			return false; 
		}); 
	}); 
	
	$(".ongletContent").backgroundCanvas(); 
	$(".blocEspace").backgroundCanvas(); 
	$(".blocRecherche").backgroundCanvas(); 
	//$("#sommaire .bloc").backgroundCanvas(); 
	
});



$(window).load(function (){ 
						 
	///// flash home //////
	flashPlayer("http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/player.swf",780, 264, "bandeau_home" , "bandeau_home", 
				 {allowfullscreen:"true", allowscriptaccess:"always",wmode:"transparent"}, 
				 {file:"http://fr.franceguide.com/GetV4FO/Styles/Corse/video/essai.swf", 
					image:"http://fr.franceguide.com/GetV4FO/Styles/Corse/video/animation10.jpg",
					autostart:true,
					displayclick:"next",
					controlbar:"none",
					skin:"http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/overlay.swf",
					screencolor:"#FFFFFF",
					resizing:"true",
					bufferlength:10 }
				 ,"8" );
	
	 ///// flash region //////
	 flashPlayer("http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/region_v2.swf",494, 370, "region" , "flashRegion", {allowfullscreen:"true", allowscriptaccess:"always",wmode:"transparent"}, {xml:"http://fr.franceguide.com/GetV4FO/Styles/Corse/flash/region.xml",lang:"fr" },"8" );
	
	 DrawBackground(); 
	$(".ongletContent").not(":first").hide(); 
});

function DrawBackground()
{
	$(".ongletContent").backgroundCanvasPaint(blocCanvas); 
	$(".blocEspace").backgroundCanvasPaint(blocCanvas); 
	$(".blocRecherche").backgroundCanvasPaint(blocCanvas);  
	//$("#sommaire .bloc").backgroundCanvasPaint(blocCanvasRound);  

}

// creation des dégradés
function blocCanvasRound(context, width, height, canvas, $canvas, $canvasDiv, $content, $element ) 
{
		var options = {x:0, height: height, width: width, radius:5,   border: 0 };
		var backgroundGradient = context.createLinearGradient(0, 0, 0, height);
		backgroundGradient.addColorStop(0 ,'#ffffff');
		backgroundGradient.addColorStop(1, '#e9e9e9');
		context.fillStyle = "#b2b2b2";
		
		// Draw the blue border rectangle 
		$.canvasPaint.roundedRect(context,options);
		
		// Draw the gradient filled inner rectangle
		options.border = 1;
		context.fillStyle = backgroundGradient; 
		$.canvasPaint.roundedRect(context,options);
}
function blocCanvas(context, width, height, canvas, $canvas, $canvasDiv, $content, $element ) 
{
		var options = {x:0, height: height, width: width, radius:0, radiusBL: 5,radiusBR: 5,  border: 0 };
		var backgroundGradient = context.createLinearGradient(0, 0, 0, height);
		backgroundGradient.addColorStop(0 ,'#ffffff');
		backgroundGradient.addColorStop(1, '#e2e2e2');
		context.fillStyle = "#b2b2b2";
		
		// Draw the blue border rectangle 
		$.canvasPaint.roundedRect(context,options);
		
		// Draw the gradient filled inner rectangle
		options.border = 1;
		context.fillStyle = backgroundGradient; 
		$.canvasPaint.roundedRect(context,options);
}

// Création des arrondis des blocs
$(function() {
	$("#accesPro").corner("5px top");
	$("#tourismeAffaire").corner("5px top");
	$("#titleBack").corner("10px top");
	$("#decouvrir").corner("10px top");
	$("#F_droite h1").corner("10px top");
	$("#actualite").corner("7px");
	$("#lang").corner("5px");
	$("#envie .bloc").corner("7px");
	$("#meteo").corner("7px");
	$("#espace").corner("7px");
	$("#search").corner("7px");
	$(".blocRegion").corner("5px");
	$(".offre").corner("5px");
	$(".cadreBleu").corner("5px");
	$(".infoPage").corner("5px");
	$("#menuAncre").corner("5px");
	$("#menuaAncre").corner("5px");
	$(".onglet").corner("5px top");
	$(".smallOnglet").corner("5px top");
	$(".map").corner("5px top");
	$(".message").corner("5px");
	$("#sommaire .bloc").corner("5px top");
	

	
	
});


//Accordion menu droit
$(function () {
	$('ul.drawers').accordion({
		active: true, 
		header: 'div.drawer-handle', 
		alwaysOpen: false,
		selectedClass: 'open',
		navigation: true, 
		autoHeight: false,
		event: 'click'
	});
});
	
    //-->    
