var CSP_DEBUG = false;
var USING_FEEDBACK_TAB = false;		//	TO DO - re implement
var LOCAL = false;				//	Local visibility only
if (location.host == "localhost:8888") {
	LOCAL = true
}

// Site wide settings for the majority of the pages on the site. Each file can also have a local js file for overrides.
$(function() {
	$('#adrates').dialog({ autoOpen: false, width: 600 });
	$('#adrates-link').click(function(){ $('#adrates').dialog('open'); return false; });
	$.localScroll({hash:true, filter: '#tabs-1,#tabs-2,#tabs-3,#tabs-4,#tabs-5,#tabs-6,#tabs-7,#tabs-8,#tabs-9'});
	/* 
	$(".listing:even").css("background-color", "#f7f9fb");
	$(".listing:odd").css("background-color", "#fff");
	*/
	$("#tabs").tabs({ event: 'click' });
	$(".callout-specials").equalHeights();
	$(".MegaMenuLink").megamenu(".MegaMenuContent", {
		width: "900px"
	});
}); 

// initialize Tab Slide Out 
$(function(){
	if (USING_FEEDBACK_TAB) {
		alert('USING_FEEDBACK_TAB');
		$('.slide-out-div').tabSlideOut({
			 tabHandle: '.handle',                             	//class of the element that will be your tab
			 pathToTabImage: 'http://www.curtsheller.com/images/tab-Feedback.png',     	//path to the image for the tab *required*
			 imageHeight: '113px',                             	//height of tab image *required*
			 imageWidth: '31px',                               	//width of tab image *required*    
			 tabLocation: 'right',								//side of screen where tab lives, top, right, bottom, or left
			 speed: 300,                                       	//speed of animation
			 action: 'click',                                  	//options: 'click' or 'hover', action to trigger animation
			 topPos: '12px',                                   	//position from the top
			 fixedPosition: true,								//options: true makes it stick(fixed position) on scroll
			 onLoadSlideOut: false
		 });
	}
 });

function LoadSidebarNav() {
//	$(".login-slide").click(function(){
//		$("#login-panel").slideToggle("fast");
//		$(this).toggleClass("loginpanel-active"); return false;
//	});

	$('.login-slide').toggle(
		function(){ // you can add as much here as you'd like
			$('#login-panel').slideDown('fast');
			$('#login-panel-img-arrow').attr('src','http://www.curtsheller.com/images/silk/icons/arrow_up.png');
			$(this).toggleClass("loginpanel-active");
		}, function() { // same here
			$('#login-panel').slideUp('fast');
			$('#login-panel-img-arrow').attr('src','http://www.curtsheller.com/images/silk/icons/arrow_down.png');
			$(this).toggleClass("loginpanel-active");
		});


	// http://dev.jqueryui.com/ticket/3613
	// jQuery UI Development & Planning Wiki, Accordion: 
	// http://jqueryui.pbwiki.com/Accordion

	$(function() { 
		var accordion = $("#sidebar-accordion");
		var index = $.cookie("sidebar-accordion");
		var active;
		if (index !== null) {
			active = accordion.find("h4:eq(" + index + ")");
		} else {
			active = 0
		}
		accordion.accordion({
			header: "h4",
			event: "click",
			active: active,
			change: function(event, ui) {
				var index = $(this).find("h4").index ( ui.newHeader[0] );
				$.cookie("sidebar-accordion", index, {
					path: "/"
				});
			},
			autoHeight: false
		});
	}); 
}

function ShowAndGo(inDiv) {
	if ($(inDiv).is(":hidden")) {
		$(inDiv).show();
		if (CSP_DEBUG) alert('ShowAndGo(inDiv) called with: ' + inDiv + ' and was HIDDEN');
	} else {
		$(inDiv).show();
		if (CSP_DEBUG) alert('ShowAndGo(inDiv) called with: ' + inDiv + ' and was VISIBLE');
	}
}
function ExpandDiv(inDiv, inAnchor){
	$(("#" + inDiv)).show();
}
function ShowDiv(inDiv){
	$(("#" + inDiv)).show();
}
function HideDiv(inDiv){
	$(("#" + inDiv)).hide();
}
function GoToDiv(inDiv){
	$(("#" + inDiv)).show();
}
function toggleDiv(inDiv){
	$(("#" + inDiv)).toggle();
}
function goTo(inDiv) {
	//alert('goTo(inDiv) called with: ' + inDiv);
	$(inDiv).show();
}
function ExpandAllClasses(inClassName) {
	$(inClassName).show();
}
function CollapseAllClasses(inClassName) {
	$(inClassName).hide();
}

// Some navigation I only need visible when it is local, for me only. Live it can be picked up by bots. 
$(function(){
 if (LOCAL) {
		$('#nav-sidebar-About').css('display', 'block');
		$('#nav-sidebar-Blog').css('display', 'block');
		$('#nav-sidebar-Guitar').css('display', 'block');
		$('#nav-sidebar-Instruments').css('display', 'block');
		$('#nav-sidebar-Lessons').css('display', 'block');
		$('#nav-sidebar-Luthiers').css('display', 'block');
		$('#nav-sidebar-Members').css('display', 'block');
		$('#nav-sidebar-Music').css('display', 'block');
		$('#nav-sidebar-Musicians').css('display', 'block');
		$('#nav-sidebar-Quick').css('display', 'block');
		$('#nav-sidebar-Racewalking').css('display', 'block');
		$('#nav-sidebar-Random').css('display', 'block');
		$('#nav-sidebar-Reviews').css('display', 'block');
		$('#nav-sidebar-Sites').css('display', 'none');
		$('#nav-sidebar-Talk').css('display', 'block');
		$('#nav-sidebar-Ukulele').css('display', 'block');

	} else {
		$('#nav-sidebar-About').css('display', 'none');
		$('#nav-sidebar-Blog').css('display', 'block');
		$('#nav-sidebar-Guitar').css('display', 'none');
		$('#nav-sidebar-Instruments').css('display', 'none');
		$('#nav-sidebar-Lessons').css('display', 'none');
		$('#nav-sidebar-Luthiers').css('display', 'none');
		$('#nav-sidebar-Members').css('display', 'block');
		$('#nav-sidebar-Music').css('display', 'none');
		$('#nav-sidebar-Musicians').css('display', 'none');
		$('#nav-sidebar-Quick').css('display', 'block');
		$('#nav-sidebar-Racewalking').css('display', 'none');
		$('#nav-sidebar-Random').css('display', 'none');
		$('#nav-sidebar-Reviews').css('display', 'none');
		$('#nav-sidebar-Sites').css('display', 'block');
		$('#nav-sidebar-Talk').css('display', 'block');
		$('#nav-sidebar-Ukulele').css('display', 'none');
	}
 });

