$(document).ready(function() {

// Slider panoramique du header
$('.bandeau-home').cycle({
		fx: 'fade',
		speed: '2000',
		timeout: '4000'
		
});

// Slider Références
$('ul.exp-references').cycle({
		fx: 'fade',
		speed: '2000',
		timeout: '4000'
});


$("ul.exp-references a").click(function(){
$('ul.exp-references').cycle('pause');
});
$('#fancybox-overlay,#fancybox-close').live("click",function(){
$('ul.exp-references').cycle('resume');
});
	$("ul.exp-references a").attr('rel', 'gallery').fancybox({
		'cyclic'		:	true,
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity':	0.8		
	});
	
// Modification du curseur dans le cas d'un href=#
try
{

$('#menu-footer > li > a').each(function()
{
	if($(this).attr('href')=='#')
	{
	$(this).css('cursor','default');
	}
});
}
catch(e)
{alert(e);}


//Script pour le menu de navigation horizontale
		$('#access .sub-menu .menu-item').addClass('li-not-last');
		$('#access .sub-menu .menu-item:last-child').removeClass('li-not-last').addClass('last-li');
		
		var lien=$("input[name='lien_blog']").attr('value');
		$('.home #access .sub-menu').mouseenter(function() {
			$(this).prev('a').css('background-image','url(wp-content/themes/twentyten/images/bg-menu-nav1-li-hover.png)');
		});
		$('body:not(.home) #access .sub-menu').mouseenter(function() {
			$(this).prev('a').css('background-image','url('+lien+'/wp-content/themes/twentyten/images/bg-menu-nav1-li-hover.png)');
		});
		$('.home #access .sub-menu').mouseleave(function() {
			$(this).prev('a').css('background-image','url(wp-content/themes/twentyten/images/bg-menu-nav1-li.png)');
		});
		$('body:not(.home) #access .sub-menu').mouseleave(function() {
			$(this).prev('a').css('background-image','url('+lien+'/wp-content/themes/twentyten/images/bg-menu-nav1-li.png)');
		});
		$('.home #menu-navhoriz > li > a').hover(function() {
			$(this).prev('a').css('background-image','url(wp-content/themes/twentyten/images/bg-menu-nav1-li-hover.png)');
		});
		$('body:not(.home) #menu-navhoriz > li > a').hover(function() {
			$(this).prev('a').css('background-image','url('+lien+'/wp-content/themes/twentyten/images/bg-menu-nav1-li-hover.png)');
		});

//Pagination des liens utiles de la HomePage, et des actualités
	$(function(){
		$("#paging li").quickpaginate({ perpage: 3, pager : $("#paging_list_counter") });
		$(".exp-actualites .exp-post").quickpaginate({ perpage: 10, pager : $(".actualites_list_counter") });
		$(".category-actualite .exp-post").quickpaginate({ perpage: 4, pager : $(".actualites_list_counter") });
		$(".category-salon .exp-post").quickpaginate({ perpage: 4, pager : $(".actualites_list_counter") });
		//$(".page .type-lexique").quickpaginate({ perpage: 6, pager : $(".lexique_list_counter") });
	});
	
/* --------------------------------------------------------------------------------------------*/
/* ------------------------- AJUSTEMENT AUTOMATIQUE DES PAGES ---------------------------------*/
/* --------------------------------------------------------------------------------------------*/

//ajustement automatique du DIV "container" des "singles"
    if ($('.single #container').height() < $('.single #primary').height())
	{
        $('.single #container').css('height', $('.single #primary').height());
    }
	else
	{
		$('.single #primary').css('height', $('.single #container').height());
	}
	
//ajustement automatique du DIV "container" des "catégories"
    if ($('.category #container').height() < $('.category #primary').height())
	{
        $('.category #container').css('height', $('.category #primary').height());
    }
	else
	{
		$('.category #primary').css('height', $('.category #container').height());
	}

//ajustement automatique du DIV "container" des "catégories" lors du click sur la pagination
$('.category .qp_next, .category .qp_prev').click(function() {
    if ($('.category #container').height() < $('.category #primary').height())
	{
        $('.category #container').css('height', $('.category #primary').height());
    }
	else
	{
		$('.category #primary').css('height', $('.category #container').height());
	}
});

//ajustement automatique du DIV "container" des "pages"
    if ($('.page .exp-conteneur-post').height() < $('.page #home-right').height())
	{
        $('.page .exp-conteneur-post').css('height', $('.page #home-right').height());
    }
	else
	{
		$('.page #home-right').css('height', $('.page .exp-conteneur-post').height());
	}
//ajustement automatique du DIV des pages spéciales (Notre actualité & Contactez-nous)
    if ($('.page .exp-conteneur-post').height() < $('.page #primary').height())
	{
        $('.page .exp-conteneur-post').css('height', $('.page #primary').height());
    }
	else
	{
		$('.page #primary').css('height', $('.page .exp-conteneur-post').height());
	}
//ajustement automatique du DIV "container" des "tags"
    if ($('.tag #container').height() < $('.tag #primary').height())
	{
        $('.tag #container').css('height', $('.tag #primary').height());
    }
	else
	{
		$('.tag #primary').css('height', $('.tag #container').height());
	}
	
/* --------------------------------------------------------------------------------------------*/
/* ------------------ FIN DU SCRIPT D'AJUSTEMENT AUTOMATIQUE DES PAGES ------------------------*/
/* --------------------------------------------------------------------------------------------*/

//script de calcul d'indexation des loyers
	$('#calculate-button1').click(function() {
		var lien=$("input[name='lien_blog']").attr('value');
		var loyer=$("input[name='loyer']").attr('value');
		var debut=$("select[name='debut'] option[value='"+$("select[name='debut']").attr('value')+"']").text();
		var fin=$("select[name='fin'] option[value='"+$("select[name='fin']").attr('value')+"']").text();
		$.post(lien+"/traitement-calcul",{'loyer':loyer, 'debut':debut, 'fin':fin, 'mtype':'icc'}, function(data){$('.resultats').empty();$('.resultats').append(data);});
		//$('.exp-calculatrice .resultats').css('border','1px solid #CC0000');
		});

//script de calcul d'indexation des loyers ilc
	$('#calculate-button-ilc').click(function() {
		var lien_ilc=$("input[name='lien_blog_ilc']").attr('value');
		var loyer_ilc=$("input[name='loyer_ilc']").attr('value');
		var debut_ilc=$("select[name='debut_ilc'] option[value='"+$("select[name='debut_ilc']").attr('value')+"']").text();
		var fin_ilc=$("select[name='fin_ilc'] option[value='"+$("select[name='fin_ilc']").attr('value')+"']").text();
		$.post(lien+"/traitement-calcul",{'loyer':loyer_ilc, 'debut':debut_ilc, 'fin':fin_ilc, 'mtype':'ilc'}, function(data){$('.resultats_ilc').empty();$('.resultats_ilc').append(data);});
		//$('.exp-calculatrice .resultats').css('border','1px solid #CC0000');
		});
		
/* --------------------------------------------------------------------------------------------*/
/* --------------------------------- VIDEO DE LA HOMEPAGE -------------------------------------*/
/* --------------------------------------------------------------------------------------------*/	
//Videobox de la Home
	//pour la version fancybox
	$("a#video_intro").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity':	0.8
	});
	
	//pour la version flowplayer
	$("a#video_intro").click(function () {
	var lien=$("input[name='lien_blog']").attr('value');
	flowplayer("video_intro_box", lien+'/wp-content/themes/twentyten/flowplayer-3.2.4.swf');
	});
});
