$.fn.fixHover = function() {
    return this.each(function(){
        $(this).hover( 
            function() { 
				$(this).addClass('fix_hover');  
			},
            function() { 
				$(this).removeClass('fix_hover'); 
			}
        );
    });
};

function blur_field(f) {
	if ($('#'+f).val()=='') {
		$('#'+f).val($('#'+f).get(0).old_value);		
	}

	if (f=='search') {
		$('#search_box').addClass('hovering');
	}
}

function focus_field(f) {
	if (!$('#'+f).get(0).old_value) 
		$('#'+f).get(0).old_value = $('#'+f).val();
	if ($('#'+f).val() == $('#'+f).get(0).old_value) 
		$('#'+f).val('');
		
	if (f=='search') {
		$('#search_box').removeClass('hovering');
	}
}

function blur_field_new(f) {
	if ($('#'+f).val()=='') {
		$('#'+f).removeClass('active');	
	}
}

function focus_field_new(f) {
	$('#'+f).addClass('active');	
}


function search_check() {
	var s = $('#search').val();
	if (s.length>2)	{
		setTimeout("search_handler('"+s+"')", 500);
	}
}

function search_hide() {
	search_visible = false;
	$('#search_output').html('').hide();
	$('#search').val('');
	blur_field('search');
	$('#search_bg').fadeTo('slow', 0, function() { $(this).hide(); });
}

var search_visible = false;
var last_ajax_search = '';

function search_handler(s) {

	var s = $('#search').val();
	var si = parseInt(s);

	if (si>99 & si<800) {
		$('#search_output').fadeIn('slow').html('<img src="/assets/images/core/auction_loader.gif"><br/>Loading&hellip;</br>');
		$.getJSON("/ajax/main_search/"+encodeURI(s)+"/"+new Date().getTime(),
			function(ret) {
				$('#search_output').show();
				$('#search_output').html(''+ret.output+'');	
				if (ret.data.redirect) {
					setTimeout("window.location = '"+ret.data.redirect+"'", 1000);
				} else {
					if (!search_visible) {
/* 						$('#search_bg').click(function(){ search_hide(); }).fadeTo(0, 0.0, function() { $(this).show().fadeTo('slow', 0.8); }); */
						search_visible = true;
					}
				}
			}
		);
		last_ajax_search = s;		
	}

/*
	
	if (s==s2 && last_ajax_search != s) {
		$('#search_output').fadeIn('slow').html('<img src="/assets/images/core/auction_loader.gif"><br/>Loading&hellip;</br>');
		$.getJSON("/ajax/main_search/"+encodeURI(s)+"/"+new Date().getTime(),
			function(ret) {
				$('#search_output').show();
				$('#search_output').html(''+ret.output+'');	
				if (ret.data.redirect) {
					setTimeout("window.location = '"+ret.data.redirect+"'", 1000);
				} else {
					if (!search_visible) {
						$('#search_bg').click(function(){ search_hide(); }).fadeTo(0, 0.0, function() { $(this).show().fadeTo('slow', 0.8); });
						search_visible = true;
					}
				}
			}
		);
		last_ajax_search = s;
	}
*/
}

