﻿// Custom Drop Down
$(document).ready(function()
{
    $("ul.custom-dropdown li p").click(function()
    {
        $(this).parent().find("ul.custom-dropdown-items").slideDown('fast');

        $(this).parent().hover(function()
        {
        }, function()
        {
            $(this).parent().find("ul.custom-dropdown-items").slideUp('fast');
        });
    });
});

//Spotlight Audio Array
var SpotlightControls = new Array();

function StopAllSpotlightControls()
{
    for (i = 0; i < SpotlightControls.length; i++)
    {
        var control = SpotlightControls[i];
        
        control.find('.PlayPause img').attr("src", "/include/images/btn_play.png");
        control.find('.PlayPause p').text("play audio clip");
        control.find('.PlayPause p').css("color", "#b6724b");
        if (control.find('.PlayPause').attr('status') == 'play') 
        {
            control.find('.PlayPause').attr('status', 'pause');
            control.find('.cycle').cycle('pause');
            control.find('.spotlightPlayer').jPlayer("pause");
        }
    }
}


// Team Members Pager
var curThumbPage = 1;
var numThumbs = 1;
var numThumbPgs = 1;

var nextPrevOnColor = "#b6724b";
var nextPrevOffColor = "#808285";

var curPrevColor = nextPrevOffColor;
var curNextColor = nextPrevOffColor;

function pageThumbsPrev() {
    if (curThumbPage >= 2) {

        var pxChange = document.getElementById('thumbsWrapper').offsetTop + 320;

        $('#thumbsWrapper').fadeOut('fast', function() {
            document.getElementById('thumbsWrapper').style.top = pxChange + "px";
            $('#thumbsWrapper').fadeIn('fast', function() {
                // Animation complete.
            });
        });

        curThumbPage -= 1;
        pageThumbsSetImgs();
    }
}

function pageThumbsNext() {
    if (curThumbPage < numThumbPgs) {

        var pxChange = document.getElementById('thumbsWrapper').offsetTop - 320;

        $('#thumbsWrapper').fadeOut('fast', function() {
            document.getElementById('thumbsWrapper').style.top = pxChange + "px";
            $('#thumbsWrapper').fadeIn('fast', function() {
                // Animation complete.
            });
        });

        curThumbPage += 1;
        pageThumbsSetImgs();
    }
}

function pageThumbsSetImgs() {
    if (curThumbPage > 1) {
        document.getElementById('imgThumbsPrev').src = "include/images/product_Thumbs_Prev_On.png";
        curPrevColor = nextPrevOnColor;
        $('#thumbsPrevLINK').css('color', nextPrevOnColor);
        $('#thumbsPrevLINK').addClass('underline-fix');
    } else {
        document.getElementById('imgThumbsPrev').src = "include/images/product_Thumbs_Prev_Off.png";
        curPrevColor = nextPrevOffColor;
        $('#thumbsPrevLINK').css('color', nextPrevOffColor);
        $('#thumbsPrevLINK').removeClass('underline-fix');
    }

    if (curThumbPage < numThumbPgs) {
        document.getElementById('imgThumbsNext').src = "include/images/product_Thumbs_Next_On.png";
        curNextColor = nextPrevOnColor;
        $('#thumbsNextLINK').css('color', nextPrevOnColor);
        $('#thumbsNextLINK').addClass('underline-fix');
    } else {
        document.getElementById('imgThumbsNext').src = "include/images/product_Thumbs_Next_Off.png";
        curNextColor = nextPrevOffColor;
        $('#thumbsNextLINK').css('color', nextPrevOffColor);
        $('#thumbsNextLINK').removeClass('underline-fix');
    }
}


// Custom Drop Down class

function PLDropDown(mainObject, valueObj, defaultText)
{
    var MainObject = mainObject;
    var ValueObj = valueObj;
    var DefaultText = defaultText;

    //set initial text
    var thisVal = $("#" + MainObject.attr("id") + " li[DBVAL='" + ValueObj.val() + "'] a").text();
    MainObject.attr("value", ValueObj.val());
    if (thisVal == "")
        thisVal = DefaultText;

    

    $("#" + MainObject.attr("id") + " li p span").html(thisVal);

    $("#" + MainObject.attr("id") + " li p").unbind('click');
    $("#" + MainObject.attr("id") + " li p").click(function()
    {
        $(this).parent().find("ul.custom-dropdown-items").show();

        $(this).parent().unbind('hover');
        $(this).parent().hover(function()
        {
        }, function()
        {
            $(this).parent().find("ul.custom-dropdown-items").hide();
        });
    });

    $("#" + MainObject.attr("id") + " ul.custom-dropdown-items li").click(function()
    {
        //set value
        ValueObj.val($(this).attr("DBVAL"));
        MainObject.attr("value", $(this).attr("DBVAL"));
        //set text
        var ddlText = $(this).find("a").text() != '' ? $(this).find("a").text() : DefaultText;
        $("#" + MainObject.attr("id") + " li p span").html(ddlText);

        //closeup the list
        $("#" + MainObject.attr("id") + " ul.custom-dropdown-items").hide(); //.slideUp('fase');
    });
}


