$(document).ready(function() {
	$('.banniere').show();
	$('a[rel*=facebox]').facebox();
	$('.less').tipsy({gravity: 's'});
	$('.more').tipsy({gravity: 'e'});
	$('.avert').tipsy({gravity: 'w'});
	$('.goanswer').click(function(){
		$("#jsreponse").animate({opacity:0}, 300).animate({opacity:1}, 300);
	});
	$('.showcomment').click(function(){
		$(this).parent().next().show();
		$(this).parent().parent().find('.form input:text').focus();
	});
	$('.cancelcomment').click(function(){
		$(this).parent().parent().hide();
	});
	$('.addcomment').click(function(){
		var form = $(this).parent();
		$.post("/ajax/comment.php", form.serialize(),
			function(data){
				form.parent().parent().append(
					'<li>' + data.comment + '&nbsp;&ndash;&nbsp;<a href="/user/' + data.username + '">'+ data.username +'</a></li>'
				);
				form.find('input:text:first').attr('value', '');
				form.parent().hide().parent().find('li:last').animate({opacity:0}, 300).animate({opacity:1}, 300);
			}, "json"
		);
	});
	$('.item form').bind('keypress', function(e) {
		if (e.keyCode == 13) {
			return false;
		}
	});
	$('#hlAddVideo').click(function(){
		$('.panelprovider').show('normal');
	});
	$('#hlAddAddress').click(function(){
		$('.paneladdress').show('normal');
	});
	$('#hlCloseProvider').click(function(){
		$('.panelprovider').hide('normal');
		$('#reply_videourl').attr('value', '');
		$('.videolink').hide('normal');
		$('#iyoutube').removeAttr('checked');
		$('#idailymotion').removeAttr('checked');
	});
	$('#hlCloseAddress').click(function(){
		$('.paneladdress').hide('normal');
		$('#reply_street').attr('value', '');
		$('#reply_country').attr('value', '');
		$('#reply_city').attr('value', '');
	});
	$('#idailymotion').click(function(){
		$('.videolink').show('normal');
		$('#reply_videourl').attr('value', '');
		$('#reply_videourl').focus();
	});
	$('#iyoutube').click(function(){
		$('.videolink').show('normal');
		$('#reply_videourl').attr('value', '');
		$('#reply_videourl').focus();
	});
});

var faceboxtype = 'item';
var rateDo = function(type,key){
	if(type=='less')
		$('#cpt-' + key).html(parseInt($('#cpt-' + key).text())-1);
	else
		$('#cpt-' + key).html(parseInt($('#cpt-' + key).text())+1);
}
