﻿// JScript File

//Provide popup window capability
function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=400,left = 600,top = 400');");
    }

//Tabbed container Helpers
function PanelClick(sender, e) {
    var Messages = $get('<%=Messages.ClientID%>');
    Highlight(Messages);
}

function ActiveTabChanged(sender, e) {
    var CurrentTab = $get('<%=CurrentTab.ClientID%>');
    CurrentTab.innerHTML = sender.get_activeTab().get_headerText();
    Highlight(CurrentTab);
}

var HighlightAnimations = {};
function Highlight(el) {
    if (HighlightAnimations[el.uniqueID] == null) {
        HighlightAnimations[el.uniqueID] = AjaxControlToolkit.Animation.createAnimation({
            AnimationName : "color",
            duration : 0.5,
            property : "style",
            propertyKey : "backgroundColor",
            startValue : "#FFFF90",
            endValue : "#FFFFFF"
        }, el);
    }
    HighlightAnimations[el.uniqueID].stop();
    HighlightAnimations[el.uniqueID].play();
}

function ToggleHidden(value) {
    $find('<%=Tabs.ClientID%>').get_tabs()[2].set_enabled(value);
}
$(function() {
    $('#featured-home')
        .before('<div id="nav-home">')
        .cycle({
            speed: 'fast',
            timeout: 0,
            pager: '#nav-home'
        });
    $('.cycle')
    .before('<div class="nav">')
    .cycle({
        fx: 'scrollDown',
        speed: 'slow',
        timeout: 3000,
        pager: '.nav'
    });
    $('#cycle-announcements')
    .cycle({
        fx: 'scrollRight',
        speed: 'slow',
        timeout: 7000,
        random: 1,
        pause: true
    });
    $('#cycle-announcements-xl').after('<div id="cycle-nav-expanded">')
    .cycle({
        fx: 'scrollRight',
        speed: 'slow',
        timeout: 8000,
        pause: true,
        pager: '#cycle-nav-expanded',
        cleartype:  !$.support.opacity,
        cleartypeNoBg:   true
    });
});

jQuery(document).ready(function ($) {

    // Enable slide down functionality on page load
    $(".slideDown").hide().slideDown(1000);

    // Enable tooltips
    //$('a[title]').colorTip({ color: 'yellow' });

    //$('input[type=text]').simpleWaterMark('watermark');
    $('.watermark').each(function () {
        $(this).watermark($(this).attr('title'));
    });
    
    // Loads "lazy load" content boxes"
    $(".ajax-load").each(function (i) {
        var Obj = $(this);
        var oldHtml = Obj.html();
        Obj.html('<img src="/images/ani_loadingSmall.gif" alt="Loading content"/><font style="font-size:10px; color:#333; font-style:italic;"> Loading...</font>');
        $.ajax(
        {
            url: this.getAttribute('title'),
            cache: false,
            success: function (html) {
                Obj.slideUp();
                Obj.html(html);
                Obj.slideDown(500);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                //Obj.html(xhr.status);
                Obj.html(oldHtml);
            }
        });
    })

    //Colorbox

    $(".feedback-form").colorbox({ iframe: true, innerWidth: 650, innerHeight: 550 });
    $(".external-link").colorbox();
    $(".video-box").colorbox({ iframe: true, innerWidth: 600, innerHeight: 480 });
    $(".contact-box").colorbox({ iframe: true, innerWidth: 600, innerHeight: 500 });
    $(".subscription-box").colorbox({ iframe: true, innerWidth: 760, innerHeight: 500 });
    $(".ajax-box").colorbox({ iframe: false, innerWidth: 760, innerHeight: 500 });
});




