if ($j.browser.msie && ($j.browser.version == "6.0")) {
}
else {
	
}

$j(document).ready(function() {
	
	$j("#locations .accordion").accordion({
		active: 0,
		change: function(e, ui) {
			var i = $j(this).find('.ui-state-active').index()/2;
			//console.log(i);
			$j('#map').children().hide();
			$j('#map').children(':eq('+i+')').toggle();
		}		
	});
	
	//$j('#sitemap .links>li').each(function(index) {
		//$j('#sitemap .links>li:eq('+index+')').addClass('last');
	//});
	$j('#sitemap ul.links>li:nth-child(9)').append('<hr />');
	$j("#sitemap li:nth-child(10)").addClass('first');
	
	$j('._saBar ._dropdown ul').attr('id','bar');
	
	$j('#menu').children().addClass('ni');
	$j('#menu .active').parents('.ni').addClass('active');
	
	$j('.list li:last-child').addClass('last');
	
	$j('#sitemap>ul').addClass('links');
	
	$j('#sitemap ul li').prepend('<span></span>');
	
	//$j('#sitemap li li a').prepend('&middot; ');
	
	$j('.faqs.q p').prepend('Q: ');
	$j('.faqs.a p').prepend('<b>A:</b> ');
	$j('.faqs p:last-child').addClass('last');
	$j('.faq-list:odd').css("background-color", "#f2f2f2");
	$j('.faq-list:odd').addClass('odd');
	$j('.faq-list:first-child').addClass('first');
	
	//$j('._entry_staffs:odd').css("background-color", "#f2f2f2");
	$j('#p_staff-directory ._saContent .staff-list:odd').css("background-color", "#f2f2f2");

	$j('#slideshow').cycle({
		next: '.next'
	});
	
	$j("#sitemap h2").click(function() {
		$j(this).toggleClass("active");
		$j("#sitemap .links").toggle();
		return false;
	}).next().hide();
	
	$j('a.reveal').unbind();
	$j('a.reveal').click(function(e){
		e.preventDefault();
		var h = $j(this).attr('href');
		if ($j(h).length != 0) {
			$j(h).toggle();
			//$j('.short_desc').toggleClass('revealed');
			$j(this).toggleClass('revealed');
		}
	});	
	
	// print
	$j('#_site-functions a.print').click(function(e) {
			e.preventDefault();
			window.print();
			return false;
	});
	
	// Reset Font Size
		var originalFontSize = $j('body').css('font-size');
		$j(".resetFont").click(function(){
			$j('body').css('font-size', originalFontSize);
		});
	
	// Increase Font Size
	$j("#_site-functions a.font-larger").click(function(e){
		e.preventDefault();
		var currentFontSize = $j('body').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.2;
		$j('body').css('font-size', newFontSize);
		//return false;
	});
	
	// Decrease Font Size
	$j("#_site-functions a.font-smaller").click(function(e){
		e.preventDefault();
		var currentFontSize = $j('body').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.8;
		$j('body').css('font-size', newFontSize);
		//return false;
	});
	
	// # Modal Window
	$j("a.modal").fancybox({
		//'modal' : true
		scrolling: 'no',
		autoScale: 'true'
	});
	
	$j("#donate a").click(function(e){
		e.preventDefault();
		$j("#donate input._submit").click();		
	});
	
	$j('input.alert').click(function(e){
		alert($j(this).attr('title'));
	});
	
	$j("._saContent.listView").accordion({
		autoHeight: false
	});
	
	$j.ajaxSetup({
	  async: false
	});
	
	var allDates;
	function getDates(data) {
		allDates = data;
	}	
	$j.getJSON('_assets/ajax.php?a=list-events-json', getDates,{async:false});
	
	$j( "#eventpicker" ).datepicker({
		dateFormat: 'yy-mm-dd',
		onSelect: function(value, obj) {
			$j('#eventList').load('_assets/ajax.php?a=list-events&eventdate='+value);
		},
		onChangeMonthYear: function(year, month, obj) {
			$j('#eventList').load('_assets/ajax.php?a=list-events&year='+year+'&month='+month);
		},
		beforeShowDay: function (date) {
			var day = date.getDate();
			var month = date.getMonth()+1;
			var year = date.getFullYear();
			day = day+'';
			month = month+'';
			year = year+'';
			
			if (day.length == 1)
				day = '0'+day;
			if (month.length == 1)
				month = '0'+month;

			date = ''+year+'-'+month+'-'+day;
			for (var i = 0; i < allDates.length; i++) {			
				if (allDates[i] == date) {
					return [true, 'hasEvent'];
				}
				else {
				}
			}
			return [true, ''];
		}
	});	
	
	$j('.textobj img[style*=left]').addClass('_floatleft');
	$j('.textobj img[style*=right]').addClass('_floatright');
});
