﻿//Initialization of pretyPhoto
$(document).ready(function() { $("a[rel^='prettyPhoto']").prettyPhoto(); });

//NewsLoop
/*
$('#news_block div:first').show();
$(document).ready(function() {$('#news_block').cycle({ fx: 'fade' });});
*/

//$("#news_block").cycle({ fx: 'scrollDown', sync: 0, delay: -2000, pause: true });

//Search field click
$(document).ready(function clickclear(thisfield, defaulttext) { if (thisfield.value == defaulttext) thisfield.value = ""; });
$(document).ready(function clickrecall(thisfield, defaulttext) { if (thisfield.value == "") thisfield.value = defaulttext; });
$(".sub_menu li:last-child").addClass("sub_menu_item_last");
//$("#sub_menu li:last-child").addClass("sub_menu_item_last");
var siteUrl = '<%=GS.siteUrl %>';
$(document).ready(function() {
    $('.pline').click(function() {
        if ($('.cat_content', this).is(':hidden')) {
            $('.cat_content', this).show('slow');
        }
        else {
            $('.cat_content', this).hide('slow');
        }
    });

    $('.pline').hover(function() { $(this).css("background-color", "#eeeeee") }, function() { $(this).css("background-color", "#ffffff") });
});

function switchOpenCloseDiv(lblQuestionID,lblAnswerID) {
    var lblAnswer = document.getElementById(lblAnswerID);
    var lblQuestion = document.getElementById(lblQuestionID);
    if (lblAnswer.style.display == 'none') {
        lblAnswer.style.display = 'block';
        //lblQuestion.style.textDecoration = 'underline';
        lblQuestion.style.fontWeight = 'bold';
    }
    else {
        lblAnswer.style.display = 'none';
        //lblQuestion.style.textDecoration = 'none';
        lblQuestion.style.fontWeight = 'normal';
    }
}

function refreshTopLetterBar(obj) {
    var allIndexTD = document.getElementsByName('letterA');
    for (f = 0; f < allIndexTD.length; f++) {
        allIndexTD.item(f).parentNode.className = 'letterTd';
    }

    obj.parentNode.className = 'letterTd_selected'
}

function showVideoContent(strContent) {
    var divVideoContentHolder = document.getElementById('div_videoContentHolder')
    divVideoContentHolder.style.display = 'block';
    divVideoContentHolder.innerHTML = unescape(strContent);
}

function HideVideoContent(strContent) {
    var divVideoContentHolder = document.getElementById('div_videoContentHolder')
    divVideoContentHolder.style.display = 'none';
}

function RedirectToUrl(UrlToGo) { $(location).attr('href', UrlToGo); }

function setVideoHomePageScroller() {
    $(function() {
        // setup scrolling for the playlist elements
        $("div.playlist").scrollable({items: 'div.VideoGalleryItems', vertical: true, next: 'a.down', prev: 'a.up' });
    });
}
$(document).ready(function() {
    $(".VideoGalleryItem").click(function() {
        var link = $(this).attr("rel");
        var wmpLink = $(this).attr("rev");

        $(".videoIframeFrame").attr("src", link);
        //$(".BigVideo").html(GetVideoObject(link));
        //$("#PlayList_VideoMediaPlayerURLParam").attr("value", link);
        //$("#PlayList_VideoMediaPlayerEmbed").attr("src", link);
        if (wmpLink == '') {
            $(".wmpVideo").attr("href", "#");
            $(".wmpVideo").removeClass("showWMPvideo").addClass("hideWMPvideo");
        }
        else {
            $(".wmpVideo").attr("href", wmpLink);
            $(".wmpVideo").removeClass("hideWMPvideo").addClass("showWMPvideo");
        }


        $(".VideoGalleryItem_on").removeClass("VideoGalleryItem_on").addClass("VideoGalleryItem");
        $(this).removeClass("VideoGalleryItem").addClass("VideoGalleryItem_on");

        $(".videoGalleryCurrentName").text($(".videoGalleryTitle", this).text());

    })

    $(".VideoGalleryItem_on").click(function() {
        var link = $(this).attr("rel");
        var wmpLink = $(this).attr("rev");

        $(".videoIframeFrame").attr("src", link);
        //$(".BigVideo").html(GetVideoObject(link));
        //$("#PlayList_VideoMediaPlayerURLParam").attr("value", link);
        //$("#PlayList_VideoMediaPlayerEmbed").attr("src", link);

        if (wmpLink == '') {
            $(".wmpVideo").attr("href", "#");
            $(".wmpVideo").removeClass("showWMPvideo").addClass("hideWMPvideo");
        }
        else {
            $(".wmpVideo").attr("href", wmpLink);
            $(".wmpVideo").removeClass("hideWMPvideo").addClass("showWMPvideo");
        }

        $(".VideoGalleryItem_on").removeClass("VideoGalleryItem_on").addClass("VideoGalleryItem");
        $(this).removeClass("VideoGalleryItem").addClass("VideoGalleryItem_on");

        $(".videoGalleryCurrentName").text($(".videoGalleryTitle", this).text());
    })

});

function GetVideoObject(VideoURL) 
{
    /*var str = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="PlayList_VideoMediaPlayer" width="336" height="300" border="0" type="application/x-ms-wmp">' +
                                      '<param id="PlayList_VideoMediaPlayerURLParam" name="URL" value="' + VideoURL + '">' +
                                      '<param name="autosize" value="0">' +
                                      '<param name="autostart" value="1">' +
                                      '<param name="stretchtofit" value="1">' +
                                      '<param name="showcontrols" value="1">' +
                                      '<param name="showstatusBar" value="1">' +
                                      '<param name="showdisplay" value="0">' +
                                      '<param name="autorewind" value="1">' +
                                      '<param name="allowchangedisplaysize" value="0">' +
                                      '<embed id="PlayList_VideoMediaPlayerEmbed" type="application/x-ms-wmp" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" width="336" height="300" src="' + VideoURL + '" filename="' + VideoURL + '" autosize="0" autostart="1" stretchtofit="1" showcontrols="1" showstatusbar="0" showdisplay="1" autorewind="1" allowchangedisplaysize="0"></embed>' +
                                      '</object>';*/
    var str = '<embed id="PlayList_VideoMediaPlayerEmbed" type="application/x-ms-wmp" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" width="336" height="300" src="' + VideoURL + '" filename="' + VideoURL + '" autosize="0" autostart="1" stretchtofit="0" showcontrols="1" showstatusbar="1" showdisplay="0" autorewind="1" allowchangedisplaysize="0"></embed>'
    return str;
}
