function rollOver(which)
{ 
	which.src = which.src.replace("_off","_on"); 
}

function rollOut(which)
{ 
	which.src = which.src.replace("_on","_off"); 
}

function empty_field(thisfield)
{
	if(thisfield.value == 'search')
	{
		thisfield.value = '';	
	}
}

function refill_field(thisfield)
{
	if(thisfield.value == '')
	{
		thisfield.value = 'search';
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name ,value ,expiredays ,path ,domain ,secure)
{
	var today = new Date();
	today.setTime( today.getTime() );
	
	if ( expiredays )
	{
		expiredays = expiredays * 1000 * 60 * 60 * 24;
	}
	
	var expires_date = new Date( today.getTime() + (expiredays) );
	
	document.cookie=c_name+ "=" +escape(value)+
	( ( expiredays ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function lgbt_toggle(on_off, url)
{
	lgbt_exp = '-1';
	if(on_off == 'on')
	{
		lgbt_exp = '365';
	}
	setCookie('lgbt', '1', lgbt_exp, '/', '', '');
	location.href=url;
}

//KLR Valide le formulaire de commentaire
var valid_captcha = false;
function validation_commentForm(is_user_logged_in, path){
	var valid = true;
	var captcha = document.getElementById('captcha_code').value;
	var the_form = document.getElementById('commentform');
	var errors = new Object();
	
	jQuery('.comment_error').each(function(){
		jQuery(this).slideUp();
	})
	
	// Enregistre les valeurs des champs
	if(!is_user_logged_in){
		var nom = the_form.author.value;
		var email = the_form.email.value;
	}
	var comment = the_form.comment.value;
	
	
	
	// Verifie si les valeurs ne sont pas vide ou non valide
	
	if((!is_user_logged_in) && (!document.getElementById('fb-user'))){
		var rule = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-.])+)\.+([a-zA-Z0-9])+$/;
			
		if(nom == ''){
			jQuery('.err_author').slideDown();
			valid = false;
		}
		if(email == ''){
			jQuery('.err_email').html('The e-mail field is required.');
			jQuery('.err_email').slideDown();
			valid = false;
		}else if(!rule.test(email)){
			jQuery('.err_email').html('This e-mail is invalid.');
			jQuery('.err_email').slideDown();
			valid = false;
		}
	}
	if(comment == ''){
		jQuery('.err_comment').slideDown();
		valid = false;
	}

	if(captcha == ''){
		jQuery('.err_captcha').html('Please, type the word on the left*');
		jQuery('.err_captcha').slideDown();
		valid = false;
	}
	else {
	var ids = { code_captcha: captcha };
		var result = jQuery.ajax({
			type: "post",
			url: path+"captcha_validate.php",
			data: ids,
			async : false,
			success : function(msg){
				if (msg == "true") {
					valid_captcha = true;
				}
				else {
					jQuery('.err_captcha').html('Please, retype the word on the left*');
					jQuery('.err_captcha').slideDown();
					valid_captcha = false;	
				}
			}	
		});
	}	

	
	if(valid && valid_captcha){
		the_form.submit();
	}
}

//KLR Ouvre un popup 
function printArticle(post_link){
	popup = open(post_link,'popup_print','toolbar=0,location=1,directories=0,status=0,menubar=0,width=480,height=620,scrollbars=1');
}
