/*
Returns true if the browser supports the passed css property or any property in an array
Optional parameter causes function to return true only if all array properties are supported

ACCEPTS:
	style: (string|array) style string or array to check
	[matchAll]: (boolean) if true, function will only return true if all array items are supported
*/
Browser.supportsStyle = function(style, matchAll){
	var supported = (!matchAll) ? false : true;
	$splat(style).each(function(style){
		switch(matchAll){
			case undefined: if ($defined(document.body.style[style.camelCase()])) supported = true; break;
			default: if (!$defined(document.body.style[style.camelCase()])) supported = false;
		}
	});
	return supported;
};


var site = {
	
	initialize: function(){
		if (!Browser.supportsStyle(['-moz-box-shadow', '-webkit-box-shadow', '-o-box-shadow', 'box-shadow', 'filter']))
			new Asset.javascript('/js/build/jquery.jquery.dropshadow.js.ycomp.js');
		
		// Menu setup
		if (!Browser.Engine.trident4){
			$$('#menu li a').each(function(a){
				var hoverEl = new Element('div', {
					'class': a.get('class') + ' current',
					styles: {
						position: 'absolute',
						top: 0,
						opacity: 0
					}
				}).inject(a);
				
				a.addEvents({
					mouseenter: function(){
						hoverEl.fade(1);
					},
					mouseleave: function(){
						hoverEl.fade(0);
					}
				});
			});
		}
		
		// Smooth scroll setup
		var products = $('products');
		if (products){
			new Fx.SmoothScroll({
			    links: '.scroll'
			});
		}
	},
	
	start: function(){
		if (!Browser.supportsStyle(['-moz-box-shadow', '-webkit-box-shadow', '-o-box-shadow', 'box-shadow', 'filter'])){
			jQuery.noConflict();
			jQuery('#inner-container').dropShadow({
				top: 4,
				left: -4,
				blur: 4,
				opacity: 0.6
			});
		}
		
		if (Browser.Engine.trident4){
			$('shadow').setStyles({
				height: $('inner-container').getSize().y,
				visibility: 'visible'
			});
		}
	}
	
};

window.addEvent('domready', site.initialize);
window.addEvent('load', site.start);