$(document).ready(function() {
    Cufon.replace('ul.navigation li a');
    $(".resetBox").focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("")
        }
    }).blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this).attr("title"))
        }

    })

    var $unique = $("ul.chkcontrol li").find("input[type=checkbox]");
    $unique.click(function() {
        if ($(this).attr("checked")) {
            $(this).parents("ul.chkcontrol").find("input[type=checkbox]").removeAttr('checked');
            $(this).parents("ul.chkcontrol li").find("input[type=checkbox]").attr('checked', true);
        }
        return
    });



    $('.sliderPromo a').click(function(e) { e.preventDefault(); })

    $('.sliderPromo').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        next: '.next',
        prev: '.prev',
        after: function() { $("a.otherModels").attr("href", this.href) }
    });

    $('.sliderWatches').cycle({
        fx: 'fade',
        timeout: 0,
        next: '.next',
        prev: '.prev'
    });

    $('.sliderDetails').cycle({
        fx: 'fade',
        timeout: 0,
        next: '.next',
        prev: '.prev'
    });

    $("ul.listFilter").find("li:first").css("font-size", "0px")

    $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();

    //$(".colorOptions div.coptions").hide();
    //$(".colorOptions div.coptions:first").show();
    $("ul.tabNav li:first").append("<div class='sprite' id='arrowUp'></div>");
    $("ul.tabNav li a").click(function() {
        $("#arrowUp").remove();
        //$('.colorOptions div.coptions').hide();
        $(this).parent().append("<div class='sprite' id='arrowUp'></div>");
        var activeTab = $(this).attr("rev");
        $(activeTab).fadeIn();
        return false;
    });

    //Product details window function
    $("a[href=#]").click(function(e) { e.preventDefault(); })

    $("div.productdetailsWindow").hide();
    $("table.table01 tr:nth-child(odd)").addClass("odd");
    $("a.productDetails").click(function() {
        var buttonPos = $(this).position();
        $("div.productdetailsWindow").css({ "top": buttonPos.top + 80, "left": buttonPos.left + 460 });
        $("div.productdetailsWindow").fadeIn("slow");
        $(window).bind("resize", function() {
            var buttonPos = $("a.productDetails").position();
            $("div.productdetailsWindow").css({ "top": buttonPos.top + 80, "left": buttonPos.left + 460 });
        });
    });

    $("a.closeDetails").click(function() {
        $("div.productdetailsWindow").fadeOut("slow"); $(window).unbind("resize");
    })
    
    var chxbxcontrol = $("ul.chkcontrol").find("input[type=checkbox]")
    $("b.collapse").next().hide();
    chxbxcontrol.each(function() {
        if ($(this).attr("checked") == true) {
            $(this).parents("ul.chkcontrol").show()
            $(this).parents("ul.chkcontrol").prev().find("span").text("-")
        }
    }
        )


    $("b.collapse").click(function() {
        $(this).next().slideToggle("fast");
        if ($(this).find("span").text() == "-") {
            $(this).find("span").text("+")
        } else { $(this).find("span").text("-") };
    });
});

