/*===========================================================================
	Presentational (Global)
	
	This JavaScript executes dynamic behaviors such as:
	* Preloading images
	* Flash Replacements (i.e. sIFR, UFO, SWFObject, etc.)
===========================================================================*/

/* Fix background-image Flickering for a:hover in Internet Explorer
===========================================================================*/

/*
	No More IE6 Background Flicker - Cristi Balan
	http://evil.che.lu/2006/9/25/no-more-ie6-background-flicker
*/

try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

/* Fix IE High Resolution DPI Zoom
===========================================================================*/

if (window.screen.logicalXDPI && window.screen.deviceXDPI && (screen.logicalXDPI / screen.deviceXDPI) != 1) {
	Event.onAvailable("page", function() {
		document.body.style.zoom = screen.logicalXDPI / screen.deviceXDPI;
	});
}

/* sIFR Replacement
===========================================================================*/

if (!(window.screen.logicalXDPI && window.screen.deviceXDPI && (screen.deviceXDPI / screen.logicalXDPI) != 1)) {
	var bickham = {
		src: '/_media/_global/bickham-script-mm.swf',
		ratios: [8,1.3,9,1.22,10,1.25,11,1.22,12,1.2,18,1.19,21,1.15,22,1.16,30,1.15,40,1.14,51,1.13,82,1.12,84,1.11,85,1.12,89,1.11,90,1.12,1.11]
	};
	
	sIFR.repaintOnResize = false;
	sIFR.activate(bickham);
	
	sIFR.replace(bickham, {
		selector: "h1.sifr-text-center",
		css: { 
			".sIFR-root": { "text-align": "center", "font-size": "70px", "color": "#A61F23", "margin-left": "25px", "kearning": true, "leading": -10 }
		},
		tuneHeight: 5,
		wmode: "transparent"//,
	});
	
	sIFR.replace(bickham, {
		selector: "h1",
		css: { 
			".sIFR-root": { "font-size": "70px", "color": "#A61F23", "margin-left": "25px", "kearning": true, "leading": -10 }
		},
		tuneHeight: 5,
		wmode: "transparent"//,
	});
	
	sIFR.rollback("div#primary-content-guinness h1");
}

/* Reflow
===========================================================================*/

DBeer.presentational.Reflow = function() {
	return {
		inIE: function(element) {
			if (!element) {
				element = document.body;
			}
			
			if (YAHOO.env.ua.ie) {
				window.setTimeout(function() {
					element.className = element.className;
				}, 300);
			}
		},
		
		inGecko: function() {
			if (YAHOO.env.ua.gecko) {
				Dom.setStyle(document.body, "width", "99.9%");
				
				window.setTimeout(function() {
					Dom.setStyle(document.body, "width", "");
				}, 300);
			}
		}//,
	};
}(); // self calling

/* Reflow Content
===========================================================================*/

Event.addListener(window, "load", function() {
	DBeer.presentational.Reflow.inIE();
});

/* Flash Notice
===========================================================================*/

DBeer.presentational.flashNotice = function() {
	var _animation = function(module) {
		var colorAnimation = new YAHOO.util.ColorAnim(module, { backgroundColor: { from: 'rgb(211,229,229)', to: 'rgb(255,255,255)' } }, 1.5, YAHOO.util.Easing.easeOut);
		colorAnimation.animate();
	};
	
	return {
		animate: function(module) {
			module = Dom.get(module) || this;
			
			if (!module || module == DBeer.presentational.flashNotice) {
				return false;
			}
			
			var notice = module.getElementsByTagName("p")[0];
			_animation(notice);
		}//,
	};
}(); // self calling

Event.onAvailable("notice", DBeer.presentational.flashNotice.animate);
