// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery.fn.as_empty_will_hide = function(target) {
    var o = $(this[0])
	if (o.val() == "") {
		target.hide(); } else {
	 	target.show();
	 }
	var re = /\w/;
	if ($('#search_box.empty_search_box').length > 0 && re.test($('#searchtext').val())) {
			addTagButton();
	}
	else if ($('#search_box.empty_search_box').length == 0 ) {
			searchTagButton();
	}
	
};

showWhenSelected = function(target, selector, exactstring, exactstring2) {
	if (selector.val() == exactstring || selector.val() == exactstring2) {
		if (target.hasClass('hidden') == true){ target.removeClass('hidden') }
	} else {
		target.addClass('hidden')		
	}
}

showWhenSelected = function(target, selector, exactstring, exactstring2, exactstring3) {
	if (selector.val() == exactstring || selector.val() == exactstring2 || selector.val() == exactstring3) {
		if (target.hasClass('hidden') == true){ target.removeClass('hidden') }
	} else {
		target.addClass('hidden')		
	}
}

addTagButton = function(){
				var c = $('#search_button_col')
				var b = $('#search_button')
				if (b.attr('alt') != "lisaa") {
					c.fadeOut('fast');
					b.attr({
						src: "/images/add_new_fi.png",
						alt: "lisaa"});
					c.fadeIn('fast');
					}	
} 
searchTagButton = function(){
				var c = $('#search_button_col')
				var b = $('#search_button')
				if (b.attr('alt') != "etsi") {	
					c.fadeOut('fast');
					b.attr({
						src: "/images/search_fi.png",
						alt: "etsi"});					
					c.fadeIn('fast');
				}			
}

$(function() {
	// Use this example, or...
	$('a.lightbox').lightBox();
})