
$(document).ready(function(){
	//Change de font of sidebar
 	var originalFontSize = $('div#main').css('font-size');
    	$("#change_font #normal").click(function(){
    	$('div#main').css('font-size', originalFontSize);
 	 });
	$('#change_font li').click(function(){
	var $speech = $('div#main');
	var currentSize = $speech.css('fontSize');
	var num = parseFloat(currentSize, 10);
	var unit = currentSize.slice(-2);
	if(this.id == 'bigger')
	{
		if(num < 14) {
			num *= 1.1;
		}
	}else if(this.id == 'smaller'){
		if(num > 9){
			num /= 1.1;
		}
	}		$speech.css('fontSize', num+unit);
			return false;
	});
	//Remove highlighting
	$('#highlighting_off').click(function(e){
		e.preventDefault();
		$('.match-word').css({'background-color':'#fff','font-weight':'normal','font-size':'1em'});
		$('#highlighting_off').css({'display':'none'});
		$('#highlighting_on').css({'display':'block'});
	})
	$('#highlighting_on').click(function(e){
		e.preventDefault();
		$('.match-word').css({'background-color':'yellow','font-weight':'bold'});
		$('#highlighting_on').css({'display':'none'});
		$('#highlighting_off').css({'display':'block'});
	})
	//Display form send a friend
	$('#email_up').click(function(){
		$("#bookmark").hide();
		$('#form_mail').toggle("slow");
		return false;
	});	


	})

$(function() {
  $('.error').hide();

  $("#button_send").click(function() {
	// validate and process form
	// first hide any error messages
    $('.error').hide();
		
	var name = $("input#name").val();
		
	if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
    
    var youremail = $("input#youremail").val();
	if (youremail == "") {
      $("label#youremail_error").show();
      $("input#youremail").focus();
      return false;
    }
    
	var emailfriend = $("input#emailfriend").val();
	
	if (emailfriend == "") {
      $("label#emailfriend_error").show();
      $("input#emailfriend").focus();
      return false;
    }
    
    var url = $("input#url").val();
    var message = $("textarea#message").val();

	var dataString = 'name='+ name + '&youremail=' + youremail + '&emailfriend=' + emailfriend + '&url=' + url + '&message=' + message;
		//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "/private/bin/process.php",
      data: dataString,
      success: function() {
      		$('#messageSent').show("fast");
			setTimeout('$("#messageSent").hide("slow");$("#form_mail").slideUp("slow")',2000);
			$.getScript("/js/clear.form.js", function(){
				$("#contactForm").clearForm();
			});

			
      	}});
    return false;
	});
	
	//Function to print
	$('#print_p').click(function(e){
		e.preventDefault(); // let«s avoid that goes to the link
		window.open(this.href,this.target,'width=950,height=520,scrollbars=yes,toolbar=0,location=1,directories=0,status=1,menubar=0');						   
	});

	
});

