// JavaScript Document

jQuery(document).ready(function($) {
	
	if($('#product-gallery #thumbs').length > 0) {
		var onMouseOutOpacity = 0.65;
		$('#thumbs ul.thumbs li').opacityrollover({mouseOutOpacity:onMouseOutOpacity, mouseOverOpacity:1.0, fadeSpeed:'fast', exemptionSelector:'.selected'});
		var gallery = $('#thumbs').galleriffic({delay:2500, numThumbs:9, preloadAhead:10, enableTopPager:false, enableBottomPager:true, maxPagesToShow:8, imageContainerSel:'#slideshow', 
		loadingContainerSel:'#loading', renderSSControls:false, renderNavControls:false, enableHistory:false, autoStart:false, syncTransitions: true, defaultTransitionDuration: 900,
		onSlideChange: function(prevIndex, nextIndex) { this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0); },
		onPageTransitionOut: function(callback) { this.fadeTo('fast', 0.0, callback); }, onPageTransitionIn: function() { this.fadeTo('fast', 1.0); }});
	}

	if($('#portfolio-gallery #thumbs').length > 0) {
		var onMouseOutOpacity = 0.65;
		$('#thumbs ul.thumbs li').opacityrollover({mouseOutOpacity:onMouseOutOpacity, mouseOverOpacity:1.0, fadeSpeed:'fast', exemptionSelector:'.selected'});
		var gallery = $('#thumbs').galleriffic({delay:2500, numThumbs:16, preloadAhead:10, enableTopPager:false, enableBottomPager:true, maxPagesToShow:8, imageContainerSel:'#slideshow', 
		loadingContainerSel:'#loading', renderSSControls:false, renderNavControls:false, enableHistory:false, autoStart:false, syncTransitions: true, defaultTransitionDuration: 900,
		onSlideChange: function(prevIndex, nextIndex) { this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0); },
		onPageTransitionOut: function(callback) { this.fadeTo('fast', 0.0, callback); }, onPageTransitionIn: function() { this.fadeTo('fast', 1.0); }});
	}
	
	if($('#mainpage-gallery #thumbs').length > 0) {
		var onMouseOutOpacity = 0.65;
		$('#thumbs ul.thumbs li').opacityrollover({mouseOutOpacity:onMouseOutOpacity, mouseOverOpacity:1.0, fadeSpeed:'fast', exemptionSelector:'.selected'});
		var gallery = $('#thumbs').galleriffic({delay:2500, numThumbs:6, preloadAhead:10, enableTopPager:false, enableBottomPager:true, maxPagesToShow:8, imageContainerSel:'#slideshow', 
		loadingContainerSel:'#loading', renderSSControls:false, renderNavControls:false, enableHistory:false, autoStart:false, syncTransitions: true, defaultTransitionDuration: 900,
		onSlideChange: function(prevIndex, nextIndex) { this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0); },
		onPageTransitionOut: function(callback) { this.fadeTo('fast', 0.0, callback); }, onPageTransitionIn: function() { this.fadeTo('fast', 1.0); }});
	}
	
	if($('ul.tabs li').length > 0) {
		$(".tab_content").hide();
		$("ul.tabs li:first").addClass("active").show();
		$(".tab_content:first").show();
		
		$("ul.tabs li").click(function() {
			$("ul.tabs li").removeClass("active");
			$(this).addClass("active");
			$(".tab_content").hide();
			var activeTab = $(this).find("a").attr("href");
			$(activeTab).fadeIn();
			return false;
		});
	}
	
	if($('form#order-form').length > 0) {
		$('form#order-form [name="length"]').click(function() { 
			if($(this).val() == "Length in Feet") { $(this).val(''); }
		}).focusout(function() {
			if($(this).val() == "") { $(this).val('Length in Feet'); } 
		});
		
		$('form#order-form [name="width"]').click(function() { 
			if($(this).val() == "Width in Feet") { $(this).val(''); }
		}).focusout(function() {
			if($(this).val() == "") { $(this).val('Width in Feet'); }
		});
	}
});
