$(function(){
	if($('span.mailme')[0]){
		$('span.mailme').mailme();
	}
	
	if($('#form_offre')[0]){
		$("#form_offre").validate({
			rules: {
				nom: "required",
				tel: "required",
				message:"required"						
			},
			meta: "validate",
			ignoreTitle: true,
			highlight: function(element, errorClass) {
				$(element).fadeIn("slow",function() {
				$(element).addClass(errorClass);
				$(element).prev().animate({marginLeft: 5},"fast",
					function(){
						$(this).animate({marginLeft: 0},"fast" );
					});
				});
			},
			unhighlight: function(element, errorClass) {
				$(element).removeClass(errorClass);
			}
			
		});
	}
	
	$('li.sub').each(function(){
		$(this).hover(function(){
			$('.sub_menu', this).show();
			$('a:first', this).css({backgroundPosition:"left bottom"});
		},function(){
			$('.sub_menu', this).hide();
			$('a:first', this).css({backgroundPosition:"left top"});
		});
	})
	
	$('#diapo').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 5000
	});
	$('#baseline').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 5000
	});
	
	
	if($.cookie("css")) {
		$('.txt').css({fontSize: parseInt($.cookie("css")), lineHeight:'normal'});
	}

	$("#sizer a").click(function() {
		var size = parseInt($('.txt').css('fontSize'));
		if($(this).attr('id') == 'more'){
			size = 16;
		}else{
			size = 12;
		}
		$('.txt').not('h2.h2').css({fontSize: size, lineHeight:'normal'});
		$.cookie("css", size, {expires: 365, path: '/'});
		return false;
	});



});


function tri(chemin, tri) {
	window.location.href=chemin+"listing.php?tri="+tri+"&orderBySens=ASC";
}
