﻿/* define a new shortcut for jQuery to prevent conflict with Prototype */
$j = jQuery.noConflict();
        
/*     Feature slideshow      */
$j(document).ready(function() {

    if ($j('.slideshow .content').length > 0) {

        $j('.slideshow .content').cycle({
            fx: 'fade',
            speed: 'slow',
            timeout: 8000,
            pause: 1,
            pager: '.slideshow .controls ul',
            //cleartype: !$j.support.opacity,
            pagerAnchorBuilder: function(id) {
                return '<li><a href="#"><span></span></a></li>';
            }
        });

        $j('.slideshow .controls a').click(function() {
            $j(this).blur();
        });

        $j('.slideshow .controls .playback').click(function() {
            if ($j(this).hasClass('pause')) {
                $j('.slideshow .content').cycle('resume');
                $j(this).removeClass('pause');
                $j(this).addClass('play');
            }
            else {
                $j('.slideshow .content').cycle('pause');
                $j(this).removeClass('play');
                $j(this).addClass('pause');
            }
            return false;
        });
    }

    $j('a.selected').parentsUntil('.subnav-links').filter('.toggleText')
      .css('display', 'block');
      
    $j('a.selected').parentsUntil('.subnav-links').filter('.toggleText').parent().children('a')
      .css({'color': '#ffffff', 'background' : "url('/~/media/Images/CSF/Styles/subnav-arrow.ashx') no-repeat top right"});
      
});

function changeVideo(video_url) {
    $j.get(video_url, function(data) {
    $j("#video-gallery-left").html(data);
    });
}

function toggle(navMenuItemID) {
    var divText = navMenuItemID + "_toggleText";
    var ele = document.getElementById(navMenuItemID + "_toggleText");
    var bg = document.getElementById(navMenuItemID + "_dropArrow");
    var text = document.getElementById(navMenuItemID + "_dropArrow");
    if (ele.style.display == "block") {
        ele.style.display = "none";
        bg.style.background = "url('/~/media/Images/CSF/Styles/subnav-arrow.ashx') no-repeat top right";
        text.style.color = "#ffffff";
    }
    else {
        ele.style.display = "block";
        bg.style.background = "url('/~/media/Images/CSF/Styles/subnav-arrow-down.ashx') no-repeat top right";
        text.style.color = "#ffffff";
    }
}
