﻿
//RMP Premier Presentation
var ppSelected = 0;
var timer;
function premierPresentation(index) {
    if (index < $('.presentation li').length) {
        $('.presentation h2').css("display", "none");
        $('.presentation li img').attr("src", "/images/inoff.gif");
        $('.presentation h2:eq(' + index + ')').css("display", "block");
        $('.presentation li img:eq(' + index + ')').attr("src", "/images/inon.gif");

        ppSelected = index;

        clearTimeout(timer);
        timer = setTimeout('premierPresentation("' + (parseInt(ppSelected) + 1) + '")', 15000);

    }
    else {
        premierPresentation(0);
    }
}
//end RMP Premier Presentation

    $(document).ready(function() {

        //RMP Premier Presentation
        if ($('.presentation li').length > 0) {
            premierPresentation(0);
        }
        $('.presentation li').each(function(i) {
            $(this).click(function() {
                premierPresentation(i);
            });
        });
        //end RMP Premier Presentation

        //home search dropdown

        $('.drophandle').bind('Open', function() {
            $('.drop', $(this)).css('display', 'block');
        }).bind('Select', function(event, itemText, itemValue) {
            $('span', $(this)).html(itemText);
            $('input:first', $(this)).val(itemValue);
        }).bind('Close', function() {
            $('.drop', $(this)).css('display', 'none');
        }).click(function(event) {
            if ($('.drop', $(this)).css('display') == "none") {
                $(this).trigger('Open');
            }
            else {
                $(this).trigger('Close');
            }

        }).trigger('Close');

        $('.drophandle').each(function(i) {
            var drophandle = $(this);
            $('li', $(this)).click(function() {
                $(drophandle).trigger('Select', [$('div', $(this)).html(), $('input', $(this)).val()])
            })
        });

        $("body").click
            (
                function(e) {
                    if ($(e.target).parent().attr("class") != "drophandle") {
                        //close drop downs if clicked outside            
                        $('.drophandle').trigger("Close")
                    }
                }
            );
    //end home search dropdown

    });

    function rebindDropHandle() {
        $('.drophandle').each(function(i) {
            var drophandle = $(this);
            $('li', $(this)).click(function() {
                $(drophandle).trigger('Select', [$('div', $(this)).html(), $('input', $(this)).val()])
            })
        });
    }
