jQuery(document).ready(function(){
	
	// jQuery LightBox
	// -----------------------------------------------------------
	jQuery("a[rel=lightbox]").lightBox({
		overlayBgColor: "#000",
		overlayOpacity: 0.8,
		keyToClose: 'esc',
		txtImage: 'Photo'
	});
	// -----------------------------------------------------------
	
	
	// Colorbox
	// -----------------------------------------------------------
	$('a#video-link').colorbox();

	
    
    // Changing homepage photos
	// -----------------------------------------------------------
	
	jQuery("#homeNav").hide();
	jQuery("#show_loader").show();
	jQuery("#show_loader").html('<div id="loading">Loading featured products</div>');
	
	jQuery("#shuffle li").hide();
	jQuery("#shuffle li:first").show();
	jQuery("#homeNav li:first").addClass("active");
	jQuery("#homeNav li a").live("click", (function() {
		
		var showItem = jQuery(this).attr("id");
		
		jQuery("#shuffle li").hide();
		jQuery("#shuffle li."+showItem).show();
		
		jQuery("#homeNav li").removeClass("active");
		jQuery(this).parent().addClass("active");
		
	}));
	// -----------------------------------------------------------

	
	
	// add class "last" to the last item on the product slider
	//------------------------------------------------------------
	jQuery("#flist li:last").css("margin-right","120px");
	
	// jQuery Scroll
	// -----------------------------------------------------------
	jQuery('.scroll').jScrollPane({ scrollbarMargin: 0 });
	
	// jCarousel for product list
	// -----------------------------------------------------------
    jQuery('#featured_list_inner').jcarousel({
    	scroll:3,
        horizontal: true,
        buttonNextHTML: '<a href="javascript:void(0);" class="featNavRight">Next</a>',
        buttonPrevHTML: '<a href="javascript:void(0);" class="featNavLeft">Previous</a>',
        buttonNextEvent: "click",
        buttonPrevEvent: "click"
    });
    
    // Changing product photos
	// -----------------------------------------------------------
	jQuery("#thumbs a:first").addClass("sel");
	jQuery("#thumbs a").live("click", (function() {
		
		var loadPhoto = jQuery(this).attr("href");
		var loadPhotoTitle = jQuery(this).attr("title");
		jQuery("#thumbs a").removeClass("sel");
		jQuery(this).addClass("sel");
		jQuery("#bigPhoto").html('<img src="'+loadPhoto+'" alt="'+loadPhotoTitle+'" title="'+loadPhotoTitle+'" />');
		return false;
		
	}));
	// -----------------------------------------------------------
	
	// set values for newsletter input
	//------------------------------------------
	//var defNL = "Subscribe to mailing list";
	//jQuery("#emailInput").val(defNL);
	//jQuery("#emailInput").focus(function() {
	//	
	//	jQuery(this).val("");
	//	
	//});
	
	jQuery('#shuffle').hide();
	jQuery('#shuffle').onImagesLoaded(function(_this){
		jQuery("#homeNav").show();
	  	jQuery(_this).show();
	  	jQuery("#show_loader").hide();
	});
	
	// PRODUCT BIG PHOTO SLIDING
	// ---------------------------------------------------------------------
	var bigPhotoWrapWidth = jQuery("#product-big-photo").width();
	var countBigPhotos = jQuery("#product-big-photo ul li").length;
	var totalBigPhotoListWidth = countBigPhotos * bigPhotoWrapWidth;
	jQuery("#product-big-photo ul").css( "width", totalBigPhotoListWidth);
	//alert(jQuery("#product-big-photo ul").width());
	// ---------------------------------------------------------------------
	
	// PRODUCT THUMBNAILS / BIG PHOTO PAGINATION - SLIDING
	// ---------------------------------------------------------------------
	jQuery("#product_thumbnails li:first a").addClass("active");
	
	jQuery("#product_thumbnails li a").click(function() {
	
		jQuery("#product_thumbnails li a").removeClass("active");
		jQuery(this).addClass("active");
		
		var show_photo = jQuery(this).attr("href");
		
		jQuery("#product-big-photo img.active").removeClass("active");
		jQuery(show_photo).addClass("active");
		
		jQuery("#product-big-photo").scrollTo( this.hash, 900);
	
		return false;
	
	});
	// ---------------------------------------------------------------------
	
	// FIXS BLOCK HEIGHTS IN CHECKOUT
	// ---------------------------------------------------------------------
	if( jQuery('.leftBlock').length > 0 && jQuery('.rightBlock').length > 0 ) {
	
	
		var leftBlockHeight = jQuery('.leftBlock').height();
		var rightBlockHeight = jQuery('.rightBlock').height();
		
		if( parseInt(leftBlockHeight) > parseInt(rightBlockHeight) ) jQuery('.rightBlock').height(leftBlockHeight);
		if( parseInt(rightBlockHeight) > parseInt(leftBlockHeight) ) jQuery('.leftBlock').height(rightBlockHeight);
	
	}
	// ---------------------------------------------------------------------
	
	
});

// sfHover for IE
// -----------------------------------------------------------
//sfHover = function() {
//	var sfEls = document.getElementById("mainNav").getElementsByTagName("LI");
//	for (var i=0; i<sfEls.length; i++) {
//		sfEls[i].onmouseover=function() {
//			this.className+=" sfhover";
//		}
//		sfEls[i].onmouseout=function() {
//			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//		}
//	}
//}
//if (window.attachEvent) window.attachEvent("onload", sfHover);
