//Vider un champ de formulaire prérempli
function fieldFocus(element, value){
	if($(element).val() == value){
		$(element).val('');
	}
}

//Remplir un champ de formulaire vide, préalablement prérempli
function fieldBlur(element, value){
	if($(element).val() == ''){
		$(element).val(value);
	}
} 
$(document).ready(function (){
	$('#nav > li').hover(function () {
		$('#nav .active').addClass('tempclass');
		$('#nav .tempclass').removeClass('active');
		$(this).addClass('active');
		if($('ul > *', this).length){
			$('#header').css('height','148px');
		}else{
			$('#header').css('height','91px');
		}
	}, function () {
		if(!$('ul > *', this).length){
			$(this).removeClass('active');
		}
	});
});


function seton(nb){
	var j = nb;
	for (var i = 1; i <= nb; i++){
		$('#star' + i).addClass('active');
	}
	j++;
	for (j; j <= 5; j++){
		$('#star' + j).removeClass('active');
	}
} 

function zoom(){
	if($('#img_article').css('height') == '118px'){
		$('#img_article').animate({
			height: $('#img_article img').height() + 'px'

		}, 1000 );
	}else{
		$('#img_article').animate({
			height: '118px'

		}, 1000 );
	}
	return false;
}

function movepage(page){
	var margin = (page-1)*703;
	var value = '-'+margin+'px';
	$('.paginator').animate({
		marginLeft: value
	}, 500 );
	return false;
}

function seefooter(){
	$('#sitemap').slideToggle();
	$('#infofooter').slideToggle();
	return false;
}

function sendcommentaire(){
	if($('#message').val() != ''){
		var message = $('#message').val();
		message = message.replace("&","#123456789#"); 
		$('#message').val('');
		$.ajax({
			type: "POST",
			url: "/commentaires/add",
			data: "reference_id="+$('#reference_id').val()+"&type="+$('#type').val()+"&message="+message,
			success: function(msg){
				$('#commentaire').prepend(msg);
				$("#commentaire > p").fadeIn("slow");
			}
		});
	}
}

function gotoandplay(num){   
	document.getElementById('flashmp3').gotoandplay(num);
	return false;
}

function setvote(note){
	$('#h5_vote #vote').html('Enregistrement...');
	$('#h5_vote #vote').css('margin-top','0px');
	$.ajax({
		type: "POST",
		url: "/votes/add",
		data: "reference_id="+$('#reference_id').val()+"&type="+$('#type').val()+"&vote="+note,
		success: function(msg){
			$('#h5_vote #vote').css('margin-top','5px');
			$('#h5_vote').html(msg);
		}
	});
	return false;
}

function pop(lien){
	var Left = (window.screen.width - 736) / 2;
	var Top = (window.screen.height - 200) / 2;
	var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=736, height=141, left=" + Left + ", top=" + Top;
	window.open(lien, "popup_modif", Configuration);
	return false;
}
