// JavaScript Document
function MM_goToURL(){var i,args=MM_goToURL.arguments;document.MM_returnValue=false;for(i=0;i<(args.length-1);i+=2)eval(args[i]+".location='"+args[i+1]+"'");}

/*horloge*/
var dd=new Date();
function parseDate(value){var a;a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\+\d{2}):(\d{2})$/.exec(value);if(a){return new Date(+a[1],+a[2]-1,+a[3],(+a[4]+parseInt(a[7],10)),+a[5],+a[6],0);}return value;}
function horloge_islande(){var hh=dd.getHours();var mm=((dd.getMinutes()<10)?'0':'')+dd.getMinutes();var ss=((dd.getSeconds()<10)?'0':'')+dd.getSeconds();$(".heure_islande").html(hh+':'+mm+':'+ss);dd.setSeconds(parseInt(ss,10)+1);}

function getMois(m){
	var m=parseInt(m,10);
	var mois=new Array("janvier","fevrier","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","decembre");
	return mois[m-1];
}

/*function testRechRap(){
	var value1=$('#rechRap_input_typeh').val();
	var value2=$('#rechRap_input_dateh').val();
	if((value1!="0")&&(value2!="00")){
		$('#rechRapValid').show('fade');		
	} else {
		$('#rechRapValid').hide();
	}
}*/


$(document).ready(function(){
	$('#newsletter button').button().find('span').css({'padding':'2px 5px'});
	/*MENU*/
	$('#menu1 ul').css('display','block');
	$('#menu1 > li').smoothMenu({direction:'horizontal', icon:false, ui:false, zIndex : 99}).closest('#menu1').css('display','block');
	
	$('#menu2 > li').smoothMenu({direction:'horizontal', ui:false, zIndex : 99});
	/**/
	$('#rechRap_ul_type a').click(function(){
		$('#rechRap_input_type').val($(this).html());
		$('#rechRap_input_typeh').val($(this).attr('rel'));
		$('#rechRap_input_addr').val($(this).attr('href'));
		
		$('#menu2 li#rechRap_li_type').smoothMenu('hide',200,1);		
		//testRechRap();
		return false;
	});
	$('#rechRap_ul_date a').click(function(){
		$('#rechRap_input_date').val($(this).html());
		$('#rechRap_input_dateh').val($(this).attr('rel'));
		$('#menu2 #rechRap_li_date').smoothMenu('hide',200,1);		      
		//testRechRap();
		return false;
	});
	$('#rechRap_button button').button();
	$('#rechRap_button button').click(function(){
		var value1=$('#rechRap_input_typeh').val();
		var value2=$('#rechRap_input_dateh').val();
		if( value2=='00'){
			MM_goToURL('parent',$('#rechRap_input_addr').val());
			return document.MM_returnValue;
		}		
		else{
			var addr=($('#rechRap_input_addr').val().replace(/(-c[0-9]+).htm$/gi,"-en-"+getMois(value2)+"$1"+'-m'+value2+'.htm'));			
			MM_goToURL('parent',addr);
			return document.MM_returnValue;
		}
		
	});
	//testRechRap();
	
	/**/
	if($( "#menu_voyages h3" ).lentgh>0){
		$( "#menu_voyages h3" ).click(function(){
			$( "#menu_voyages>ul" ).toggle(500);
		});
	}
		
	/*SLIDESHOW*/
	var affiche =-1;
	var maxLength = $("#home li").length;
		function afficheImage(){
			if(affiche==maxLength-1){
				affiche=0;
			} else{
				affiche += 1;
			};
			$(".diaporama li:eq("+affiche+")").fadeIn(1000, function(){setTimeout(cacheImage, 4500)});
		};
		function cacheImage(){
			$(".diaporama li:eq("+affiche+")").fadeOut(1000,afficheImage());
		};
	if(maxLength>1){
		
		for(i=0; i<maxLength;i++){
			$(".diaporama li:eq("+i+")").css('position','absolute').hide();
		}
		setTimeout(afficheImage,1000);
		
	}
	//
	$('#rechRap').hide();
	setTimeout(function(){
		$('#rechRap').show();
	},1000)
	
	$('img',$(this)).bind('contextmenu', function() {
      return false;
    });

	
		
});
$(window).load(function(){
	dd=parseDate($(".heure_islande#span").text());
	setInterval("horloge_islande()",1000);
	setTimeout(function(){$(".footer iframe").attr('allowtransprency','true');},5000);
});
