// ** Font stuff with Cufon **
// **
if (typeof(Cufon) != 'undefined') {
	Cufon.replace('h2', { fontFamily: 'Gm' });
	Cufon.replace('#top-navigation a', { fontFamily: 'Gm', hover: true });
	Cufon.replace('#main-navigation li a', { fontFamily: 'Gm', hover: true });
};


// ** Add search functionality **
// **                          **
$(function(){ // (executes when the dom is ready)
	
	// add search field for webkit/safari
	if ($.browser.safari) {
		// replace existing search box
		$("#q").replaceWith('<input id="safari-search" type="search" name="keywords" value="" placeholder="" results="10" autosave="org.theoldjailartcenter.search"/>');
		// hide button but keep spacing
		$("#go").css("display","none");
		// update search label to point to new search field
		$("#search-text").attr("for","safari-search");
	};
	
});

// ** Check height of third nav and adjust **
// **                                      **
$(function(){ // (executes when the dom is ready)
	
	if ($("#nav-sub2").height() > 30) {
		$("#nav-sub2").addClass("multiline");
	}
	
});


// embed our flash with UFO
var heroFlashObject = { movie:"/flash/events.swf", width:"790", height:"342", majorversion:"9", build:"0", bgcolor:"#ffffff", wmode:"window", menu:"false", name:"flash-events", id:"flash-events", flashvars:"xmlfile=/ssp/events&;xmlfiletype=Default" };
UFO.create(heroFlashObject, "hero-area");
$(function(){$("#hero-area").addClass("js-yes");}); // add js-yes class since they have js
//var collectionsFlashObject = { movie:"/flash/collections.swf", width:"625", height:"340", majorversion:"9", build:"0", bgcolor:"#ffffff", wmode:"window", menu:"false", name:"flash-collections", id:"flash-collections", flashvars:"xmlfile=/ssp/collections&;xmlfiletype=Default" };
//UFO.create(collectionsFlashObject, "collections");
//$(function(){$("#collections").addClass("js-yes");}); // add js-yes class since they have js

// ** Misc **
// **      **
$(function(){ // (executes when the dom is ready)
	// make logo a link to go back to home page
	$("#logo").click(function(){
		document.location = "/";
	}).css("cursor","pointer");
	// detect iPhone/iPod and add class
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		$("body").addClass("iphone");
	};
	// misc IE 7 stuff
	if ($.browser.msie && ($.browser.version == 7)) {
		
	};
	// misc IE stuff
	if ($.browser.msie && ($.browser.version <= 7)) {
		// hr's
		$("hr").replaceWith('<div class="hr"></div>');
	};
	// misc FF 2 stuff
	if ($.browser.mozilla && $.browser.version.substr(0,3) == "1.8") {
		// inline-block
		$("#oajc-copyright").addClass("oajc-copyright-ff2");
	};
	// stripe table
	$("table.chart").wrap("<div class='chart-wrapper'></div>");
	$("table.chart tr:even").addClass("stripe");
	// switch collections marked as "switchable" with the h2 right below it
	$("#collections.switchable").next("h2").each(function(){
		$("#collections.switchable").before("<h2>"+$(this).html()+"</h2>").next("h2").hide();
	});
});



/* stop IE6 flicker */
try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {}