var search_default = 'Enter search and click GO';

var inputClearer = function(item,default_text)
{
	if(item.value == default_text)
	{
		item.value="";
	} else if(item.value == "")
	{
		item.value=default_text;
	} 
}

var inputClearerPW = function(item,default_text)
{
	if(item.value == default_text)
	{
		item.value="";
	}
}

var search_validate = function() {
	ok_test = true;
	search_box = $('input#top_search_box')[0];
	if(search_box.value == "" || search_box.value == search_default) {
		ok_test = false;
	}
	return ok_test;
}

// this handles the redirects from the pulldown menu
var drillMenu = function()
{
	var urlPrefix = "/wholesale/";
	var shopform = $('form#shopmod');
	var mode = $('input#mode').val();	
	var opt = $('select#subcat option:selected').val();
	var newUrl = "";
	
	if(mode=="lat")
	{
		newUrl = urlPrefix + "latest/" + opt + "/1";
	}
	else if(mode=="cat")
	{
		newUrl = urlPrefix + "catalog/" + opt + "/1";
	}
	
	if(newUrl != "")
	{
		window.location.href = newUrl;
	}
	//alert("changed " + mode + " opt " + opt);
}

var mainInit = function()
{
	// add change event to subca dropdown
	$('form#shopmod select#subcat').change(drillMenu);	

	$('input#top_search_box').blur(function() {
		inputClearer(this, search_default)
		});	
	$('input#top_search_box').click(function() {
		inputClearer(this,search_default)
		});
	
	rollover_init();
}

jQuery().ready(mainInit);
