﻿// Copyright (c) 2010 PageBean, Inc.  (http://www.pagebean.com)
// All rights reserved.

$(document).ready(
    function(){
        $("#filterContainer .header").click(
            function(){

                var dropDown = ($(this).next());

                if (dropDown.hasClass("expanded")) {
                    dropDown.slideUp("slow");
                    dropDown.removeClass("expanded");
                    $(this).children("div").children("img").attr("src", "/theme/main/images/downArrowSearch.jpg");
                } else {
                    dropDown.slideDown("slow");
                    dropDown.addClass("expanded");
                    $(this).children("div").children("img").attr("src", "/theme/main/images/upArrowSearch.jpg");
                }
            }
        );
    }
);


$(document).ready(
    function() {
        $("#brandingNavigation .header").click(
            function() {

                var $brandingSlide = $('.BrandingSlide');

                $('.header').each(function() {
                    var dropDown = ($(this).next());
                    dropDown.slideUp("slow");
                    dropDown.removeClass("expanded");
                    $(this).children(".brandingArrow").children("img").attr("src", "/theme/main/images/brandingArrowRight.png");
                })
                
                var dropDown = ($(this).next());

                if (dropDown.hasClass("expanded")) {
                    //dropDown.slideUp("slow");
                    //dropDown.removeClass("expanded");
                    //$(this).children("div").children("img").attr("src", "/theme/main/images/brandingArrowDown.png");
                } else {
                    dropDown.slideDown("slow");
                    dropDown.addClass("expanded");
                    $(this).children(".brandingArrow").children("img").attr("src", "/theme/main/images/brandingArrowDown.png");
                }
            }
        );
    }
);

function slideDownNav(divId) {
    $("#" + divId).slideDown("slow");
    $("#" + divId + "-LINK").attr("href", "JavaScript:slideUpNav('" + divId + "');");
    $("#" + divId + "-LINK").html("<img src='/theme/main/images/upArrowSearch.jpg' />");
}

function slideUpNav(divId) {
    $("#" + divId).slideUp("slow");
    $("#" + divId + "-LINK").attr("href", "JavaScript:slideDownNav('" + divId + "');");
    $("#" + divId + "-LINK").html("<img src='/theme/main/images/downArrowSearch.jpg' />");
}

$(document).ready
(
    function() {

        $("#bestSellersSlideRight").click(function() {
            if (-$("#bestSellersContainer").outerWidth() < ($("#bestSellersContainer").css('left').replace('px', '') - 868 - 1))
                $("#bestSellersContainer").animate({ 'left': "-=868px" });
            
            //CHECK RIGHT ARROW
            if (-$("#bestSellersContainer").outerWidth() >= ($("#bestSellersContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowBestSellers").attr("src", "/theme/main/images/slideRightArrowOFF.jpg");
            } else {
                $("#slideRightArrowBestSellers").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }
            
            //CHECK LEFT ARROW
            if (($("#bestSellersContainer").css('left')) == '0px') {
                $("#slideLeftArrowBestSellers").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });
        
        $("#bestSellersSlideLeft").click(function() {
            if (($("#bestSellersContainer").css('left')) != '0px')
                $("#bestSellersContainer").animate({ 'left': "+=868px" });

            //CHECK RIGHT ARROW
            if (-$("#bestSellersContainer").outerWidth() >= ($("#bestSellersContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowBestSellers").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }

            //CHECK LEFT ARROW
            if (($("#bestSellersContainer").css('left')) == '-868px' || ($("#bestSellersContainer").css('left')) == '0px') {
                $("#slideLeftArrowBestSellers").attr("src", "/theme/main/images/slideLeftArrowOFF.jpg");
            } else {
                $("#slideLeftArrowBestSellers").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });

        $("#bestDealsSlideRight").click(function() {
            if (-$("#bestDealsContainer").outerWidth() < ($("#bestDealsContainer").css('left').replace('px', '') - 868))
                $("#bestDealsContainer").animate({ 'left': "-=868px" });

            //CHECK RIGHT ARROW
            if (-$("#bestDealsContainer").outerWidth() >= ($("#bestDealsContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowBestDeals").attr("src", "/theme/main/images/slideRightArrowOFF.jpg");
            } else {
                $("#slideRightArrowBestDeals").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }

            //CHECK LEFT ARROW
            if (($("#bestDealsContainer").css('left')) == '0px') {
                $("#slideLeftArrowBestDeals").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });

        $("#bestDealsSlideLeft").click(function() {
            if (($("#bestDealsContainer").css('left')) != '0px')
                $("#bestDealsContainer").animate({ 'left': "+=868px" });

            //CHECK RIGHT ARROW
            if (-$("#bestDealsContainer").outerWidth() >= ($("#bestDealsContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowBestDeals").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }

            //CHECK LEFT ARROW
            if (($("#bestDealsContainer").css('left')) == '-868px' || ($("#bestDealsContainer").css('left')) == '0px') {
                $("#slideLeftArrowBestDeals").attr("src", "/theme/main/images/slideLeftArrowOFF.jpg");
            } else {
                $("#slideLeftArrowBestDeals").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });

        $("#justArrivedSlideRight").click(function() {
            if (-$("#justArrivedContainer").outerWidth() < ($("#justArrivedContainer").css('left').replace('px', '') - 868 - 1))
                $("#justArrivedContainer").animate({ 'left': "-=868px" });

            //CHECK RIGHT ARROW
            if (-$("#justArrivedContainer").outerWidth() >= ($("#justArrivedContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowJustArrived").attr("src", "/theme/main/images/slideRightArrowOFF.jpg");
            } else {
                $("#slideRightArrowJustArrived").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }

            //CHECK LEFT ARROW
            if (($("#justArrivedContainer").css('left')) == '0px') {
                $("#slideLeftArrowJustArrived").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });

        $("#justArrivedSlideLeft").click(function() {
            if (($("#justArrivedContainer").css('left')) != '0px')
                $("#justArrivedContainer").animate({ 'left': "+=868px" });

            //CHECK RIGHT ARROW
            if (-$("#justArrivedContainer").outerWidth() >= ($("#justArrivedContainer").css('left').replace('px', '') - 868 - 868 - 1)) {
                $("#slideRightArrowJustArrived").attr("src", "/theme/main/images/slideRightArrow.jpg");
            }

            //CHECK LEFT ARROW
            if (($("#justArrivedContainer").css('left')) == '-868px' || ($("#justArrivedContainer").css('left')) == '0px') {
                $("#slideLeftArrowJustArrived").attr("src", "/theme/main/images/slideLeftArrowOFF.jpg");
            } else {
                $("#slideLeftArrowJustArrived").attr("src", "/theme/main/images/slideLeftArrow.jpg");
            }
        });

        $(function() {
            $('.rolloverArrowLeft').hover(function() {
                var currentImg = $(this).attr('src');
                if (currentImg != "/theme/main/images/slideLeftArrowOFF.jpg") {
                    $(this).attr('src', '/theme/main/images/slideLeftArrowOVER.jpg');
                }
            }, function() {
                var currentImg = $(this).attr('src');
                if (currentImg != "/theme/main/images/slideLeftArrowOFF.jpg") {
                    $(this).attr('src', '/theme/main/images/slideLeftArrow.jpg');
                }
            });
        });

        $(function() {
            $('.rolloverArrowRight').hover(function() {
                var currentImg = $(this).attr('src');
                if (currentImg != "/theme/main/images/slideRightArrowOFF.jpg") {
                    $(this).attr('src', '/theme/main/images/slideRightArrowOVER.jpg');
                }
            }, function() {
                var currentImg = $(this).attr('src');
                if (currentImg != "/theme/main/images/slideRightArrowOFF.jpg") {
                    $(this).attr('src', '/theme/main/images/slideRightArrow.jpg');
                }
            });
        });
    }
)

