$(document).ready(function() {
	   $('#accordion').accordion({header:"h3", active:0, autoHeight: false});
	   $('#TFTD').hide(500);	
	   makeActive();
	   window.api = $("#BabaSayingsScrollable").scrollable({
			size:1,speed:600			
		}).circular().autoscroll({autoplay: true, api: true, interval: 15000});
		
		var quoteSize = api.getSize();
		var start = Math.floor(Math.random()*quoteSize);
		if (start == 0){start = 1;}
		
		api.onBeforeSeek(function() { 
		    $(".baba-sayings-item").fadeOut(100);			 
		});
	    api.onSeek(function() { 
		    $(".baba-sayings-item").fadeIn(1000);		 
		});
		
		api.seekTo(start);
	});
$(function() {
	swapValues = [];
	$(".swap_value").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
				$(this).val("");
			}
		}).blur(function(){
			if ($.trim($(this).val()) == "") {
				$(this).val(swapValues[i]);
			}
		});
	});	
});
function playPause(){
	if ($('#PlayPauseButton').text()=="Play"){
		api.play()
		$('#PlayPauseButton').text("Pause");
	} else {
		api.pause()
		$('#PlayPauseButton').text("Play");
	}
}
function showHide(id){
	if ($(id).is(':visible')){
		$(id).hide(500);
		$('#id-instructions').html('Click to show');
	} else {
		$(id).show(500);
		$('#id-instructions').html('Click to hide');
	}
}
function makeActive(){
	$(".activeTab").removeClass("activeTab");
	var urlpath = location.pathname.split("/");
	switch (urlpath[1])
	{
		case "":
		$('#menuHome').addClass("activeTab");
		$("#tabs").tabs();
		$("#centre-tour").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#centre-tour-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;
		
		case "home":
		$('#menuHome').addClass("activeTab");
		$("#tabs").tabs();
		break;
		
		case "spiritual-wing":
		$('#menuSpiritual').addClass("activeTab");
		$("#bhajans").scrollable({hoverClass: 'hover', size:5}).navigator({naviItem:'li'}).mousewheel().find("a").overlay({
			// each trigger uses the same overlay with id "gallery"
			target: '#bhajans-gallery',
			// optional exposing effect with custom color
			expose: '#111'
		// gallery plugin
		}).gallery({
			// do not use the same disabled class name as scrollable
			disabledClass: 'inactive'
		});
		break;
		
		case "education-wing":
		$('#menuEducation').addClass("activeTab");
		break;
		
		case "service-wing":
		$('#menuService').addClass("activeTab");
		$("#narayan-seva").scrollable({hoverClass: 'hover', size:5}).navigator({naviItem:'li'}).mousewheel().find("a").overlay({
			// each trigger uses the same overlay with id "gallery"
			target: '#narayan-seva-gallery',
			// optional exposing effect with custom color
			expose: '#111'
		// gallery plugin
		}).gallery({
			// do not use the same disabled class name as scrollable
			disabledClass: 'inactive'
		});
		$("#medical-dental-clinic").scrollable({hoverClass: 'hover', size:5}).navigator({naviItem:'li'}).mousewheel().find("a").overlay({
			// each trigger uses the same overlay with id "gallery"
			target: '#medical-dental-clinic-gallery',
			// optional exposing effect with custom color
			expose: '#111'
		// gallery plugin
		}).gallery({
			// do not use the same disabled class name as scrollable
			disabledClass: 'inactive'
		});
		break;
		
		case "projects-wing":
		$('#menuProjects').addClass("activeTab");
		break;
		
		case "ladies-wing":
		$('#menuLadies').addClass("activeTab");
		break;
		
		case "youth-wing":
		$('#menuYouth').addClass("activeTab");
		break;
		
		case "service-opportunities":
		$('#menuHelp').addClass("activeTab");
		break;
		
		case "calendar":
		$('#menuCalendar').addClass("activeTab");
		break;
		
		case "blog":
		$('#menuBlog').addClass("activeTab");
		break;
		
		case "contact":
		$('#menuContact').addClass("activeTab");
		break;
		
		case "committee":
		$('#menuCommittee').addClass("activeTab");
		break;
		
		case "trustees":
		$('#menuTrustees').addClass("activeTab");
		break;
		
		case "2010-photos":
		$('#menu2010Photos').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 1);
	    });
		$("#85thBirthday").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#85thBirthday-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
	    $("#MedicalCamp").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#MedicalCamp-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		$("#Janmashtami").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#Janmashtami-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		$("#Gurupoornima").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#Gurupoornima-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		$("#Easwaramma").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#Easwaramma-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;
		
		case "2009-photos":
		$('#menu2009Photos').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 1);
	    });
	    $("#Birthday84").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#Birthday84-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;
		
		case "chronology":
		$('#menuChronology').addClass("activeTab");
		$("#timeline").scrollable({size:1}).navigator({naviItem:'li'}).mousewheel();
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });
		break;
		
		case "swamis-visit-to-east-africa":
		$('#menuAfricaVisit').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });
		break;
		
		case "beginnings":
		$('#menuBeginnings').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });
		$("#beginnings").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#beginnings-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		$("#mahadwara").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#mahadwara-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;
		
		case "stupa":
		$('#menuStupa').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });		
		$("#stupa").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#stupa-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;

		case "lingam":
		$('#menuLingam').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });
		break;
		
		case "new-centre-building":
		$('#menuNewCentre').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 2);
	    });
		$("#newcentre").scrollable({hoverClass: 'hover', size:5})
					.navigator({naviItem:'li'})
					.mousewheel()
					.find("a").overlay({target: '#newcentre-gallery', expose: '#111'})
					.gallery({ disabledClass: 'inactive' });
		break;
		
		case "sai-links":
		$('#menuSaiLinks').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 3);
	    });
		break;
		
		case "logos":
		$('#menuLogos').addClass("activeTab");
		$(window).load(function() {
		   $('#accordion').accordion('activate', 3);
	    });
		break;
		
		case "prayers":
		$('#menuPrayers').addClass("activeTab");
		$("#tabs").tabs();
		$(window).load(function() {
		   $('#accordion').accordion('activate', 3);
	    });		
		break;
		
		default:
		break;
	}
}


