function init()
{
	$('#photoStream').galleria({
        width: 650,
        height: 600
    });
	
	//set/check cookie for homepage animation
	nomNomCookie();
	//find out what page we're on to apply .current class
	$('ul#nav > li > a.navLink').click(whereAmI());
	//nav background image animation
	$('ul#nav li a').hoverIntent(
		  function () {
			if (!$(this).parent().hasClass('current')){  // if this is not the current page fire event
				$(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200);
				$(this).animate({backgroundPosition:"(0 -5px)"}, 150);
			}
		  },
		  function () {
			$(this).animate({backgroundPosition:"(0 -149px)"}, 200);
		  }
    );	
	

	$('#drinkMenuBtn').click(function(){
		$('#drinkMenu').dialog({
			modal:true, 
			width: 'auto',
			minHeight:'auto',
			resizable: false,
			draggable: false,
			closeOnEscape: true,
			buttons: {"Close":function() { 
				$(this).dialog("close");
			} }
		});
	});
	
	$('#foodMenuBtn').click(function(){
		$('#foodMenu').dialog({
			modal:true, 
			width: 'auto',
			minHeight:'auto',
			resizable: false,
			draggable: false,
			closeOnEscape: true,
			buttons: {"Close":function() { 
				$(this).dialog("close");
			} }
		});
	});

	/*
	$('#adminPortal').dialog({
		modal: true,
		title: 'Admin Portal',
		width: 800,
		height: 800,
		resizable: false,
		draggable: false,
		closeOnEscape: false,
		buttons: {
			"Cancel":function() { 
				$(this).dialog("close"); window.location.href = '/';
			},
			"Submit":function(){
				$(this).dialog("close");
			}
		}
	});
	*/

	
	$('#updateType').change(function(){
		switch ($(this).val()){
			case 'Events':
				$('#eventsSec').dialog({
					modal:true, 
					width: 'auto',
					minHeight:'auto',
					resizable: false,
					draggable: false,
					closeOnEscape: true,
					buttons: {"Cancel":function() { 
						$(this).dialog("close");
					},"Submit":function(){ } }
				});
			break;
			case 'Beers':
				$('#draughtsSec').dialog({
					modal:true, 
					width: 'auto',
					minHeight:'auto',
					resizable: false,
					draggable: false,
					closeOnEscape: true,
					buttons: {"Cancel":function() { 
						$(this).dialog("close");
					},"Submit":function(){ } }
				});
			break;
			case 'Specials':
				$('#specialsSec').dialog({
					modal:true, 
					width: 'auto',
					minHeight:'auto',
					resizable: false,
					draggable: false,
					closeOnEscape: true,
					buttons: {"Cancel":function() { 
						$(this).dialog("close");
					},"Submit":function(){ } }
				});	
			break;
		}
	});
 
	$('#alertSpecial').dialog({
		modal:true, 
		width: 'auto',
		minHeight:600,
		resizable: false,
		draggable: false,
		closeOnEscape: true,
		buttons: {"OK":function() { 
			$(this).dialog("close");
		} }
	});
	
	$('#alertSpecial').next('.ui-dialog-buttonpane').prepend('<div style="width:80%; position:relative; clear:both; margin: 0 auto; text-align:center; font-weight:bolder; font-size:20px;">.35&cent; Wings, &nbsp;&nbsp;$2.00 Hot Dogs, &nbsp;&nbsp;$3.00 Sausages</div>');
 

}  // end init()

function nomNomCookie(path){
	if (whereAmI(path) == '/'){
		if($.cookie('ocpModalNever') == null){
			if ($.cookie('ocpModal') == null){
				$('#eModal').dialog({
					minWidth:1000, 
					minHeight:600,
					modal: true,
					position: 'top',
					resizable: false,
					draggable: false,
					open: function() {
						$('#fade').fadeIn(2000, "linear");
						$('#body').hide();
					},
					closeOnEscape: true,
					buttons: [
						{
							text: "Enter Site",
							click: function() { $.cookie('ocpModal','1',{expires:'',path:'/'}); $(this).dialog("close"); }
						},
						{
							text: "Don't Show Again",
							click: function() { $.cookie('ocpModalNever','1',{expires:12020,path:'/'}); $(this).dialog("close");  $('#eModal').hide(); }
						}
					],
					close: function() {
						$('#body').show();
						console.log($.cookie('ocpModalNever'));
						console.log($.cookie('ocpModal'));
					}
				});
			}
		}
	}
}

function whereAmI(){
	path = window.location.pathname;
	directory = path.split('/');
	directory = directory[1];
	switch (directory)
	{
		case "":
			$("li#home").addClass("current");

		break;
		case "home":
			$("li#home").addClass("current");

		break;
		case "food":
			$("li#menu").addClass("current");

		break;
		case "drinks":
			$("li#drinks").addClass("current");

		break;
		case "events":
			$("li#events").addClass("current");

		break;
		case "admin":
			$('body').find('div.ui-dialog-titlebar').css('display','block');
		break;
		default:
		break;
	}
	return path;
}

