﻿$(document).ready(function(){

	// Accordion
	$( "#accordion" ).accordion({
	header: 'h3',
	navigation: true,
	active: '.selected',
	autoHeight: false,
	clearStyle: true,
	alwaysOpen: false,
	animated: false
});

	// Tabs
	$("#tabs_secure").tabs();
	$("#tabs_event_edit").tabs();

	// Dialog			
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}
//			"Cancel": function() { 
//				$(this).dialog("close"); 
//			} 
		}
	});
	
	$('#dialog_map').dialog({
		autoOpen: false,
		width: 200,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}
		}
	});


	// Dialog Link
	$("#dialog_link").click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	
	$( "#opener" ).click(function() {
		$( "#dialog" ).dialog( "open" );
		return false;
	});

	$( "#dialog-form" ).dialog({
		autoOpen: false,
		width: 650,
		modal: true,
		buttons: {
			Close: function() {
				$( this ).dialog( "close" );
			}
		}
	});
	
	$( "#show-picture" )
		.button()
		.click(function() {
			$( "#dialog-form" ).dialog( "open" );
			$( "#dialog-form" ).height($("church-door").height());
		});

	$( "#show-map" )
		.button()
		.click(function() {
		return false;
		});

// Datepicker
	$('#startdatepicker').datepicker({
		numberOfMonths: 2,
		showButtonPanel: true,
		dateFormat: 'D M-d-yy'
	});
	
	$('#enddatepicker').datepicker({
		numberOfMonths: 2,
		showButtonPanel: true,
		dateFormat: 'D M-d-yy'
	});
	
	// Slider
	$("#slider").slider({
		range: true,
		values: [17, 67]
	});
	
	// Progressbar
	$("#progressbar").progressbar({
		value: 20 
	});
	
	//hover states on the static widgets
//	$('#dialog_link, ul#icons li').hover(
//		function() { $(this).addClass('ui-state-hover'); }, 
//		function() { $(this).removeClass('ui-state-hover'); }
//	);
});

function changeStory(reference){
	

switch(reference){
	case 'meetings':
		window.location.href='meeting list.php';
		break;
	case 'maps':
		var d=new Date();
		var weekday=new Array(7);
		weekday[0]="Sunday";
		weekday[1]="Monday";
		weekday[2]="Tuesday";
		weekday[3]="Wednesday";
		weekday[4]="Thursday";
		weekday[5]="Friday";
		weekday[6]="Saturday";

		window.location.href='meeting map.php?Day='+weekday[d.getDay()];
		break;
	case 'newcomers':
		window.location.href='newcomer.php';
		break;
	case 'events':
		window.location.href='event list.php';
		break;
	case 'resources':
		window.location.href='group resources.php';
		break;
	case 'links':
		window.location.href='alanonlinks.php';
		break;
	case 'contact':
		window.location.href='contactus.php';
		break;
	case 'admin':
		window.location.href='admin.php';
		break;
	}
}

function refresh(acindex){
	//alert(acindex);
	$("#accordion").accordion("option", "active", acindex );
	var d=new Date();
	$("#page_body").tabs().tabs('select', d.getDay());
	makevisible();
}

function makevisible(){
$("#accordion").css("visibility", "visible");
$("#page_body").css("visibility", "visible");
$("#page_body_map").css("visibility", "visible");
$("#map_canvas").css("visibility", "visible");
}
