$(document).ready(function(){
	
	$("#footer .multiple").hover(
	function() {
		//alert($(this.children[1]));
		myUl = $(this).children()[1];
		myLIs = $(myUl).children();
		$(myLIs).each(function(index, item) {
			myULs = $(item).children()[1];
			console.log(myULs);
			 if($(myULs).css("display") == 'none'){ 
			 	$(myULs).fadeIn("slow"); 
			 } 	
		});
		
	},
	function(){
		$("#footer .nav ul.l3").fadeOut("fast");
	}
); 
	
	$(".freeContent ol li:first").addClass("first");
	$(".freeContent ol li:last").addClass("last");
	$('.freeContent ol li').each(function(){
		var _c = $(this).html();
		$(this).html("<p>"+_c+"</p>");
	});	
	$(".freeContent ol").addClass("customizedOL");
	
	
	// 	 tooltip
	$('div.popup-holder').each(function(){
		var _toltipHolder = $(this);
		_toltipHolder.mouseenter(function(){
			$(this).addClass('open-popup');
		}).mouseleave(function(){
			$(this).removeClass('open-popup');
		});
	});
	
	$(".externalControl .jCarouselLite").jCarouselLite({
	    visible: 5,
	    start: 0,
	    btnNext: ".externalControl .next",
	    btnPrev: ".externalControl .prev",
	    btnGo:
	    [".externalControl .1", ".externalControl .2",
	    ".externalControl .3", ".externalControl .4",
	    ".externalControl .5", ".externalControl .6",
	    ".externalControl .7", ".externalControl .8",
	    ".externalControl .9", ".externalControl .10",
	    ".externalControl .11", ".externalControl .12"]
	});
	
	/* PAGER */
	$(".paging ul li a.pagerItems").click(function() {
		$(".paging li").removeClass("active");
		//$(this.parentNode).addClass("active"); 
		cur = parseInt($(this).attr('current'));
		$(".paging li.pager"+cur).addClass("active");
		$("."+$(this).attr('context')).addClass("pagerHidden");
		$("."+$(this).attr('context')+$(this).attr('current')).removeClass("pagerHidden");
	});
	$(".paging ul li.prev a").click(function() {
		if($(".paging li.active a").attr('current') != 1){
			cur = parseInt($(".paging li.active a").attr('current'))-1;
			$(".paging li").removeClass("active");
			$(".paging li.pager"+cur).addClass("active"); 
			$("."+$(this).attr('context')).addClass("pagerHidden");
			$("."+$(this).attr('context')+cur).removeClass("pagerHidden");
		}
	});
	$(".paging ul li.next a").click(function() {
		if($(".paging li.active a").attr('current') != $(this).attr('pages')){
			cur = parseInt($(".paging li.active a").attr('current'))+1;
			$(".paging li").removeClass("active");
			$(".paging li.pager"+cur).addClass("active"); 
			$("."+$(this).attr('context')).addClass("pagerHidden");
			$("."+$(this).attr('context')+cur).removeClass("pagerHidden");
		}
	});
	
	$('.redirect-select').change(function() {
	  if($(this).attr('value') != ''){
		window.open($(this).attr('value'))
	  }
	});
	
	$("#frmCandidate input").hover(function(){
		$(this).addClass("write_hover");
	},function(){
		$(this).removeClass("write_hover");
	});
	
	$("#frmCandidate input").click(function(){
		$(this).addClass("write");
	});
	
	$("#frmCandidate input").blur(function(){
		$(this).removeClass("write");
	});
	
	$("#frmCandidate input").focus(function(){
		$(this).addClass("write");
	});
	
	$("#frmCandidate textarea").hover(function(){
		$(this).addClass("write_hover");
	},function(){
		$(this).removeClass("write_hover");
	});
	
	$("#frmCandidate textarea").click(function(){
		$(this).addClass("write");
	});
	
	$("#frmCandidate textarea").blur(function(){
		$(this).removeClass("write");
	});
	
	$("#frmCandidate textarea").focus(function(){
		$(this).addClass("write");
	});
	
	if(typeof(jQuery.fn.prettyPhoto)=='function'){
		$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
	}
	/************Added by hra 22.03.2011**********/
	//When you click on a link with class of poplight and the href starts with a # 
	/*$('a.poplight[href^=#]').click(function() {
		var popID = $(this).attr('rel'); //Get Popup Name
		var popURL = $(this).attr('href'); //Get Popup href to define size
	
		//Pull Query & Variables from href URL
		var query= popURL.split('?');
		var dim= query[1].split('&');
		var popWidth = dim[0].split('=')[1]; //Gets the first query string value
	
		//Fade in the Popup and add close button
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="/img/template/ico-close.png" class="btn_close" title="Close Window" alt="Close" /></a>');
	
		//Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;
	
		//Apply Margin to Popup
		$('#' + popID).css({
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
	
		//Fade in Background
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
	
		return false;
	});
	
	//Close Popups and Fade Layer
	$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
		$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close').remove();  //fade them both out
		});
		return false;
	});*/
	
	/************end Added by hra*********/
	
});
function sendToAFriend(objForm){
	var ctrlValidation = eval('_CF_check' + objForm.name + '(document.' + objForm.name + ')');
	// utilise deux variables globales : pageLanguage et pageAjaxURL
	if (ctrlValidation){
		var mailfrom = objForm.from.value;
		var mailto   = objForm.to.value;
		var message  = objForm.message.value;
		var linkinmail  = objForm.linktofriend.value;
		var strParam = 'plugin=sendtoafriend&action=send&mailfrom=' + mailfrom + '&mailto=' + mailto + '&linkinmail=' + linkinmail + '&message=' + message + '&language=' + pageLanguage;
		$.ajax({
			type:"GET",
			url: pageAjaxURL,
			data: strParam,
			success: function(msg){
				try {
					var arDatas = eval(msg);
					//sendToAFriendClose(objForm);
					$(".layerForm .row").hide();
					$(".layerForm .btn-green").hide();
					$(".successSendFrmSendtoafriend").show();
				} catch (e) {
					//alert(msg);
				}
			}
		});
	}
}
function sendToAFriendClose(objForm){
	$('#customLayer,a.btn-close').click();
	objForm.to.value = ' ';
}
function subscribeNewsletter(objForm,pageArea){
	if(pageArea == undefined){pageArea = "N/A"};
	var ctrlValidation = eval('_CF_check' + objForm.name + '(document.' + objForm.name + ')');
	// utilise deux variables globales : pageLanguage et pageAjaxURL
	if (ctrlValidation){
		var email = objForm.yourEmail.value;
		var strParam = 'handler=form_newsletter&action=subscribe&email=' + email + '&language=' + pageLanguage;
		if(typeof(_gaq) != 'undefined' )_gaq.push(['_trackEvent', "Formulaire", "Abonnement Newsletter", pageArea]);		
		
		$.ajax({
			type:"GET",
			url: pageAjaxURL,
			data: strParam,
			success: function(msg){
				try {
					var arDatas = eval(msg);
					$('#'+objForm.name+'Error').hide();
					subscribeNewsletterStatus(objForm);
				} catch (e) {
					$('#'+objForm.name+'Error').hide();
					$('#'+objForm.name+'Success').text(msg);
					$('#'+objForm.name+'Success').show();
				}
			}
		});
	}
}
function subscribeNewsletterStatus(message){
	//alert(message);
	$('#frmNewsletterSubscribeSuccess').text(message);
	$('#frmNewsletterSubscribeSuccess').show();
}




