try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
var fancyboxDefOptions = {'overlayShow': true, 'overlayOpacity': 0.70, 'zoomSpeedIn' : 300, 'zoomSpeedOut' : 400};

$(function() {
	// image preload
	$.preloadImages(_appRoot + "/images/background/menu-"+_lang+"-hover.png");

	// png fix for ie6
	$('.foo').supersleight({shim: 'images/blank.gif'});
	
	// scroller
	if ($.isFunction($.fn.scroller)) {
			$(".scroller:not(.double-scroller)").scroller();
			$(".double-scroller").scroller({lines: 2});
	}
	
	// slideshow
	if ($.isFunction($.fn.slideshow)) {
			$(".slideshow").slideshow();
	}
	
	// submit
	$("a.submit").click(function() {
		$(this).parents("form").submit();
		return false;
	});
	
	// fancybox init
	if ($.isFunction($.fn.fancybox)) {
		$(".gallery:not(.video) a, a.main").fancybox(fancyboxDefOptions);
		$(".video a").fancybox($.extend(fancyboxDefOptions, { width: 680, height: 540, type: 'iframe', padding: 0 }));
	}
	
	// video image mask
	$(".video a").each(function() {
			$img = $("<img>").addClass("mask").attr("src", _appRoot + "/images/play.gif").css({ 'opacity': 0.70 }).hover(
			function() { $(this).dequeue().animate({ "opacity": 0.35 }, 250, "easeOutBack") },
			function() { $(this).dequeue().animate({ "opacity": 0.70 }, 250, "easeOutBack") }
		);
		$(this).append($img);
	});
	
	$("#products li").hover(function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); });
});

jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
