﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

var OK = {};

OK.DropDown = {
    init: function() {
        //styleSelect script for dropdown menu (select) replacement:
        //standard select
        jQuery(".drop-down").styleSelect({ styleClass: "fancy-select", optionsWidth: 1, speed: 'fast' });
        jQuery(".fancy-select, .fancy-select ul li").attr('title', ''); //hides tooltip id names

        //wide big select
        jQuery(".drop-down-wide").styleSelect({ styleClass: "fancy-select-wide", optionsWidth: 1, optionsTop: '34px', speed: 'fast' });
        jQuery(".fancy-select-wide, .fancy-select-wide ul li").attr('title', ''); //hides tooltip id names
    }
};

// Top login animation
OK.Login = {
    init: function() {
        this.setBehavior();
    },
    setBehavior: function() {
        jQuery(".signin").click(function(e) {
            e.preventDefault();
            if ($(".login-panel").hasClass("login-active")) {
                $(".login-panel").animate({ height: '1px' }, 1000, "easeOutExpo", function() { $(".login-panel").removeClass("login-active"); });
            }
            else {
                $(".login-panel").css({ 'height': '1px' }).addClass("login-active").animate({ height: '190px' }, 700, "easeInOutExpo", function() { $("#LoginForm input[id$='UserName']").focus(); });
            }
            return false;
        });
    }
};

OK.AnnualReport = {
    docListHeight: null,
    init: function() {
        // Download list animation
        if ($("#partial-docs")) {
            this.setListBehavior();
        }

        // Start video menu
        if ($("#video-menu")) {
            jQuery('#video-menu div a img').css('opacity', 0.6);
            this.setMenuBehavior();
        }
    },
    setListBehavior: function() {
        docListHeight = jQuery('#partial-docs').height();
        jQuery('#partial-docs').animate({ 'height': 0 }, 300, "easeInOutExpo").addClass('closed');
        jQuery('a.toggle-download').click(function(e) {
            e.preventDefault();
            if (jQuery('#partial-docs').hasClass('closed'))
                jQuery('#partial-docs').removeClass('closed').animate({ 'height': docListHeight + 'px' }, 500, "easeOutExpo");
            else
                jQuery('#partial-docs').animate({ 'height': 0 }, 300, "easeInOutExpo").addClass('closed');
            return false;
        });
    },
    setMenuBehavior: function() {
        jQuery('#video-menu div').hover(function() {
            jQuery(this).find('a img').animate({ 'opacity': 1 }, 300);
        }, function() {
            jQuery(this).find('a img').animate({ 'opacity': 0.6 }, 300);
        });
    }
};

function CopyStartDateToEndDate(sourceInputElement, targetInputElement) {
    targetInputElement.value = sourceInputElement.value;
}

jQuery(document).ready(function() {
    OK.DropDown.init();
    OK.Login.init();
    OK.AnnualReport.init();

    // Pretty Checkboxes
    $(document).ready(function() {
        $('.options input[type=radio]').prettyCheckboxes({ checkboxWidth: 21, checkboxHeight: 20, classname: 'prettyRadiobutton' });
        $('.options input[type=checkbox]').prettyCheckboxes({ checkboxWidth: 21, checkboxHeight: 20, classname: 'prettyCheckbox' });
    });

    // File upload
    jQuery('input.file').change(function(e) {
        var textbox = jQuery(this).next().find('input');
        //jQuery(textbox).empty();
        jQuery(textbox).val(this.value);
    });

});
