// JavaScript Document

function Contact(){
	ajustDimension("form#contact","#reponse");
	$('html, body').animate({scrollTop:0}, 'slow');
	$('div#reponse').html('');
	$('div#reponse').css('backgroundImage','url('+absoluteURL+'images/loading_bar.gif)');
	$.post(absoluteURL+'modules/contact.php',$("form#contact").serialize(), function(data) {
  		$('#reponse').html(data);
		if($('#ok').size() > 0){$('#ok').oneTime("2s", function() {resetForm('contact');});}
}).complete(function(){$('div#reponse').css('backgroundImage','url()');});;
    $('div#reponse').fadeIn();
    return false;
}

function resetForm(id){
	$('form#'+id+' input').each(function(index, element) {
		if($(this).attr('type') == "text" || $(this).attr('type') == "checkbox"){
        $(this).val('');
		}
    });
	
	$('form#'+id+' select').each(function(index, element) {
        $(this).val('');
    });
	
	$('form#'+id+' textarea').each(function(index, element) {
        $(this).val('');
    });

}

function friendSend(lien){
	$.post(absoluteURL+'friend.php',{action:"linksend",url:lien}, function(data) {
  		$.colorbox({html:data,width:"700px"});	
}).complete(function(){$("img#refresh").click(function(){change_captcha();});$("img#refresh").css('cursor','pointer');$.colorbox.resize()});
    return false;
	}

function sendLink(){
	ajustDimension("form#friend_form","#reponse");
	$('html, body').animate({scrollTop:0}, 'slow');
	$('div#reponse').html('');
	$('div#reponse').css('backgroundImage','url('+absoluteURL+'images/loading_bar.gif)');
	$.post(absoluteURL+'friend.php',$("form#friend_form").serialize(), function(data) {
  		$('#reponse').html(data);
		if($('#ok').size() > 0){$('#ok').oneTime("2s", function() {resetForm('contact');});}
}).complete(function(){$('div#reponse').css('backgroundImage','url()');});;
    $('div#reponse').fadeIn();
    return false;
}


function markError(id){
	//Supprimer les anciens mark
	$('form#'+id+' input').each(function(){
		$(this).removeClass('inputError');
		});
	
	$("#error li").each(function(){
		field = $(this).attr('rel');
		$("#"+field).addClass('inputError');
	});
	
	
}
