var flashvars = {};
var params = {};
var attributes = {};
attributes.id = "banner";

swfobject.embedSWF("/shop/flash/shop-banner.swf", "banner", "700", "109", "9.0.0", "/shop/flash/expressInstall.swf", flashvars, params, attributes);

//var baseMainSiteUrl = 'http://drago.php5.truth.posiweb.net/';
var baseMainSiteUrl = '';
var grabNavUrl = baseMainSiteUrl + '/en/ajax-nav/';
var grabHeadImgUrl = baseMainSiteUrl + '/en/ajax-shop-header/';

jQuery.noConflict();

jQuery(document).ready(domSetup);

window.onload = pageSetup;

function domSetup() {
	jQuery('#paint, #mask').hide();
	
	Cufon.replace('#content h2:not(#content .module.events h2.title)', { fontFamily: 'Century Gothic' });
	Cufon.replace('#content h3', { fontFamily: 'Century Gothic' });
	Cufon.replace('#content h4:not(#content h4.listing-summary)', { fontFamily: 'Century Gothic' });
	Cufon.replace('#summary h4', { fontFamily: 'Century Gothic' });
	Cufon.replace('.smaug ul.smaug-slide-controls li a', { fontFamily: 'Century Gothic' });
	
	//go grab the nav markup
	jQuery('#navigation').load(grabNavUrl, {}, function() {
		Cufon.replace('#navigation ul a:not(#navigation ul ul a)', { fontFamily: 'Century Gothic' }); 	
		
		jQuery('#navigation ul.dropdown-menu').superfish({
			delay: 1000,
			dropShadows: false,
			autoArrows: false,
			animation: {'height' : 'show' },
			speed: 'fast'
		}); 
	});
	
	jQuery.getJSON(grabHeadImgUrl, {}, function(json) {
		jQuery('#header').css('background-image', 'url(' + json.path + ')');
	});
	
	jQuery('.slide-container ul').smaugSlide({
		slideHeight: 400,
		easing: 'easeInQuad',
		duration: 500,
		autoScroll: true,
		moreInfoDiv: '#slide-more-info'
	});
	
	jQuery('body').supersleight({
		shim: 'x.gif'
	});
	
	jQuery('#product-gallery ul.more-views li a').click(function() {
		var imgSrc = jQuery(this).attr('href');
		var imgAlt = jQuery(this).attr('title');
		var img = new Image();

		jQuery(img).hide();

		jQuery('#product-image').height(jQuery('#product-image img').height());

		jQuery('#product-image').addClass('loading').find('img').fadeOut('normal', function() {
			jQuery(img).load(function() {
				jQuery('#product-image').animate({height: img.height}).removeClass('loading');

				jQuery(this).appendTo('#product-image').fadeIn();
			}).error(function() {

			}).attr({
				src: imgSrc,
				alt: imgAlt,
				title: imgAlt
			});

			jQuery('#product-image').empty();
		});
		
		return false;
	});
	
}

function pageSetup() {

	jQuery('.recently li').height(jQuery('.recently ul').outerHeight());
	
	setTimeout(
		function(){
			// Spray
			jQuery('#paint, #mask').show();

			 // Drip
			jQuery('#shop-navigation').fadeTo(4000, 0.8);
			jQuery('#mask').animate({'top' : 400}, 4000, 'swing', function() {
				jQuery(this).hide();
			});
		}, 3000
	);
}

