﻿var scrollSpeed = 70; 		// Speed in milliseconds
var step = 1; 				// How many pixels to move per step
var current = 0; 		// The current pixel row
var imageWidth = 4300; 	// Background image height
var headerWidth = 300; 	// How tall the header is.
//The pixel row where to start a new loop
var restartPosition = -(imageWidth - headerWidth);
function scrollBg() {
    //Go to next pixel row.
    current -= step;

    //If at the end of the image, then go to the top.
    if (current == restartPosition) {
        current = 0;
    }
    //Set the CSS of the header.
    $('.clouds-r2l').css("background-position", imageWidth - current + "px");
    $('.clouds-l2r').css("background-position", current + "px");
    $('.water-effect').css("background-position", current + "px");
}
//Calls the scrolling function repeatedly
var init = setInterval("scrollBg()", scrollSpeed);


var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;
var countslides = $("div.panelContainer div.panel").length;

theInterval = function (cur) {
    clearInterval(theInt);

    if (typeof cur != 'undefined')
        curclicked = cur;

    $crosslink.removeClass("active-thumb");
    $navthumb.eq(curclicked).parent().addClass("active-thumb");
    $(".stripNav ul li a").eq(curclicked).trigger('click');

    theInt = setInterval(function () {
        $crosslink.removeClass("active-thumb");
        $navthumb.eq(curclicked).parent().addClass("active-thumb");
        $(".stripNav ul li a").eq(curclicked).trigger('click');
        curclicked++;
        if (countslides == curclicked)
            curclicked = 0;

    }, 3000);
};

$(function () {
    $("#main-photo-slider").codaSlider();

    $navthumb = $(".nav-thumb");
    $crosslink = $(".cross-link");

    $navthumb
    	.click(function () {
    	    var $this = $(this);
    	    theInterval($this.parent().attr('href').slice(1) - 1);
    	    return false;
    	});

    theInterval();
});

var ie = (function () {
    var undef,
			v = 3,
			div = document.createElement('div'),
			all = div.getElementsByTagName('i');
    while (
			div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
			all[0]
		);
    return v > 4 ? v : undef;
} ());

if ($.browser.msie || $.browser.opera) {
    jQuery(document).ready(function () {
        //Boat moving								
        $(".moving-boat").queue(function (m_boat) {
            $(this).animate({ top: "-12px" }, 2000,
			function () {
			    $(this).animate({ top: "-16px" }, 2000);
			});
            $(this).queue(arguments.callee);
            m_boat();
        });
        $(".boat-image").queue(function (boat_img) {
            $(this).animate({ right: "40px" }, 4000,
			function () {
			    $(this).animate({ right: 0 }, 4000);
			});
            $(this).queue(arguments.callee);
            boat_img();
        });
        //Balloon moving
        $(".balloon").queue(function (balloon) {
            $(this).animate({ top: "-36px" }, 2000,
			function () {
			    $(this).animate({ top: "-44px" }, 2000);
			});
            $(this).queue(arguments.callee);
            balloon();
        });
        $(".balloon span").queue(function (balloon_span) {
            $(this).animate({ left: "10px" }, 4000,
			function () {
			    $(this).animate({ left: 0 }, 4000);
			});
            $(this).queue(arguments.callee);
            balloon_span();
        });
        //login-div moving
        $(".login-div").queue(function (login_div) {
            $(this).animate({ top: "40px" }, 3000,
			function () {
			    $(this).animate({ top: "10px" }, 3000);
			});
            $(this).queue(arguments.callee);
            login_div();
        });
    });
}
if ($.browser.msie && $.browser.version === "6.0") { $("div.login-div").hover(function () { $(this).css("background-position", "0 -168px"); }, function () { $(this).css("background-position", "0 0"); }); }

