/*
  slidebutton.js
*/

function searchBoxGrey () {
	var valid = $("#searchSmarterZipCode").attr('class');	
	if(valid && valid.match(/inputIsValid/)) {
		$("#search-form #search-smarter-submit-grey").hide();
		$("#search-form #search-smarter-submit").show();
		return true;
	}
	else {
		$("#search-form #search-smarter-submit").hide();
		$("#search-form #search-smarter-submit-grey").show();
		return false;
	}
}

$(document).ready(function() {
    // Search smarter box
    $('#search_smarter h2').click(function() {
        $(this).next().slideToggle('slow');
    });

	$('.leftColumnModuleHeader, .sidebar_openclose').click(function() {
		$(this).parent().next('.leftColumnModuleBody, .column_links').slideToggle('slow');
		return false;
	});

	$("#showSearchSmarterAdvandedSearch").click( function (method) {
		method.preventDefault();
		$('#ss_keywords').show();
		$(this).hide();
	});
	
	$("#search-form").each( function () {
		$(this).bind('click change beforeUnload select', function () {
			searchBoxGrey();
		});
	});
	
	$("#search-form").submit( function (method) {
		if(!searchBoxGrey()) {
			method.preventDefault();
		}
	});

	searchBoxGrey();
	$('#ss_keywords').hide();
	if(!$("#search-form").hasClass('showOnLoad'))
		$("#search-form").hide();
});
