function sfHover () {
	var navbarEls = document.getElementById("navbar").getElementsByTagName("li");
	for (var i=0; i<navbarEls.length; i++) {
		navbarEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		navbarEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}

$(document).ready(function(){
	sfHover();
	$("#lang_links").appendTo("#lang_container");
});

//Validate forms
(function($){
	  $.fn.validator = function(opts){
		  var idForm=$(this).attr("id");
		  $("#"+idForm+" .error_msg").html("");
	    $(this).find('.mandatory').live('keyup', function(){
		      if($(this).val()!=""){
		          $(this).removeClass('mandatory');
		      }
	    });
	    $(this).find('.mandatory').live("change", function(){		      
		          $(this).removeClass('mandatory');
		     
	    });
	     $(this).find('.no_empty').each(function(){
	        if ($(this).attr('value') == ''){
	          $(this).addClass('mandatory');
	          $("#"+idForm+" .error_msg").html('<li>'+$('#messageNoEmpty').attr('value')+'</li>');      
	          
	        }
	     });		
	     $(this).find('.email').each(function(){
	    	 if($(this) && $(this).attr('value') && !(/^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/.test($(this).attr('value')))) {
	    		 $(this).addClass('mandatory');	 
	    		 $("#"+idForm+" .error_msg").append('<li>'+$('#messageFormatEmail').attr('value')+'</li>');
	    		 
	    	 }
	     });
	     $(this).find('.password_confirm').live('keyup', function(){
		      if($(this).val()!=""){
		          $(this).removeClass('mandatory');
		      }
	    });
	         
	    $(this).find('.mandatory:first').focus();
	    return $(this).find('.mandatory').length;
	     
	  };
})(jQuery);

