/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 4000 );
});










jQuery(document).ready(function($) {

$("body").addClass("js"); // .js class


//$("#slideshow IMG").addClass("active");



// Contact form spam prevention.
// This js autofills a captcha-like question.
$("#contact-form input[type=text]").focus(function(){
	$("p.no-spam input[type=text]").val('20');	
});

$("#subscription_content input[type=text]").focus(function(){
	$("span.no-spam input[type=text]").val('20');	
});




// Gallery buttons fade in-out
$("a.gal_btn").hover(function(){
	$(this).animate({'opacity' : 0.7}, 150);
} , function() {
	$(this).animate({'opacity' : 1}, 300);
});




// Shop Product preview fade in-out
$(".default_product_display .product_image").css("opacity", 0.8);

$(".default_product_display").hover(function(){
	$(this).children("a").children(".product_image").animate({'opacity' : 1}, 150);
} , function() {
	$(this).children("a").children(".product_image").animate({'opacity' : 0.8}, 300);
});










// Width override on slider

var total_width = 0;

$("#slider li").each(function(){
	var li_length = ($(this).width()) * 1;
	$(this).attr("rel", li_length);
	total_width += li_length;
	});
$("#slider ul").css("width", total_width + "px");
$("#slider").css("width", total_width + "px");









// Position Fixed (sort of) for Header and Footer

// #h and #f need to be in the flow of the document but positioned relative to the left hand side of the window;
// horizontal scroll offset needs to match pos-rel left offset.

/*
$('#header').css("position", "relative");
$('#footer').css("position", "relative");

$(window).scroll(function () { 
	var scrollLeft = $(window).scrollLeft();
	$('#header').css("left", scrollLeft);
	$('#footer').css("left", scrollLeft);
});


*/




//$('#g_page').css("position","relative");

/*
$('#header')
	.css("position", "fixed")
	.css("left", "0px");

$('#footer')
	.css("position", "fixed")
	.css("left", "0px");

$('#g_page .gallery-page').css("margin-top", "130px");
*/

var galHeight = $('#g_page .gallery-page').height();

var scrollTop = $(window).scrollTop();
$('#header').css("top", -scrollTop);
$('#footer').css("top", -scrollTop + galHeight + 130);

	
$(window).scroll(function () { 
	var scrollTop = $(window).scrollTop();
	$('#header').css("top", -scrollTop);
	$('#footer').css("top", -scrollTop + galHeight + 130);
});







}); //end





