
// Video Ratting
function fxRate(rate, idToHide, idToShow){
	
	$.ajax({
		type: 'POST',
		url: baseurl+ '/ajax/ajax.php?a=rate_video',
		data: 'rate=' +rate+ '&vid=' +vidid,
		
		success: function(msg){
			hideMe(idToHide);
			showMe(idToShow);
			$('div#voteProcess > span').html(msg);
		}
	});
}

// Video Comment
function fxSendComments(commentId, idToHide, idToShow){
	
	comment_value = document.getElementById(commentId).value;
	
	if(comment_value=='')
	{
		alert('Le formulaire est vide!')
		return 0;
		
	} else {
		
		$.ajax({
			type: 'POST',
			url: baseurl+ '/ajax/ajax.php?a=process_comment',
			data: 'comment=' +comment_value+ '&vid=' +vidid,
			
			success: function(msg){
				hideMe(idToHide);
				showMe(idToShow);
			}
		});
	}		
}

function fxShowAccInfo(a,b){
	showMe(a);
	hideMe(b);	
}

function hideMe(myId){ document.getElementById(myId).style.display="none"; }
function showMe(myId){ document.getElementById(myId).style.display="block"; }


// Afficher ou cacher la div en fade
function fadeInOut(div)
{
	$('enca-twitter-send').hide();
	
	// retourne 0 si la div n'est pas affichée
	var twitDiv			= $('#' + div);
	var twitDivVisible 	= $('#' +div+ ':visible').length;
	
	if(twitDivVisible == 0)
	{
		$('#enca-twitter-send').hide();
		twitDiv.fadeIn();
		
	} else{
		twitDiv.fadeOut();
	}
	
	return 0;
}

function twitterSender()
{
	var username	= $('#twit-uname').val();
	var password	= $('#twit-passwd').val();
	var comment		= $('#twit-comment').val();
	
	if(username == '' || password == '' || comment == '')
	{
		alert('Veuillez indiquer votre nom d\'utilisateur, votre mot de passe et votre message')
		return 0;
		
	} else {
		
		$.ajax({
			type: 'POST',
			url: baseurl+ '/ajax/twitter.php?a=process_comment',
			data: 'comment=' + comment 
			+ '&username=' + username
			+ '&password=' + password,
			
			success: function(msg){
				if(msg)
					$('#enca-twitter-send').html('Votre message a bien été envoyé');
				else
					$('#enca-twitter-send').html('Le script a rencontré une erreur durant l\'envoi du message');
			}
		});
	
	// effet de fade out puis fade in
	$('enca-twitter-send').fadeIn();
	}
	
	
}

