(function() {

	$('ul.option a[title], a.option[title]').livequery(function() { 
		$(this).qtip({ 
			style: { 
				name: 'light', 
				tip: true 
				}, 
			position: {
                corner: {
                    tooltip: 'bottomLeft', 
                	target: 'topRight'
            		}
            	}
			}) 
	});

	var test = function() {
		$(this).each(function(){
			var url_content = $(this).attr('id');
			var width_content = $(this).attr('width');
			
			$(this).qtip({
			   content: {
			      url: url_content
			   },
			   style: { 
			      padding: 5,
			      width: width_content,
			      background: '#A2D959',
			      color: 'black',
			      textAlign: 'center',
			      border: {
			         width: 7,
			         radius: 5,
			         color: '#A2D959'
			      },
			      tip: 'bottomMiddle'
			   },
			   position: {
			      corner: {
			         target: 'topLeft',
			         tooltip: 'bottomLeft'
			      }
			   }
			});
		});    
	};    

	$(".tooltip").livequery(test);

	$.fn.formGraphicAnimated = function() {
		var $_this = $(this);
		
		$("label.big_option input[type=radio]:checked").closest("label").addClass("selected");
		$("label.big_option input[type=checkbox]:checked").closest("label").addClass("selected");
		
		return this.each(function() {
			var name = $(this).attr('name');
			var type = $(this).attr('type');
			$(this).change(
			function(){
				$("input[type="+type+"][name="+name+"]").closest("label").removeClass("selected");
				$("input[type="+type+"][name="+name+"]:checked").closest("label").addClass("selected");
			}
			);
	   	});
	};
	
	$.fn.removeFormErrorInputNonEmpty = function() {
		return this.each(function() {
			$(this).change( function() {
				$(this).closest(".form_classic_error").removeClass("form_classic_error");
			});
	   	});
	};
	
})(jQuery);

$(function() {

//    var graphic_animated = function() {
    	$(".form_graphic label.big_option input[type=radio], .form_graphic label.big_option input[type=checkbox]").formGraphicAnimated();
//    };
    
//    $(".form_graphic label.big_option input[type=radio], .form_graphic label.big_option input[type=checkbox]").livequery(graphic_animated);
    
    	$(".slide_menu_option").css({display: "none"}); // Opera Fix
    	$(".slide_menu").hover(function(){
    		$(this).children('.slide_menu_option').css({visibility: "visible",display: "none"}).fadeIn(400);
    		},function(){
    		$(this).children('.slide_menu_option').css({visibility: "hidden"});
    	});

    	$(".slide_menu_v2").hover(function(){
    		$(this).children('.slide_menu_option').css({visibility: "visible",display: "none"}).slideDown(200);
    		},function(){
    		$(this).children('.slide_menu_option').css({visibility: "hidden"});
    	});	
	
	$(".form_classic_error input").removeFormErrorInputNonEmpty();
});
