$(document).ready(function() 
{
	if($('#hp-content').length){ $('#hp-content #sport').hover(function(){ var src = $(this).next().find('img').attr("src").replace('.jpg', '-hover.jpg'); $(this).next().find('img').attr("src", src); },function(){ var src = $(this).next().find('img').attr("src").replace('-hover', ''); $(this).next().find('img').attr("src", src); }); $('#hp-content #lifestyle').hover(function(){ var src = $(this).prev().find('img').attr("src").replace('.jpg', '-hover.jpg'); $(this).prev().find('img').attr("src", src); },function(){ var src = $(this).prev().find('img').attr("src").replace('-hover', ''); $(this).prev().find('img').attr("src", src); }); }
	homeResize();
	if($('#menu ul ul').length) { $('#menu ul li').hover(function(){ $('ul', this).offset({left:$(this).offset().left}); $('ul', this).css('z-index', '100000').show(); },function(){$('ul', this).hide(); }); }
	if($('#menu-lifestyle').length) { $('#menu-lifestyle li:last').addClass('last'); }
	if($('#slider').length){ $('#slider').tinycarousel({ intervaltime: 5000, pager:true, interval:true, rewind:true }); }
	if($('.sub-cleft').length){ $('.sub-cleft, .sub-cright').equalHeights(); }
	if($('#proslider img').length)
	{
		if(!$('#proslider ul').hasClass('nobind')) { var obj = '#list-cnt-1'; $('#list-right').html($(obj).html()); } 
		$('#proslider').tinycarousel({ display: 1, callback: function(element, index){ intIndex = index + 1; if(intIndex >= 1) { if(!$('#proslider ul').hasClass('nobind')) { var obj = '#list-cnt-'+intIndex; $('#list-right').html($(obj).html()); } } } });
		$("a[rel=fancygroup]").fancybox({ 'transitionIn' : 'none', 'transitionOut' : 'none', 'titlePosition' : 'over', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>'; }});
		$("a[rel=fancyvideogroup]").fancybox({ 'width' : '50%', 'height' : '75%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' });
	}
	if($('.sub-content').length){ $('.sub-content .sub-cleft li').hover(function(){ $('.sub-content .sub-cleft li').css({'opacity': '0.3'}); $(this).css({'opacity': '1'}); },function(){ $('.sub-content .sub-cleft li').css({'opacity': '1'}); }); }
	if($('#list .blocks').length){ $('#list .blocks').hover(function(){ $('#list .blocks').css({'opacity': '0.3'}); $('#list .blocks:first').css({'opacity': '1'}); $(this).css({'opacity': '1'}); },function(){ $('#list .blocks').css({'opacity': '1'}); });  }
	if($('#cform').length)
	{
		$('#cfformbtn').click(function() { 
			if($('#nom').val() == '' || $('#prenom').val() == '' || $('#email').val() == '' || $('#ville').val() == '' || $('#message').val() == '')
				$('#cffrmframe').html('<p class="msg">Please check the fields</p>');
			else
				$('#cffrm').submit();
			return false; 
		});
		$("#cffrm").submit
		(
			function()
			{
				$('#cffrmframe').html('<p class="msg">Veuillez patienter! L\'email s\'envoit...</p>');
				strURL = $("#surl").val() + "/send.php";
				var str = $(this).serialize();
				$.ajax(
				{
					type: "POST",
					url: strURL,
					data: str,
					success: 
					function(msgStatus)
					{
						$("#cffrmframe").ajaxComplete(function(event, request, settings)
						{
							strmsg = '<p class="msg">' + msgStatus + '</p>';
							$('#cffrmframe').html(strmsg);
						});
					}
				});
				return false;
			}
		);
	}

});

$(window).load(function(){homeResize();});
$(window).bind('resize',function(){homeResize();});
function homeResize(){$('#hp-content a img').css({'height': ($(window).height() - 160) +'px'});$('#hp-content').css({'width': (($('#hp-content a img').width() * 2)+1) +'px'});}
function getMaxHeight() { var tal = 0; $('#list-slider .mb-scroll img').each(function() { if($(this).height() > tal) { tal = $(this).height(); } }); return tal; }

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		var tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest);
		});
	}
})(jQuery);
