// jQuery
$(document).ready(function() {
	// logo click event
	$('#btn_logo').click(function(){
		document.location = 'index.shtml';
	});
	// logo hover event
	$('#btn_logo').hover(
		function(){
			$('#btn_logo').addClass('logoOver');
		},
		function(){
			$('#btn_logo').removeClass('logoOver');
		}
	);
	// quote click
	$('#btn_quote').click(function(){
		document.location = 'Van_Horn.shtml';
	});
	// quote hover
	$('#btn_quote').hover(
		function(){
			$('#btn_quote').addClass('grayHover');
		},
		function(){
			$('#btn_quote').removeClass('grayHover');
		}
	);
	
	// Init Tabs
	// megatabEvents(buttonid,tabid);
	megatabEvents('btn_catalog','tab_catalog'); // catalog MEGA tab
});

// Custom Functions
megatabEvents = function(buttonid,tabid){
	var nofadebutton = 0; // determines whether to block the fade-out event on the button
	var nofadetab = 0; // determines whether to block the fade-out event on the tab itself
	$("#"+buttonid).mouseover(function(){
		nofadetab = 1;
		$("#"+tabid).fadeIn("fast", "linear");
	});
	$("#"+buttonid).mouseleave(function(){
		var catalog_fade = window.setTimeout(function() {
			if(nofadebutton == 0) {
				$("#"+tabid).fadeOut("fast", "linear");
			}
		}, 300);
		nofadetab = 0;
	});
	$("#"+tabid).mouseover(function(){
		nofadebutton = 1;
	});
	$("#"+tabid).mouseleave(function(){
		nofadebutton = 0;
		var catalog_fade = window.setTimeout(function() {
			if(nofadetab == 0) {
				$("#"+tabid).fadeOut("fast", "linear");
			}
		}, 300);
		nofadebutton = 0;
	});
}


