var addthis_pub = "crumbsbakery";

//setup the namespace
if (typeof crumbs == "undefined" || !crumbs) {
    var crumbs = {};
}

var screenManager;
function initScreenManager() {
	screenManager = new crumbs.ScreenManager();
	document.fire('crumbs:load');  // our custom event alerting that the screenManager is available
}

Event.observe(window, 'load', initScreenManager);

function initHomepageMovie() {
	if(!$('homepage-presentation')) return false;
	
	var flashVersion = "8";
	if(swfobject.hasFlashPlayerVersion(flashVersion)) {
		var flashvars = {xmlPath:TEMPLATE_PATH + "flash/xml/crumbs_home.xml"};
		var params = {};
		var attributes = {bgcolor: "#F0EACC"};
		swfobject.embedSWF(TEMPLATE_PATH + "flash/crumbs_home.swf", "homepage-presentation", "100%", "336", flashVersion, null, flashvars, params, attributes)
	} else {
		$('homepage-noflash').setStyle({display: 'block'});
	}
}
Event.observe(window, 'load', initHomepageMovie);

/*
 * check for console namespace. If it's not present, use
 * our own console object which has empty methods for each
 * of those found in the FF console.
 */
//if (!Prototype.Browser.Gecko || document.location.host.substr(-5) != ".site" || !window.console || !window.console.firebug) {
//    var console = opconsole;	
//}

/*
 * Unregisters a Varien listener, which monitors when Ajax requests are sent out.
 * See ticket #129.
 */
Ajax.Responders.unregister(Varien.GlobalHandlers);

/**
 * Add This specific functions to enable the icon color change on rollover
 */
var addthis_offset_left = -217;
function addthisOver(elm, link, title) {
	var img = Element.select(elm, "img");
	img = img[0];
	img.setAttribute("origsrc", img.getAttribute("src"));
	img.setAttribute("src", img.getAttribute("oversrc"));
	return addthis_open(elm, '', link, title);
}
function addthisOut(elm) {
	var img = Element.select(elm, "img");
	img = img[0];
	img.setAttribute("src", img.getAttribute("origsrc"));
	addthis_close();
}

/**
 * RSS specific functions to enable the icon color change on rollover
 */
function rssOver(elm) {
	var img = Element.select(elm, "img");
	img = img[0];
	img.setAttribute("origsrc", img.getAttribute("src"));
	img.setAttribute("src", img.getAttribute("oversrc"));
}
function rssOut(elm) {
	var img = Element.select(elm, "img");
	img = img[0];
	img.setAttribute("src", img.getAttribute("origsrc"));
}