// Site-specific Javascript file

function soGallery() {
  if($('#gallery').length) {
    var so_gallery = new SWFObject("/flash/gallery.swf", "flash-gallery", "550", "400", "9.0.28", "#daf6dd");
    so_gallery.addParam("wmode", "window");
    so_gallery.addParam("allowFullScreen", "true");
    so_gallery.write("gallery");
  }
}

function initCupcakes() {
	if($("#cupcakes").length == 0) return;
	$("#cupcakes li dl dt").defTip();
	var today = new Date().getDay();
	var displayIdx = today == 0 ? 0 : today - 1;
	var days = $("#cupcakes li");
	if(displayIdx == today - 1) {
		var activeday = $(days[displayIdx]).find('p.day');
		activeday.text('Today');
		Cufon.replace(activeday);
	}
	days.find('dl').hide();
	$(days[displayIdx]).addClass('expanded').find('dl').show();
	days.find('p.day').click(
		function() {
			var obj = $(this).parent();
			if(obj.hasClass('expanded')) {
				obj.removeClass('expanded').find("dl").slideUp(200);
			} else {
				obj.addClass('expanded').find("dl").slideDown(200);
			}
			Cufon.replace($(this));
		}
	);
}

function initCoffee() {
	$("#coffee li dl dt").defTip();
}

function initCufon() {
	Cufon.replace("body.home #sidebar h2");
	Cufon.replace("body.home #cupcakes li p.day");
	Cufon.replace("body.home #coffee li p.feature");
	//Cufon.replace("#titlebar .button a", { textShadow: '0 2px #00006a', hover: true });
	//Cufon.replace("#primary-nav li[id!=location-selector] a", { hover: true, textShadow: '0px 2px #00004F' });
	//Cufon.replace("#primary-nav #location-button", { hover: true, textShadow: '0px -1px #00004F' });
	//Cufon.replace("#content h1");
	//Cufon.replace("#content h2");//$("#content h2").not('#content h2.de-emphasized'));
	//Cufon.replace("#info h2");
	//Cufon.replace("#contact span.phone");
}
//jQuery(initCupcakes);
jQuery(initCoffee);
jQuery(soGallery);