$(document).ready(function() {

    initMenu();

    //TV Vieuwer:
    $("#wepViewerTV").fancybox({
        'width': 485,
        'height': 384,
        'autoScale': false,
        'transitionIn': 'elastic',
        'transitionOut': 'none',
        'type': 'iframe',
        'overlayShow': true,
        'overlayColor': '#000',
        'overlayOpacity': 0.7
    });
    

    //$('#wepPlayer').remove();
    
    $.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
        $(pager).find('li').removeClass('activeLI')
		.filter('li:eq(' + currSlideIndex + ')').addClass('activeLI');
    };


    $('.topimage').cycle({
        fx: 'fade',
        speed: 1500, // speed of the transition (any valid fx speed value)
        timeout: 100, // milliseconds between slide transitions (0 to disable auto advance) 
        next: '.topimage', // id of element to use as click trigger for next slide 
        pager: '.topbar', // id of element to use as pager container 
        pagerEvent: 'mouseover',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor 
            //return '.topbar .colum:(' + idx + ')';
        }
    });

    //maand view
    $('.uitklap:first').show();
    $('.uitklap:first').addClass("active");



    // style switcher
    $("#css-red").click(function() {
        $("link[rel=stylesheet]").attr({ href: "css/styles-radio.css" });
    });

    $("#css-blue").click(function() {
        $("link[rel=stylesheet]").attr({ href: "css/style.css" });
    });

    // Uitzending gemist---------------

    $("#btnHello").click(getListButton);
    $("#ddlOne").change(getList);
    $("#ddlCat").change(get_ddlCat);
    $("#ddlDate").change(get_ddlDate);
    //  $("#uitzendingAlgemeen").change(get_ddlCatList);

    //---------------------------------
});


        function wepLiveViewer() {
            $('#wepPlayer').remove();
            $('#MediaPlayer').remove();
        }

		//AJAX SCRIP: Uitzending Gemist::

        function get_ddlDateList(id, cat) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/ddlDate.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=" + id +"&Cat="+ cat,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#lastuitzending").remove();
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }



        function get_ddlDate() {

            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/ddlDate.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=last&Cat=" + $("#ddlDate").val(),
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#lastuitzending").remove();
                    $("#uitzendingAlgemeen").remove();
                    $("#ddlTwo").remove();
                    $("#wepSearchUG").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }


        function get_ddlCatList(id, cat) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/ddlCat.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=" + id + "&Cat=" + cat,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#lastuitzending").remove();
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }



        function get_ddlCat() {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/ddlCat.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=last&Cat=" + $("#ddlCat").val(),
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#lastuitzending").remove();
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }
        
        
        function getListButton() {
        
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=last",
                async: false,
                success: function(msg) {
                $('#MediaPlayer').remove(); 
                $("#ddlTwo").remove();
                $("#wepSearchUG").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }

        function getLinkButton(strVal) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val="+ strVal,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove();
                    $("#uitzendingAlgemeen").remove();
                    $("#ddlTwo").remove();
                    $("#wepSearchUG").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }

        function getLinkButtonMainPage(strVal) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val="+ strVal,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#uitzendingAlgemeen").remove();
                    $("#ddlTwo").remove();
                    $("#wepSearchUG").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }
        
		function getList() {
		    $.ajax({
		        type: "POST",
		        url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
		        dataType: "application/x-www-form-urlencoded",
		        data: "Action=GetList&Val=" + $("#ddlOne").val(),
		        async: false,
		        success: function(msg) {
		            $('#MediaPlayer').remove(); 
		            $("#ddlTwo").remove();
		            $("#wepSearchUG").remove();
		            $("#wepVideo").append(msg);
		        }
		    })
		}

		function getListHome() {
		    $.ajax({
		        type: "POST",
		        url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
		        dataType: "application/x-www-form-urlencoded",
		        data: "Action=GetList&Val=last",
		        async: false,
		        success: function(msg) {
		            $('#MediaPlayer').remove();
		            $("#ddlTwo").remove();
		            $("#wepSearchUG").remove();
		            $("#wepVideo").append(msg);
		            $("#wepPlayer").append();
		        }
		    })
		}

		function getSearchResults(strVal) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerSearch.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val="+ escape(strVal),
                async: false,
                success: function(msg) {
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepVideo").append(msg);
                    $('#wepPlayer').remove();
                }
            })
        }
        function getSearchResult(strVal,strValID) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerSearch.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=" + strVal + "&ValID=" + strValID,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }


        function getLinkItemsButton(strVal, strItem) {
            $.ajax({
                type: "POST",
                url: "/tv/uitzending_gemist/wepPlayerAjax.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=" + strVal + "&item=" + strItem,
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#uitzendingAlgemeen").remove();
                    $("#ddlTwo").remove();
                    $("#wepSearchUG").remove();
                    $("#wepVideo").append(msg);
                }
            })
        }


        function getSearchResultsMain(strVal, strPortal) {
            $.ajax({
                type: "POST",
                url: "/" + strPortal + "/zoeken/zoeken.asp",
                dataType: "application/x-www-form-urlencoded",
                data: "Action=hello&Val=" + escape(strVal) + "",
                async: false,
                success: function(msg) {
                    $('#MediaPlayer').remove(); 
                    $("#uitzendingAlgemeen").remove();
                    $("#wepSearchUG").remove();
                    $("#ddlTwo").remove();
                    $("#wepSearch").append(msg);
                }
            })
        }        
		//END AJAX


        //Main menu
        function openMenu(val) {
            document.getElementById('submenuTv').style.display = 'none';
            document.getElementById('submenuRadio').style.display = 'none';
            document.getElementById('submenuHvD').style.display = 'none';
            document.getElementById('submenuOmroep').style.display = 'none';
            if (val != '') {
                document.getElementById(val).style.display = 'inline';
            }
        }


        // Search page:: menuSearch
        function initMenu() {
            $('#menuSearch ul').hide();
            $('#menuSearch ul:first').show();
            $('#menuSearch li a').click(
            function() {
                var checkElement = $(this).next();
                if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                    return false;
                }
                if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                    $('#menuSearch ul:visible').slideUp('normal');
                    checkElement.slideDown('normal');
                    return false;
                }
            }
            );
        }

        // END:: Search page

