﻿/**Refresh Listen Live**/

$(document).ready(function () {
    var iFrequency = 30000; // expressed in miliseconds
    var myInterval = 0;


    if (myInterval > 0) clearInterval(myInterval);  // stop
    myInterval = setInterval("refreshListenLive()", iFrequency);  // run
    //setTimeout("refreshListenLive()", 30000);

});


function refreshListenLive() {
    var routeURL = document.getElementById("routeURL").value;
    $.ajax({
        url: routeURL + 'Shared/refreshListenLive',
        type: 'POST',
        data: '',

        success: function (data) {
            var songName = $("#trackName").text();
            var newSongName = "";
            $('#headerId').html(data);
            newSongName = $("#trackName").text();

            if (newSongName != songName) {
                $('#trackName').fadeOut('slow');
                $('#nextTrack').fadeOut('slow');
                $('#trackName').fadeIn('slow');
                $('#nextTrack').fadeIn('slow');
            } else {
               

            }
        }
    });
}

/****************************************/

/*Event Menu*/


$(document).ready(function () {

    //allEventSubPageallEventSubPage
    if ($(".menu_item").length > 0) {
        // remove initial classes
        $("#newstyles").removeClass("menu_items_1");
        $("#newstyles").removeClass("menu_items_2");
        $("#newstyles").removeClass("menu_items_3");

        // change background images related to menu item number
        if ($("#newstyles").find(".menu_item").length == 1) {
            $("#newstyles").addClass("menu_items_1");
            $(".menu_item").addClass('selected');
        }
        else if ($("#newstyles").find(".menu_item").length == 2) {
            $("#newstyles").addClass("menu_items_2");
        }
        else if ($("#newstyles").find(".menu_item").length == 3) {

            $("#newstyles").addClass("menu_items_3");
        }

    }
});
/**/

/*home page top 20*/

$(document).ready(function () {
    var currentPosition = 0;
    var currentslidenumber = 0;
    var slideWidth = 311;
    var slides = $('#featured_posters .cellule');
    var numberOfSlides = slides.length;


    // Wrap all .slides with #slideInner div
    slides
  .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
  .css({
      'float': 'left',
      'width': slideWidth
  });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner').css('width', slideWidth * numberOfSlides);

    // Insert left and right arrow controls in the DOM
    $('#featured_posters')
    //    .prepend('<span class="control" id="leftControl">Move left</span>')
    //    .append('<span class="control" id="rightControl">Move right</span>');

    // Hide left arrow control on first load
    manageControls(currentPosition);

    // Create event listeners for .controls clicks
    $('.control')
    .bind('click', function () {

        // Determine new position
        currentPosition = ($(this).attr('id') == 'rightControl')
    ? currentPosition + 3 : currentPosition - 3;

        currentslidenumber = ($(this).attr('id') == 'rightControl')
    ? currentslidenumber + 1 : currentslidenumber - 1;

        // Hide / show controls
        manageControls(currentPosition);
        // Move slideInner using margin-left
        $('#slideInner').animate({
            'marginLeft': slideWidth * (-currentPosition)
        });
    });

    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position) {
        // Hide left arrow if position is first slide
        if (position == 0) { $('.top20 .totheLeft').hide() }
        else { $('.top20 .totheLeft').show() }
        // Hide right arrow if position is last slide
        if (position == numberOfSlides - 2) { $('.top20 .totheRight').hide() }
        else { $('.top20 .totheRight').show() }
        $('.nu').removeClass('selected');
        $('.nu').eq(currentPosition / 3).addClass('selected');

    }

    /* $('.slides_container .slide').live('swipeleft swiperight', function (event) {




    if (event.type == "swipeleft" && currentPosition != numberOfSlides - 1) {
    //    alert("in ")


    currentPosition = currentPosition + 3;
    manageControls(currentPosition);
    $('#slideInner').animate({
    'marginLeft': slideWidth * (-currentPosition)
    });

    }
    if (event.type == "swiperight" && currentPosition != 0) {
    currentPosition = currentPosition - 3;
    manageControls(currentPosition);
    $('#slideInner').animate({
    'marginLeft': slideWidth * (-currentPosition)
    });
    }
    event.preventDefault();
    });*/



    $('.nu').click(function () {
        var index = $(this).index() * 3;
        $('.nu').removeClass('selected');
        //$(this).addClass('selected');

        currentPosition = index;
        manageControls(currentPosition);
        $('#slideInner').animate({
            'marginLeft': slideWidth * (-currentPosition)
        });
    });


});






/**/
/*$(document).ready(function () {

$('.showingBarTop #suiteNumber0').addClass('selected');
$('.showingBarButtom #suiteNumber0').addClass('selected');
$('.previousBlue').addClass('disabled');
var NumPages = document.getElementById("NbPageMusics").value;

if (NumPages == 0) {
$('.previousBlue').addClass('disabled');
$('.nextBlue').addClass('disabled');
}
});*/



/**/



/*Pressssss*/

$(document).ready(function () {

    var currentPosition2 = 0;
    var currentslidenumber2 = 0;
    var slideWidth2 = 359;
    var slides2 = $('#featured_press .pressArticle');
    var numberOfSlides2 = slides2.length;


    // Wrap all .slides with #slideInner div
    slides2
  .wrapAll('<div id="slideInner2"></div>')
    // Float left to display horizontally, readjust .slides width
  .css({
      'float': 'left',
      'width': slideWidth2
  });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner2').css('width', slideWidth2 * numberOfSlides2);

    // Insert left and right arrow controls in the DOM
    $('#featured_press')
    //    .prepend('<span class="control" id="leftControl">Move left</span>')
    //    .append('<span class="control" id="rightControl">Move right</span>');

    // Hide left arrow control on first load
    manageControls(currentPosition2);

    // Create event listeners for .controls clicks
    $('.control')
    .bind('click', function () {

        // Determine new position
        currentPosition2 = ($(this).attr('id') == 'rightO')
    ? currentPosition2 + 2 : currentPosition2 - 2;



        // Hide / show controls
        manageControls(currentPosition2);
        // Move slideInner using margin-left
        $('#slideInner2').animate({
            'marginLeft': slideWidth2 * (-currentPosition2) + (-currentPosition2) * 50
        });
    });

    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position) {

        // Hide left arrow if position is first slide
        if (position == 0) { $('.PressPartContent .leftO').hide() }
        else { $('.PressPartContent .leftO').show() }
        // Hide right arrow if position is last slide
        if (position == numberOfSlides2 - 2 || numberOfSlides2 == 0) { $('.PressPartContent .rightO').hide() }
        else { $('.PressPartContent .rightO').show() }

    }






});
/**/

/**/


/*Past event photos*/

$(document).ready(function () {

    var currentPosition3 = 0;
    var currentslidenumber3 = 0;
    var slideWidth3 = 198;
    var slides3 = $('#featured_pastphotos .meduimPic');
    var numberOfSlides3 = slides3.length;


    // Wrap all .slides with #slideInner div
    slides3
  .wrapAll('<div id="slideInner3"></div>')
    // Float left to display horizontally, readjust .slides width
  .css({
      'float': 'left',
      'width': slideWidth3
  });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner3').css('width', slideWidth3 * numberOfSlides3);

    // Insert left and right arrow controls in the DOM
    $('#featured_pastphotos')
    //    .prepend('<span class="control" id="leftControl">Move left</span>')
    //    .append('<span class="control" id="rightControl">Move right</span>');

    // Hide left arrow control on first load
    manageControls(currentPosition3);

    // Create event listeners for .controls clicks
    $('.control2')
    .bind('click', function () {
        if ($(this).attr('class') != 'leftpastphotos control2 disabled' && $(this).attr('class') != 'rightpastphotos control2 disabled') {
            // Determine new position
            currentPosition3 = ($(this).attr('id') == 'rightpastphotos')
    ? currentPosition3 + 2 : currentPosition3 - 2;



            // Hide / show controls
            manageControls(currentPosition3);
            // Move slideInner using margin-left
            $('#slideInner3').animate({
                'marginLeft': slideWidth3 * (-currentPosition3)
            });
        }
    });

    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position) {

        // Hide left arrow if position is first slide
        if (position == 0) { $('.photoParthead .leftpastphotos').addClass('disabled') }
        else { $('.photoParthead .leftpastphotos').removeClass('disabled') }
        // Hide right arrow if position is last slide
        if (position == numberOfSlides3 - 2 || position == numberOfSlides3 - 1 || numberOfSlides3 == 0) { $('.photoParthead .rightpastphotos').addClass('disabled') }
        else { $('.photoParthead .rightpastphotos').removeClass('disabled') }

    }


});

/**/

/*Past event videos*/

$(document).ready(function () {

    var currentPosition4 = 0;
    var currentslidenumber4 = 0;
    var slideWidth4 = 198;
    var slides4 = $('#featured_pastvideos .meduimPic');
    var numberOfSlides4 = slides4.length;


    // Wrap all .slides with #slideInner div
    slides4
  .wrapAll('<div id="slideInner4"></div>')
    // Float left to display horizontally, readjust .slides width
  .css({
      'float': 'left',
      'width': slideWidth4
  });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner4').css('width', slideWidth4 * numberOfSlides4);

    // Insert left and right arrow controls in the DOM
    $('#featured_pastvideos')
    //    .prepend('<span class="control" id="leftControl">Move left</span>')
    //    .append('<span class="control" id="rightControl">Move right</span>');

    // Hide left arrow control on first load
    manageControls(currentPosition4);

    // Create event listeners for .controls clicks
    $('.control3')
    .bind('click', function () {
        if ($(this).attr('class') != 'leftpastvideos control3 disabled' && $(this).attr('class') != 'rightpastvideos control3 disabled') {
            // Determine new position
            currentPosition4 = ($(this).attr('id') == 'rightpastvideos')
    ? currentPosition4 + 2 : currentPosition4 - 2;



            // Hide / show controls
            manageControls(currentPosition4);
            // Move slideInner using margin-left
            $('#slideInner4').animate({
                'marginLeft': slideWidth4 * (-currentPosition4)
            });
        }
    });

    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position) {

        // Hide left arrow if position is first slide
        if (position == 0) { $('.videoParthead .leftpastvideos').addClass('disabled') }
        else { $('.videoParthead .leftpastvideos').removeClass('disabled') }
        // Hide right arrow if position is last slide
        if (position == numberOfSlides4 - 2 || position == numberOfSlides4 - 1 || numberOfSlides4 == 0) { $('.videoParthead .rightpastvideos').addClass('disabled') }
        else { $('.videoParthead .rightpastvideos').removeClass('disabled') }

    }


});

/**/


/*Latest News next btn*/
function previous() {

    if ($('.current_news').parent().find('.current_news').prev().prev().length == 0) {
        $('.previous').addClass('disabled');
    } else {
        $('.next').removeClass('disabled');
    }

    $('#latestnewscontainer .next').removeClass('inactive');



    if ($(".container").length != 1 && !$('.current_news').is(':animated') && !$('#latestnewscontainer .prev').hasClass('inactive')) {

        selected_index = $('.current_news').index() - 1;

        if (selected_index < 0) {
            selected_index = $(".container").length - 1;
        }


        var $active = $('.current_news').parent().find('.current_news');

        var $previous = $active.prev().length ? $active.prev() : $('.current_news').parent().find('.container:last');


        if ($active.prev().length) {
            $active.addClass('last-active').removeClass('current_news').css('display', 'none');


            if ($active.length == 0) $active = $('.current_news').parent().find('.container:first');



            $previous.addClass('current_news').css('display', 'block', function () {
                $active.removeClass('current_news last-active').css('display', 'none');
            });

            if ($('.container').hasClass('first current_news')) {
                $('#latestnewscontainer .prev').removeClass('active');

            }


        }
    }

}

/*Latest News previous btn*/
function next() {
    if ($('.current_news').parent().find('.current_news').next().next().length == 0) {
        $('.next').addClass('disabled');
    } else {
        $('.previous').removeClass('disabled');
    }

    $('#latestnewscontainer .prev').addClass('active');


    if ($(".container").length != 1 && !$('.current_news').is(':animated') && !$('#latestnewscontainer .next').hasClass('inactive')) {




        selected_index = $('.current_news').index() + 1;

        if (selected_index >= $(".container").length) {
            selected_index = 0;
        }


        var $active = $('.current_news').parent().find('.current_news');

        var $next = $active.next().length ? $active.next() : $('.current_news').parent().find('.container:first');


        if ($active.next().length) {


            $active.addClass('last-active').removeClass('current_news').css('display', 'none');



            if ($active.length == 0) $active = $('.current_news').parent().find('.container:last');

            if ($active.next().length) {
                $next.addClass('current_news').css('display', 'block', function () {
                    $active.removeClass('current_news last-active').css('display', 'none');
                });

                if ($('.container').hasClass('final current_news')) {
                    $('#latestnewscontainer .next').addClass('inactive');
                }

            }

        } else {
            $('.next').addClass('disabled');
        }

    }

}


/*Podcast previous btn*/
function previouspodcast() {

    //    if ($('.current_podcast').parent().find('.current_podcast').prev().prev().length == 0) {
    //        $('#toTheLeftDoublepodcasts').addClass('disabled');
    //    } else {
    //        $('#toTheRightDoublepodcasts').removeClass('disabled');
    //    }

    $('#podcastscontainer .nextpodcast').removeClass('inactive');



    if ($(".container").length != 1 && !$('.current_podcast').is(':animated') && !$('#podcastscontainer .prev').hasClass('inactive')) {

        selected_index = $('.current_podcast').index() - 1;

        if (selected_index < 0) {
            selected_index = $(".container").length - 1;
        }


        var $active = $('.current_podcast').parent().find('.current_podcast');

        var $previous = $active.prev().length ? $active.prev() : $('.current_podcast').parent().find('.container:last');


        // if ($active.prev().length) {
        $active.addClass('last-active').removeClass('current_podcast').css('display', 'none');


        if ($active.length == 0) $active = $('.current_podcast').parent().find('.container:first');



        $previous.addClass('current_podcast').css('display', 'block', function () {
            $active.removeClass('current_podcast last-active').css('display', 'none');
        });

        //            if ($('.container').hasClass('first current_podcast')) {
        //                $('#podcastscontainer .prev').removeClass('active');

        //            }


        //}
    }

}

/*Podcast next btn*/
function nextpodcast() {
    //    if ($('.current_podcast').parent().find('.current_podcast').next().next().length == 0) {
    //        $('#toTheRightDoublepodcasts').addClass('disabled');
    //    } else {
    //        $('#toTheLeftDoublepodcasts').removeClass('disabled');
    //    }

    $('#podcastscontainer .prev').addClass('active');


    if ($(".container").length != 1 && !$('.current_podcast').is(':animated') && !$('#podcastscontainer .next').hasClass('inactive')) {




        selected_index = $('.current_podcast').index() + 1;

        if (selected_index >= $(".container").length) {
            selected_index = 0;
        }


        var $active = $('.current_podcast').parent().find('.current_podcast');

        var $next = $active.next().length ? $active.next() : $('.current_podcast').parent().find('.container:first');


        //if ($active.next().length) {


        $active.addClass('last-active').removeClass('current_podcast').css('display', 'none');



        if ($active.length == 0) $active = $('.current_podcast').parent().find('.container:last');

        //if ($active.next().length) {
        $next.addClass('current_podcast').css('display', 'block', function () {
            $active.removeClass('current_podcast last-active').css('display', 'none');
        });

        if ($('.container').hasClass('final current_podcast')) {
            $('#podcastscontainer .next').addClass('inactive');
        }

        //}

        //} else {
        //  $('.nextpodcast').addClass('disabled');
        // }

    }

}


/*Presenter next btn*/
function previouspresenter() {


    //    if ($('.current_presenter').parent().find('.current_presenter').prev().prev().length == 0) {
    //        $('#toTheLeftDoublepresenter').addClass('disabled');
    //    } else {
    //        $('#toTheRightDoublepresenter').removeClass('disabled');
    //    }

    $('#presentercontainer .nextpresenter').removeClass('inactive');



    if ($(".container").length != 1 && !$('.current_presenter').is(':animated') && !$('#presentercontainer .prev').hasClass('inactive')) {

        selected_index = $('.current_presenter').index() - 1;

        if (selected_index < 0) {
            selected_index = $(".container").length - 1;
        }


        var $active = $('.current_presenter').parent().find('.current_presenter');

        var $previous = $active.prev().length ? $active.prev() : $('.current_presenter').parent().find('.container:last');


        //if ($active.prev().length) {
        $active.addClass('last-active').removeClass('current_presenter').css('display', 'none');


        if ($active.length == 0) $active = $('.current_presenter').parent().find('.container:first');



        $previous.addClass('current_presenter').css('display', 'block', function () {
            $active.removeClass('current_presenter last-active').css('display', 'none');
        });

        //            if ($('.container').hasClass('first current_presenter')) {
        //                $('#presentercontainer .prev').removeClass('active');

        //            }


        // }
    }

}

/*Presenter previous btn*/
function nextpresenter() {
    //    if ($('.current_presenter').parent().find('.current_presenter').next().next().length == 0) {
    //        $('#toTheRightDoublepresenter').addClass('disabled');
    //    } else {
    //        $('#toTheLeftDoublepresenter').removeClass('disabled');
    //    }

    $('#presentercontainer .prev').addClass('active');


    if ($(".container").length != 1 && !$('.current_presenter').is(':animated') && !$('#presentercontainer .next').hasClass('inactive')) {




        selected_index = $('.current_presenter').index() + 1;

        if (selected_index >= $(".container").length) {
            selected_index = 0;
        }


        var $active = $('.current_presenter').parent().find('.current_presenter');

        var $next = $active.next().length ? $active.next() : $('.current_presenter').parent().find('.container:first');


        // if ($active.next().length) {


        $active.addClass('last-active').removeClass('current_presenter').css('display', 'none');



        if ($active.length == 0) $active = $('.current_presenter').parent().find('.container:last');

        // if ($active.next().length) {
        $next.addClass('current_presenter').css('display', 'block', function () {
            $active.removeClass('current_presenter last-active').css('display', 'none');
        });

        if ($('.container').hasClass('final current_presenter')) {
            $('#presentercontainer .next').addClass('inactive');
        }

        // }

        //        } else {
        //            $('.nextpresenter').addClass('disabled');
        //        }

    }

}


/*dj previous btn*/
function previousdj() {


    //    if ($('.current_dj').parent().find('.current_dj').prev().prev().length == 0) {
    //        $('#toTheLeftDoubledj').addClass('disabled');
    //    } else {
    //        $('#toTheRightDoubledj').removeClass('disabled');
    //    }

    $('#djcontainer .nextdj').removeClass('inactive');



    if ($(".container").length != 1 && !$('.current_dj').is(':animated') && !$('#djcontainer .prev').hasClass('inactive')) {

        selected_index = $('.current_dj').index() - 1;

        if (selected_index < 0) {
            selected_index = $(".container").length - 1;
        }


        var $active = $('.current_dj').parent().find('.current_dj');

        var $previous = $active.prev().length ? $active.prev() : $('.current_dj').parent().find('.container:last');


        // if ($active.prev().length) {
        $active.addClass('last-active').removeClass('current_dj').css('display', 'none');


        if ($active.length == 0) $active = $('.current_dj').parent().find('.container:first');



        $previous.addClass('current_dj').css('display', 'block', function () {
            $active.removeClass('current_dj last-active').css('display', 'none');
        });

        //            if ($('.container').hasClass('first current_dj')) {
        //                $('#djcontainer .prev').removeClass('active');

        //            }


        //  }
    }

}

/*dj next btn*/
function nextdj() {
    //    if ($('.current_dj').parent().find('.current_dj').next().next().length == 0) {
    //        $('#toTheRightDoubledj').addClass('disabled');
    //    } else {
    //        $('#toTheLeftDoubledj').removeClass('disabled');
    //    }

    $('#djcontainer .prev').addClass('active');


    if ($(".container").length != 1 && !$('.current_dj').is(':animated') && !$('#djcontainer .next').hasClass('inactive')) {




        selected_index = $('.current_dj').index() + 1;

        if (selected_index >= $(".container").length) {
            selected_index = 0;
        }


        var $active = $('.current_dj').parent().find('.current_dj');

        var $next = $active.next().length ? $active.next() : $('.current_dj').parent().find('.container:first');


        //if ($active.next().length) {


        $active.addClass('last-active').removeClass('current_dj').css('display', 'none');



        if ($active.length == 0) $active = $('.current_dj').parent().find('.container:last');

        //if ($active.next().length) {
        $next.addClass('current_dj').css('display', 'block', function () {
            $active.removeClass('current_dj last-active').css('display', 'none');
        });

        if ($('.container').hasClass('final current_dj')) {
            $('#djcontainer .next').addClass('inactive');
        }

        // }

        //        } else {
        //            $('.nextdj').addClass('disabled');
        //        }

    }

}


function showgray() {
    // alert("in");
    //$(".slideWindow .song .smallPIC img").fadeIn(500);

    // clone image
    $('.slideWindow .song .smallPIC img').each(function () {
        var el = $(this);
        el.css({ "position": "absolute" }).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass('img_grayscale').css({ "position": "absolute", "z-index": "1", "opacity": "0" }).insertBefore(el).queue(function () {
            var el = $(this);
            el.parent().css({ "width": this.width, "height": this.height });
            el.dequeue();
        });
        this.src = grayscale(this.src);
    });

    // Fade image

    $('.slideWindow .song .smallPIC').mouseover(function () {
        $(this).find('img:first').stop().animate({ opacity: 1 }, 200);
    })
    $('.slideWindow .song .smallPIC').mouseout(function () {
        $(this).find('.img_grayscale:first').stop().animate({ opacity: 0 }, 200);
    });

    // alert("end");         
}


function ShowNextMusic() {


    var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPageMusic').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPageMusics").value)) {
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) + 1;
        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);
        var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);

        $(selectedelt1).addClass('selected');
        $(selectedelt2).addClass('selected');


        $('.previousBlue').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == parseInt(document.getElementById("NbPageMusics").value - 1)) {

            $('.nextBlue').addClass('disabled');
        } else {
            $('.nextBlue').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageMusic").value = pageId + 1;
        //}


        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId + 1) + "&Search=" + encodeURI(Search);

        $.ajax({
            url: routeURL + 'Music/GetNextMusics',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#musicpaging').html(data);
                showgray();




            }
        });
    }

}


function ShowPreviousMusic() {

    var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPageMusic').val();


    if (parseInt(pageId) != 0) {

        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) - 1;
        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);
        var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);

        $(selectedelt1).addClass('selected');
        $(selectedelt2).addClass('selected');


        $('.nextBlue').removeClass('disabled');


        pageId = parseInt(pageId);
        if (parseInt(pageId) == 1) {

            $('.previousBlue').addClass('disabled');
        } else {
            $('.previousBlue').removeClass('disabled');
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageMusic").value = pageId - 1;
        //}


        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId - 1) + "&Search=" + encodeURI(Search);

        $.ajax({
            url: routeURL + 'Music/GetPreviousMusics',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#musicpaging').html(data);
                //alert("before");
                showgray();

            }
        });
    }

}

function ShowSelectedMusic(pageNum) {
    var Search = document.getElementById("currentSearch").value;

    //var pageId = $('#currentPageMusic').val();
    $('.suiteNumber').removeClass('selected');
    pageId = parseInt(pageNum);

    var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(pageId);
    var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(pageId);

    $(selectedelt1).addClass('selected');
    $(selectedelt2).addClass('selected');

    if (parseInt(pageId) == parseInt(document.getElementById("NbPageMusics").value)) {

        $('.nextBlue').addClass('disabled');
        if (parseInt(document.getElementById("NbPageMusics").value) != 0) {
            $('.previousBlue').removeClass('disabled');
        }
        // $('#btnMoreArticles').hide();
    }
    else if (parseInt(pageId) == 0) {

        $('.previousBlue').addClass('disabled');
        if (parseInt(document.getElementById("NbPageMusics").value) != 0) {
            $('.nextBlue').removeClass('disabled');
        }
        // $('#btnMoreArticles').hide();
    }
    else {
        $('.nextBlue').removeClass('disabled');
        $('.previousBlue').removeClass('disabled');
    }

    //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

    document.getElementById("currentPageMusic").value = pageId;
    //}


    var routeURL = document.getElementById("routeURL").value;
    var poststr = "pagenum=" + encodeURI(pageId) + "&Search=" + encodeURI(Search);

    $.ajax({
        url: routeURL + 'Music/GetSelectedMusics',
        type: 'POST',
        data: '' + poststr,

        success: function (data) {


            $('#musicpaging').html(data)

            showgray();




        }
    });

}

function GoToMusicResult() {
    var routeURL = document.getElementById("routeURL").value;
    var searchEvent = document.getElementById("searchEvent").value;
    if (searchEvent != "artist/song") {
        window.location = routeURL + "Music?Search=" + searchEvent;
    } else {
        window.location = routeURL + "Music?Search=" + "All";
    }
}


function ShowbeforeTop20() {

    //var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPageTop20').val();
    var weekId = $('#currentWeekId').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPageTop20s").value)) {

        $('.ViewALL').css('display', 'block');

        var newpageId = parseInt(pageId) + 1;

        $('.after').removeClass('disabled');


        pageId = parseInt(pageId);
        if (parseInt(pageId) == parseInt(document.getElementById("NbPageTop20s").value - 1)) {

            $('.b4').addClass('disabled');
        } else {
            $('.b4').removeClass('disabled');
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageTop20").value = pageId + 1;
        //}

        //  var currentright = $('#weekOf').css('right');




        if (parseInt($('#weekOf').css('right')) > 267) {


            $('#weekOf').animate({
                'right': '-=216'
            });
        } else {

            $('#weekOf').animate({
                'right': '+=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId - 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&weekId=" + encodeURI(weekId);

        $.ajax({
            url: routeURL + 'Music/GetPreviousTop20s',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {
                $('#top20paging').html(data);
                var MusicTop20Date = document.getElementById("MusicTop20Date").value;
                $('#weekOf').text(MusicTop20Date);


                showgray();



            }
        });
    }

}


function ShowafterTop20() {


    //var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPageTop20').val();
    var weekId = $('#currentWeekId').val();

    if (parseInt(pageId) != 0) {
        $('.ViewALL').css('display', 'block');
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) - 1;



        $('.b4').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == 1) {

            $('.after').addClass('disabled');
        } else {
            $('.after').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageTop20").value = pageId - 1;
        //}

        // var currentright = $('#weekOf').css('right');




        if (parseInt($('#weekOf').css('right')) < 53) {


            $('#weekOf').animate({
                'right': '+=216'
            });
        } else {
            $('#weekOf').animate({
                'right': '-=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId + 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&weekId=" + encodeURI(weekId);



        $.ajax({
            url: routeURL + 'Music/GetNextTop20s',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {

                $('#top20paging').html(data);
                var MusicTop20Date = document.getElementById("MusicTop20Date").value;
                $('#weekOf').text(MusicTop20Date);


                showgray();

            }
        });
    }

}

/*************Top100*********************/
function ShowbeforeTop100() {

    //var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPageTop100').val();
    var yearId = $('#currentYearId').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPageTop100s").value)) {

        var newpageId = parseInt(pageId) + 1;

        $('.after').removeClass('disabled');


        pageId = parseInt(pageId);
        if (parseInt(pageId) == parseInt(document.getElementById("NbPageTop100s").value - 1)) {

            $('.b4').addClass('disabled');
        } else {
            $('.b4').removeClass('disabled');
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageTop100").value = pageId + 1;
        //}

        //  var currentright = $('#weekOf').css('right');




        if (parseInt($('#yearOf').css('right')) > 267) {


            $('#yearOf').animate({
                'right': '-=216'
            });
        } else {

            $('#yearOf').animate({
                'right': '+=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId - 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&yearId=" + encodeURI(yearId);

        location.hash = "pageid=" + newpageId;
        $.ajax({
            url: routeURL + 'Music/GetPreviousTop100s',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {
                $('#top100paging').html(data);

                var MusicTop100Date = document.getElementById("MusicTop100Date").value;
                // alert(MusicTop100Date);
                $('#yearOf').text(MusicTop100Date);
                $('#yearOfMenu').text(MusicTop100Date);
                if (MusicTop100Date != "2011") {
                    $('.playMusic').css('display', 'none');
                } else {
                    $('.playMusic').css('display', 'block');
                }

                showgray();



            }
        });
    }

}


function ShowafterTop100() {


    //var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPageTop100').val();
    var yearId = $('#currentYearId').val();

    if (parseInt(pageId) != 0) {
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) - 1;



        $('.b4').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == 1) {

            $('.after').addClass('disabled');
        } else {
            $('.after').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageTop100").value = pageId - 1;
        //}

        // var currentright = $('#weekOf').css('right');




        if (parseInt($('#yearOf').css('right')) < 53) {


            $('#yearOf').animate({
                'right': '+=216'
            });
        } else {
            $('#yearOf').animate({
                'right': '-=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId + 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&yearId=" + encodeURI(yearId);

        location.hash = "pageid=" + newpageId;

        $.ajax({
            url: routeURL + 'Music/GetNextTop100s',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {

                $('#top100paging').html(data);
                var MusicTop100Date = document.getElementById("MusicTop100Date").value;

                $('#yearOf').text(MusicTop100Date);
                $('#yearOfMenu').text(MusicTop100Date);
                if (MusicTop100Date != "2011") {
                    $('.playMusic').css('display', 'none');
                } else {
                    $('.playMusic').css('display', 'block');
                }


                showgray();

            }
        });
    }

}
/***************EndTop100************************/

/*********************/
function ShowbeforePlaylist() {

    //var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPagePlaylist').val();
    var weekId = $('#currentWeekId').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPagePlaylists").value)) {

        $('.ViewALL').css('display', 'block');

        var newpageId = parseInt(pageId) + 1;

        $('.after').removeClass('disabled');


        pageId = parseInt(pageId);
        if (parseInt(pageId) == parseInt(document.getElementById("NbPagePlaylists").value - 1)) {

            $('.b4').addClass('disabled');
        } else {
            $('.b4').removeClass('disabled');
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPagePlaylist").value = pageId + 1;
        //}

        //  var currentright = $('#weekOf').css('right');




        if (parseInt($('#weekOf').css('right')) > 267) {


            $('#weekOf').animate({
                'right': '-=216'
            });
        } else {

            $('#weekOf').animate({
                'right': '+=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId - 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&weekId=" + encodeURI(weekId);

        $.ajax({
            url: routeURL + 'Music/GetPreviousPlaylists',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {
                $('#Playlistpaging').html(data);
                var MusicPlaylistDate = document.getElementById("MusicPlaylistDate").value;
                $('#weekOf').text(MusicPlaylistDate);


                showgray();



            }
        });
    }

}


function ShowafterPlaylist() {


    //var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPagePlaylist').val();
    var weekId = $('#currentWeekId').val();

    if (parseInt(pageId) != 0) {
        $('.ViewALL').css('display', 'block');
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) - 1;



        $('.b4').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == 1) {

            $('.after').addClass('disabled');
        } else {
            $('.after').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPagePlaylist").value = pageId - 1;
        //}

        // var currentright = $('#weekOf').css('right');




        if (parseInt($('#weekOf').css('right')) < 53) {


            $('#weekOf').animate({
                'right': '+=216'
            });
        } else {
            $('#weekOf').animate({
                'right': '-=36'
            });
        }


        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId + 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(newpageId) + "&weekId=" + encodeURI(weekId);



        $.ajax({
            url: routeURL + 'Music/GetNextPlaylists',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {

                $('#Playlistpaging').html(data);
                var MusicPlaylistDate = document.getElementById("MusicPlaylistDate").value;
                $('#weekOf').text(MusicPlaylistDate);


                showgray();

            }
        });
    }

}
/********************/


function GoToTop20Result() {
    var routeURL = document.getElementById("routeURL").value;
    var searchEvent = document.getElementById("searchTop20").value;
    var Page = document.getElementById("currentPageTop20").value;
    if (searchEvent != "artist/song") {
        window.location = routeURL + "Music/Top20?Search=" + searchEvent + "&Page=" + Page;
    } else {
        window.location = routeURL + "Music/Top20?Search=" + "All" + "&Page=" + Page;
    }
}



function nextevents() {
    var pageId = $('#currentPageEvent').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPageEvents").value)) {

        var newpageId = parseInt(pageId) + 1;



        $('.previousRond').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == parseInt(document.getElementById("NbPageEvents").value - 1)) {

            $('.nextRond').addClass('disabled');
        } else {
            $('.nextRond').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageEvent").value = pageId + 1;
        //}

        location.hash = "pageid=" + newpageId;
        $('#loader').css('display', 'block');
        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId + 1);

        $.ajax({
            url: routeURL + 'Events/GetNextEvents',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {
                $('#Eventlist').html(data);
                $('#loader').css('display', 'none');

            }
        });
    }

}


function previousevents() {
    var pageId = $('#currentPageEvent').val();


    if (parseInt(pageId) != 0) {

        var newpageId = parseInt(pageId) - 1;



        $('.nextRond').removeClass('disabled');
        pageId = parseInt(pageId);


        if (parseInt(pageId) == parseInt(document.getElementById("NbPageEvents").value + 1)) {

            $('.previousRond').addClass('disabled');
        } else {
            $('.previousRond').removeClass('disabled');
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageEvent").value = pageId - 1;
        //}
        $('#loader').css('display', 'block');

        var routeURL = document.getElementById("routeURL").value;
        //var poststr = "pagenum=" + encodeURI(pageId + 1) + "&Search=" + encodeURI(Search);
        var poststr = "pagenum=" + encodeURI(pageId - 1);
        location.hash = "pageid=" + newpageId;

        $.ajax({
            url: routeURL + 'Events/GetPreviousEvents',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#Eventlist').html(data);
                $('#loader').css('display', 'none');
            }
        });
    }

}





/*PhotoGallery Albums*/

function GoToNextAlbums() {


    //var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPageAlbum').val();
    var pageNum = parseInt(pageId);

    if (parseInt(pageId) != parseInt(document.getElementById("NbPageAlbums").value)) {
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) + 1;

        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);
        // var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);


        $(selectedelt1).addClass('selected');
        //$(selectedelt2).addClass('selected');


        /******Move 5******/
        var selectedNumber = selectedelt1;
        // alert(pageNum);
        if ($(selectedNumber).hasClass('RightBound')) {

            $(selectedNumber).removeClass('RightBound');
            var total = pageNum + 5;
            var newright = "#suiteNumber" + total;
            $(newright).addClass('RightBound');

            for (i = pageNum + 1; i < pageNum + 6; i++) {

                var elt = "#suiteNumber" + i;
                $(elt).css('display', 'block');
            }


            var newleft = "#suiteNumber" + parseInt(pageNum + 1);

            $(newleft).addClass('LeftBound');

            for (w = pageNum; w >= pageNum - 6; w--) {
                var elt = "#suiteNumber" + w;
                $(elt).css('display', 'none');
            }
        }
        /************/


        $('.previousBlue').removeClass('disabled');
        $('.totheRightBig').show();
        pageId = parseInt(pageId);


        if (parseInt(pageId) == parseInt(document.getElementById("NbPageAlbums").value - 1)) {

            $('.nextBlue').addClass('disabled');
            $('.totheLeftBig').hide();
        } else {
            $('.nextBlue').removeClass('disabled');
            $('.totheLeftBig').show();
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageAlbum").value = pageId + 1;
        //}

        location.hash = "pageid=" + newpageId;
        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId);



        $.ajax({
            url: routeURL + 'Gallery/GetNextAlbums',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#albumlist').html(data);

            }
        });
    }

}


function GoToPreviousAlbums() {

    // var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPageAlbum').val();
    var pageNum = parseInt(pageId);

    if (parseInt(pageId) != 0) {

        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId - 1);

        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);

        //var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);
        //alert(selectedelt1);
        $(selectedelt1).addClass('selected');
        //$(selectedelt2).addClass('selected');

        //alert(selectedelt1);
        /***Move 5 back*****************/
        var selectedNumber = selectedelt1;
        // alert(selectedNumber);
        if ($(selectedNumber).hasClass('LeftBound') && pageNum != 1) {

            $(selectedNumber).removeClass('LeftBound');
            $(selectedNumber).addClass('RightBound');

            var total = pageNum + 1;
            var newright = "#suiteNumber" + total;

            $(newright).addClass('RightBound');


            for (i = pageNum; i > pageNum - 5; i--) {

                var elt = "#suiteNumber" + i;
                //alert(elt);
                $(elt).css('display', 'block');
            }

            var total = pageNum - 5;
            var newleft = "#suiteNumber" + total;

            $(newleft).addClass('LeftBound');

            for (w = pageNum + 1; w < pageNum + 5; w++) {
                var elt = "#suiteNumber" + w;
                $(elt).css('display', 'none');
            }
        }
        /******************************/

        $('.nextBlue').removeClass('disabled');
        $('.totheLeftBig').show();

        pageId = parseInt(pageId);
        if (parseInt(pageId) == 1) {

            $('.previousBlue').addClass('disabled');
            $('.totheRightBig').hide();
        } else {
            $('.previousBlue').removeClass('disabled');
            $('.totheRightBig').show();
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageAlbum").value = pageId - 1;
        //}


        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId - 1);
        location.hash = "pageid=" + newpageId;


        $.ajax({
            url: routeURL + 'Gallery/GetPreviousAlbums',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#albumlist').html(data);

            }
        });
    }

}

function ShowSelectedAlbum(pageNum) {
    //var Search = document.getElementById("currentSearch").value;
    var j = 0;
    var z = 0;
    //var pageId = $('#currentPageMusic').val();
    $('.suiteNumber').removeClass('selected');
    pageId = parseInt(pageNum);
    pageNum = parseInt(pageNum);

    var selectedNumber = "#suiteNumber" + pageNum;


    if ($(selectedNumber).hasClass('RightBound')) {

        $(selectedNumber).removeClass('RightBound');
        var total = pageNum + 4;
        var newright = "#suiteNumber" + total;
        $(newright).addClass('RightBound');

        for (i = pageNum; i < pageNum + 5; i++) {

            var elt = "#suiteNumber" + i;
            $(elt).css('display', 'block');
        }

        var newleft = "#suiteNumber" + pageNum;

        $(newleft).addClass('LeftBound');

        for (w = pageNum - 1; w >= pageNum - 5; w--) {
            var elt = "#suiteNumber" + w;
            $(elt).css('display', 'none');
        }
    }


    else if ($(selectedNumber).hasClass('LeftBound') && pageNum != 1) {

        $(selectedNumber).removeClass('LeftBound');
        $(selectedNumber).addClass('RightBound');

        var total = pageNum - 4;
        var newright = "#suiteNumber" + total;

        //$(newright).addClass('RightBound');

        //alert(pageNum);
        for (i = pageNum; i >= pageNum - 4; i--) {

            var elt = "#suiteNumber" + i;
            $(elt).css('display', 'block');
        }

        var total = pageNum - 4;
        var newleft = "#suiteNumber" + total;

        $(newleft).addClass('LeftBound');

        for (w = pageNum + 1; w < pageNum + 5; w++) {
            var elt = "#suiteNumber" + w;
            $(elt).css('display', 'none');
        }
    } else {
    }
    var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(pageId);
    // var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(pageId);

    $(selectedelt1).addClass('selected');
    //$(selectedelt2).addClass('selected');

    if (parseInt(pageId) == parseInt(document.getElementById("NbPageAlbums").value)) {

        $('.nextBlue').addClass('disabled');
        $('.totheLeftBig').hide();
        if (parseInt(document.getElementById("NbPageAlbums").value) != 0) {
            $('.previousBlue').removeClass('disabled');
            $('.totheRightBig').show();
        }
        // $('#btnMoreArticles').hide();
    }
    else if (parseInt(pageId) == 0) {

        $('.previousBlue').addClass('disabled');
        $('.totheRightBig').hide();
        if (parseInt(document.getElementById("NbPageAlbums").value) != 0) {
            $('.nextBlue').removeClass('disabled');
            $('.totheLeftBig').hide();
        }
        // $('#btnMoreArticles').hide();
    }
    else {
        $('.nextBlue').removeClass('disabled');
        $('.previousBlue').removeClass('disabled');
        $('.totheRightBig').show();
        $('.totheLeftBig').show();
    }

    //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

    document.getElementById("currentPageAlbum").value = pageId;
    //}


    var routeURL = document.getElementById("routeURL").value;
    var poststr = "pagenum=" + encodeURI(pageId - 1);

    $.ajax({
        url: routeURL + 'Gallery/GetSelectedAlbums',
        type: 'POST',
        data: '' + poststr,

        success: function (data) {
            $('#albumlist').html(data);

        }
    });

}

/**/


/*PhotoGallery Videos*/

function GoToNextVideos() {


    //var Search = document.getElementById("currentSearch").value;

    var pageId = $('#currentPageVideo').val();


    if (parseInt(pageId) != parseInt(document.getElementById("NbPageVideos").value)) {
        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) + 1;
        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);
        var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);

        $(selectedelt1).addClass('selected');
        $(selectedelt2).addClass('selected');


        $('.previousBlue').removeClass('disabled');
        $('.totheRightBig').show();
        pageId = parseInt(pageId);


        if (parseInt(pageId) == parseInt(document.getElementById("NbPageVideos").value - 1)) {

            $('.nextBlue').addClass('disabled');
            $('.totheLeftBig').hide();
        } else {
            $('.nextBlue').removeClass('disabled');
            $('.totheLefttBig').show();
        }
        //if (parseInt(pageId) < parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageVideo").value = pageId + 1;
        //}


        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId);



        $.ajax({
            url: routeURL + 'Gallery/GetNextVideos',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#videolist').html(data);

                showImageyoutube();

            }
        });
    }

}


function GoToPreviousVideos() {

    // var Search = document.getElementById("currentSearch").value;
    var pageId = $('#currentPageVideo').val();


    if (parseInt(pageId) != 0) {


        $('.suiteNumber').removeClass('selected');

        var newpageId = parseInt(pageId) - 1;
        var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(newpageId);
        var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(newpageId);

        $(selectedelt1).addClass('selected');
        $(selectedelt2).addClass('selected');


        $('.nextBlue').removeClass('disabled');
        $('.totheLeftBig').show();

        pageId = parseInt(pageId);
        if (parseInt(pageId) == 1) {

            $('.previousBlue').addClass('disabled');
            $('.totheRightBig').hide();
        } else {
            $('.previousBlue').removeClass('disabled');
            $('.totheRightBig').show();
        }
        //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

        document.getElementById("currentPageVideo").value = pageId - 1;
        //}


        var routeURL = document.getElementById("routeURL").value;
        var poststr = "pagenum=" + encodeURI(pageId - 1);


        $.ajax({
            url: routeURL + 'Gallery/GetPreviousVideos',
            type: 'POST',
            data: '' + poststr,

            success: function (data) {


                $('#videolist').html(data);

            }
        });
    }

}



function ShowSelectedVideo(pageNum) {
    //var Search = document.getElementById("currentSearch").value;
    var j = 0;
    var z = 0;
    //var pageId = $('#currentPageMusic').val();
    $('.suiteNumber').removeClass('selected');
    pageId = parseInt(pageNum);
    pageNum = parseInt(pageNum);

    var selectedNumber = "#suiteNumber" + pageNum;


    if ($(selectedNumber).hasClass('RightBound')) {

        $(selectedNumber).removeClass('RightBound');
        var total = pageNum + 4;
        var newright = "#suiteNumber" + total;
        $(newright).addClass('RightBound');

        for (i = pageNum; i < pageNum + 5; i++) {

            var elt = "#suiteNumber" + i;
            $(elt).css('display', 'block');
        }

        var newleft = "#suiteNumber" + pageNum;

        $(newleft).addClass('LeftBound');

        for (w = pageNum - 1; w >= pageNum - 5; w--) {
            var elt = "#suiteNumber" + w;
            $(elt).css('display', 'none');
        }
    }


    else if ($(selectedNumber).hasClass('LeftBound') && pageNum != 1) {

        $(selectedNumber).removeClass('LeftBound');
        $(selectedNumber).addClass('RightBound');

        var total = pageNum - 4;
        var newright = "#suiteNumber" + total;

        //$(newright).addClass('RightBound');

        //alert(pageNum);
        for (i = pageNum; i >= pageNum - 4; i--) {

            var elt = "#suiteNumber" + i;
            $(elt).css('display', 'block');
        }

        var total = pageNum - 4;
        var newleft = "#suiteNumber" + total;

        $(newleft).addClass('LeftBound');

        for (w = pageNum + 1; w < pageNum + 5; w++) {
            var elt = "#suiteNumber" + w;
            $(elt).css('display', 'none');
        }
    } else {
    }
    var selectedelt1 = ".showingBarTop" + " " + "#suiteNumber" + String(pageId);
    //var selectedelt2 = ".showingBarButtom" + " " + "#suiteNumber" + String(pageId);

    $(selectedelt1).addClass('selected');
    //$(selectedelt2).addClass('selected');

    if (parseInt(pageId) == parseInt(document.getElementById("NbPageVideos").value)) {

        $('.nextBlue').addClass('disabled');
        if (parseInt(document.getElementById("NbPageVideos").value) != 0) {
            $('.previousBlue').removeClass('disabled');
        }
        // $('#btnMoreArticles').hide();
    }
    else if (parseInt(pageId) == 0) {

        $('.previousBlue').addClass('disabled');
        if (parseInt(document.getElementById("NbPageVideos").value) != 0) {
            $('.nextBlue').removeClass('disabled');
        }
        // $('#btnMoreArticles').hide();
    }
    else {
        $('.nextBlue').removeClass('disabled');
        $('.previousBlue').removeClass('disabled');
    }

    //if (parseInt(pageId) <= parseInt(document.getElementById("NbPageMusics").value)) {

    document.getElementById("currentPageVideo").value = pageId;
    //}


    var routeURL = document.getElementById("routeURL").value;
    var poststr = "pagenum=" + encodeURI(pageId - 1);

    $.ajax({
        url: routeURL + 'Gallery/GetSelectedVideos',
        type: 'POST',
        data: '' + poststr,

        success: function (data) {
            $('#videolist').html(data);

        }
    });

}



var popUpWin = 0;

function popUpWindow(URLStr, left, top, width, height) {

    if (popUpWin) {

        if (!popUpWin.closed) popUpWin.close();

    }

    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');

}

function OpenLiveList() {
    var routeURL = document.getElementById("routeURL").value;
    popUpWindow(routeURL + "ListenLive", 10, 10, 455, 200, 'resizable = no');
}


/**/

function IsValidEmail(email) {
    var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    return filter.test(email);
}


/*contact form validation*/
function submitForm(formid) {
    $('#message_sent').hide();
    test = false;

    $(formid).find('input,textarea').each(function () {
        var isError = false;
        //var test = false;


        var elem;
        if (($(this).attr('required') == 'required' && $(this).attr('value').length == 0) || ($(this).attr('required') == 'required' && $(this).attr('value') == 'Phone') || ($(this).attr('required') == 'required' && $(this).attr('value') == 'E-mail') || ($(this).attr('email') == '1' && !IsValidEmail($(this).attr('value'))) || ($(this).attr('email') == '1' && !IsValidEmail($(this).attr('value')))) {
            $('#message_error').css('display', 'block');
            isError = true;
            test = true;
            if (!elem) elem = $(this);
        }
    })

    if (test == false) {

        $('#message_error').css('display', 'none');

        $('#loader').css('display', 'block');
        var routeURL = document.getElementById("routeURL").value;
        var fullname = document.getElementById("fullname").value;
        var phone = document.getElementById("phone").value;
        var email = document.getElementById("email").value;
        var message = document.getElementById("message").value;
        var poststr = "fullname=" + fullname + "&phone=" + phone + "&email=" + email + "&message=" + message;

        $.ajax({
            url: routeURL + '/Home/AddContactUs',
            type: 'POST',
            data: '' + poststr,
            success: function (data) {
                document.getElementById("fullname").value = "";
                document.getElementById("phone").value = "Phone";
                document.getElementById("email").value = "E-mail";
                document.getElementById("message").value = "";
                $('#loader').css('display', 'none');
                $('#message_sent').show();

            }
        });


    }
}





/******************************/
function thisMovie(movieName) {

    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];

}

function ListenToPodcast(url, status, id) {
    var listenpodcastloader = '#loader' + id;
    $(listenpodcastloader).css('display', 'block');
    $('#grayContent').find('.slidinglistenpodcast').each(function (index) {
        $('.slidinglistenpodcast').html('');
        $('.closepodcast').css('display', 'none');
        $('.listenpodcast').css('display', 'block');
    });

    var routeURL = document.getElementById("routeURL").value;
    var slidinglistenpodcast = "#slidinglistenpodcast" + id;
    var closepodcast = "#closepodcast" + id;
    var listenpodcast = '#listenpodcast' + id;
    var poststr = "";

    $.ajax({
        url: routeURL + 'Music/GetListenLiveFlash',
        type: 'POST',
        data: '' + poststr,

        success: function (data) {

            var slidinglistenpodcast = "#slidinglistenpodcast" + id;

            $(slidinglistenpodcast).html(data);
            setTimeout(function () {

                //alert("2");
                $(listenpodcast).css('display', 'none');
                $(slidinglistenpodcast).css('visibility', 'visible');
                thisMovie("podcastflash").SetVariable("to_load", url);
                thisMovie("podcastflash").SetVariable("play_status", status);
                $(slidinglistenpodcast).css('height', '25px');
                $(slidinglistenpodcast).css('left', '100px');
                $(closepodcast).css('display', 'block');
                
            }, 1000);
            $(listenpodcastloader).css('display', 'none');
            // alert("done");
        }
    });
}
/*****************************/


