//$(document).ready(function() {
//    $("dd:not(:first)").hide();
//    $("dt a").click(function() {
//        $("dd").slideUp();
//        $(this).parent("dt").next("dd").slideDown("normal");
//    });
//    $("li:has(ul) ul").hide();
//    $("li:has(ul) a").click(function() {
//        $(this).parent("li").parent("ul").children("li").children("ul").slideUp();
//        $(this).parent("li").children("ul").slideToggle("normal");

//    });
//});



$(document).ready(function() {
    /* for first level*/
//    $(".item ul").hide();
    $("#nav li ul:first").slideDown("normal");
    //          $('#nav li a:first').fadeOut("normal").fadeIn("normal").fadeOut("normal").fadeIn("normal",function (){$('#nav li a:first').css('margin-left','-10')});


    $(".item > a:first").click(function() {
        $(".item ul").slideUp();
        $(this).parent("li").children("ul").slideDown("normal");
    });
    /* for second level  blue  */
    $(".list_blue").hide();
    $(".item_blue ").click(function() {
        // $(this).parent("li").parent("ul").children("li").children("ul").slideUp();
        $(".list_blue").slideUp();
        $(this).parent("li").children("ul").slideDown("normal");
    });

    /* for second level  green  */
    $(".list_green").hide();
    $(".item_green ").click(function() {
        // $(this).parent("li").parent("ul").children("li").children("ul").slideUp();
        $(".list_green").slideUp();
        $(this).parent("li").children("ul").slideDown("normal");
    });

    /* for second level  orange  */
    $(".list_orange").hide();
    $(".item_orange ").click(function() {
        // $(this).parent("li").parent("ul").children("li").children("ul").slideUp();
        $(".list_orange").slideUp();
        $(this).parent("li").children("ul").slideDown("normal");
    });

  

    /*for forth level blue */
    $(".forthList_blue").hide();
    $(".list_blue li:has(ul) > a ").click(function() {
    $(".forthList_blue").slideUp();
    $(this).parent("li").children("ul").slideDown("normal");
});

$(".list_blue >li:not(:has(ul)) > a ").click(function() {
    $(".forthList_blue").slideUp();
   
});

/*for forth level green */
$(".forthList_green").hide();
$(".list_green li:has(ul)> a ").click(function() {
    $(".forthList_green").slideUp();
    $(this).parent("li").children("ul").slideDown("normal");
});

$(".list_green >li:not(:has(ul))> a ").click(function() {
    $(".forthList_green").slideUp();
  
});

/*for forth level orange */
$(".forthList_orange").hide();
$(".list_orange li:has(ul)> a ").click(function() {
    $(".forthList_orange").slideUp();
    $(this).parent("li").children("ul").slideDown("normal");
});

$(".list_orange >li:not(:has(ul))> a ").click(function() {
    $(".forthList_orange").slideUp();
 
});

});





       /*** for header slideshow picture
       Simple jQuery Slideshow Script
       Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
       ***/

       function slideSwitch() {
           var $active = $('#slideshow IMG.active');

           if ($active.length == 0) $active = $('#slideshow IMG:last');

           // use this to pull the images in the order they appear in the markup
           var $next = $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

           // uncomment the 3 lines below to pull the images in random order

           // var $sibs  = $active.siblings();
           // var rndNum = Math.floor(Math.random() * $sibs.length );
           // var $next  = $( $sibs[ rndNum ] );


           $active.addClass('last-active');

           $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        });
       }

       $(function() {
           setInterval("slideSwitch()", 10000);
       });

       function slideSwitch2() {
           var $active = $('#slideshow2 IMG.active');

           if ($active.length == 0) $active = $('#slideshow2 IMG:last');

           // use this to pull the images in the order they appear in the markup
           var $next = $active.next().length ? $active.next()
        : $('#slideshow2 IMG:first');

           // uncomment the 3 lines below to pull the images in random order

           // var $sibs  = $active.siblings();
           // var rndNum = Math.floor(Math.random() * $sibs.length );
           // var $next  = $( $sibs[ rndNum ] );


           $active.addClass('last-active');

           $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        });
       }

       $(function() {
           setInterval("slideSwitch2()", 10000);
       });





       function slideSwitch3() {
           var $active = $('#slideshow3 IMG.active');

           if ($active.length == 0) $active = $('#slideshow3 IMG:last');

           // use this to pull the images in the order they appear in the markup
           var $next = $active.next().length ? $active.next()
        : $('#slideshow3 IMG:first');

           // uncomment the 3 lines below to pull the images in random order

           // var $sibs  = $active.siblings();
           // var rndNum = Math.floor(Math.random() * $sibs.length );
           // var $next  = $( $sibs[ rndNum ] );


           $active.addClass('last-active');

           $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        });
       }

       $(function() {
           setInterval("slideSwitch3()", 10000);
       });







       /***********************************************
       * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
       * This notice MUST stay intact for legal use
       * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
       ***********************************************/

//       function ajaxpage(url, containerid, callBack, isSkipScroll) {

//           $("#" + containerid).load(url + "#ajaxDiv", "", function() {


//               if (callBack) eval(callBack);             
//               //        if(isSkipScroll != 1){
//               //             $('html, body').animate({scrollTop:0}, 'slow');
//               //        }
//           });
//       }

       function ajaxpage(url,containerid,callBack,isSkipScroll) {
           $("#" + containerid).load(url + " #ajaxDiv");

       }
           $(document).ready(function() {
           $("#center").ajaxStart(function() {
               $("#loading").show();
               $("#ajaxDivContent").hide();
           });
           $("center").ajaxStop(function() {
               $("#loading").hide();
           });

       });
              
              function ajaxpagePrint(url, containerid, callBack, isSkipScroll) {

           $("#" + containerid).load(url + " #bodyContent", "", function() {


               if (callBack) eval(callBack);
               //        if(isSkipScroll != 1){
               //             $('html, body').animate({scrollTop:0}, 'slow');
               //        }
           });
       }
       
       
       /*js for contact page*/

function formSerialize(formId) {
    var form = document.getElementById(formId);
    var s = [];
    for (var index = 0; index < form.length; index++) {
        ctrl = form[index];
        if (ctrl.type == "text" || ctrl.type == "textarea"||ctrl.type=="password") {
            s.push(ctrl.name + "=" + encodeURIComponent(ctrl.value));

        }
    }

    return s.join("&");

}




var xmlhttp; //????,????xmlhttpxmlhttpuest??
function creatxmlhttpZwembaden() // ??xmlhttpxmlhttpuest,ajax??
{
    var url = "SportSpectRum_Contact_Zwembaden_Send.aspx"; //?????????
    if (window.XMLHttpRequest) //?IE???,?xmlhttpxmlhttpuest????
    {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) //IE????activexobject????
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHttp");
    }

    if (xmlhttp) //????xmlhttpxmlhttpuest
    {

        if (Reg()) {
            xmlhttp.open("post", url, true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlhttp.send(formSerialize("form1"));
            
        }

    }


}



function creatxmlhttpBeweging() // ??xmlhttpxmlhttpuest,ajax??
{
    var url = "SportSpectRum_Contact_Beweging_Send.aspx"; //?????????
    if (window.XMLHttpRequest) //?IE???,?xmlhttpxmlhttpuest????
    {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) //IE????activexobject????
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHttp");
    }

    if (xmlhttp) //????xmlhttpxmlhttpuest
    {

        if (Reg()) {
            xmlhttp.open("post", url, true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlhttp.send(formSerialize("form1"));

        }

    }


}


function creatxmlhttpBeheer() // ??xmlhttpxmlhttpuest,ajax??
{
    var url = "SportSpectRum_Contact_Beheer_Send.aspx"; //?????????
    if (window.XMLHttpRequest) //?IE???,?xmlhttpxmlhttpuest????
    {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) //IE????activexobject????
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHttp");
    }

    if (xmlhttp) //????xmlhttpxmlhttpuest
    {

        if (Reg()) {
            xmlhttp.open("post", url, true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlhttp.send(formSerialize("form1"));

        }

    }


}

function callback() //????,?????????,??response??
{
    if (xmlhttp.readyState == 4) //?????4????
    {
        if (xmlhttp.status == 200) //http??200??OK
        {
            Display(); //??????,?????,????
        }
        else //http??????
        {
            alert("???????" + xmlhttp.statusText);
        }
    }
    else //?????????,????
    {
        //    document .getElementById ("myTime").innerHTML ="?????";
        //document.write ("sending");
    }
}

function Display() //??????????,??????
{
    //document .getElementById ("myTime").innerHTML =xmlhttp.responseText;
    //             document.write (xmlhttp.responseText);

    jAlert('Uw bericht is verstuurd. We zullen uw bericht op korte termijn verwerken.', 'Email - Success');
    document.getElementById("form1").reset();

}


//validate

function Reg() {



//Reg maam  required
     var NaamText=document.getElementById ("naam").value;
     var regNaam=/^\s*$/;
     if(regNaam.test (NaamText ))
     {
       document.getElementById ("regnaam").style.visibility="visible";
       document.getElementById ("naam").focus();
       return false ;
     
     }
     else
     {
       document.getElementById ("regnaam").style .visibility="hidden" ;

   }


   //Reg Onderwerp  required
   var NaamText = document.getElementById("onderwerp").value;
   var regNaam = /^\s*$/;
   if (regNaam.test(NaamText)) {
       document.getElementById("regonderwerp").style.visibility = "visible";
       document.getElementById("onderwerp").focus();
       return false;

   }
   else {
       document.getElementById("regonderwerp").style.visibility = "hidden";

   }


   //Reg Vraagstelling  required
   var NaamText = document.getElementById("vraagstelling").value;
   var regNaam = /^\s*$/;
   if (regNaam.test(NaamText)) {
       document.getElementById("regvraagstelling").style.visibility = "visible";
       document.getElementById("vraagstelling").focus();
       return false;

   }
   else {
       document.getElementById("regvraagstelling").style.visibility = "hidden";

   }

    // Reg the format Email
    var emailText = document.getElementById("email").value;
    var Regemail = /^[_a-zA-Z0-9_-]+@([_a-zA-Z0-9_-]+\.)+[a-zA-Z0-9_-]{2,3}$/;

    if (!Regemail.test(emailText)) {
        document.getElementById("regemail").style.visibility = "visible";
        document.getElementById("email").focus();
        return false;
    }

    else {
        document.getElementById("regemail").style.visibility = "hidden";
    }

    return true;


}






/*
================================
Popup window
================================
*/

// jQuery Alert Dialogs Plugin
//
// Version 1.0
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 29 December 2008
//
// Visit http://abeautifulsite.net/notebook/87 for more information
//
// Usage:
//		jAlert( message, [title, callback] )
//		jConfirm( message, [title, callback] )
//		jPrompt( message, [value, title, callback] )
// 
// History:
//
//		1.00 - Released (29 December 2008)
//
// License:
// 
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC. 
//
(function($) {

    $.alerts = {

        // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time

        verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
        horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
        repositionOnResize: true,           // re-centers the dialog on window resize
        overlayOpacity: .01,                // transparency level of overlay
        overlayColor: '',               // base color of overlay
        draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
        okButton: '&nbsp;OK&nbsp;',         // text for the OK button
        cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
        dialogClass: null,                  // if specified, this class will be applied to all dialogs

        // Public methods

        alert: function(message, title, callback) {
            if (title == null) title = 'Alert';
            $.alerts._show(title, message, null, 'alert', function(result) {
                if (callback) callback(result);
            });
        },

        confirm: function(message, title, callback) {
            if (title == null) title = 'Confirm';
            $.alerts._show(title, message, null, 'confirm', function(result) {
                if (callback) callback(result);
            });
        },

        prompt: function(message, value, title, callback) {
            if (title == null) title = 'Prompt';
            $.alerts._show(title, message, value, 'prompt', function(result) {
                if (callback) callback(result);
            });
        },

        // Private methods

        _show: function(title, msg, value, type, callback) {

            $.alerts._hide();
            $.alerts._overlay('show');

            $("BODY").append(
			  '<div id="popup_container">' +
			    '<h1 id="popup_title"></h1>' +
			    '<div id="popup_content">' +
			      '<div id="popup_message"></div>' +
				'</div>' +
			  '</div>');

            if ($.alerts.dialogClass) $("#popup_container").addClass($.alerts.dialogClass);

            // IE6 Fix
            var pos = ($.browser.msie && parseInt($.browser.version) <= 6) ? 'absolute' : 'fixed';

            $("#popup_container").css({
                position: pos,
                zIndex: 99999,
                padding: 0,
                margin: 0
            });

            $("#popup_title").text(title);
            $("#popup_content").addClass(type);
            $("#popup_message").text(msg);
            $("#popup_message").html($("#popup_message").text().replace(/\n/g, '<br />'));

            $("#popup_container").css({
                minWidth: $("#popup_container").outerWidth(),
                maxWidth: $("#popup_container").outerWidth()
            });

            $.alerts._reposition();
            $.alerts._maintainPosition(true);

            switch (type) {
                case 'alert':
                    $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
                    $("#popup_ok").click(function() {
                        $.alerts._hide();
                        callback(true);
                    });
                    $("#popup_ok").focus().keypress(function(e) {
                        if (e.keyCode == 13 || e.keyCode == 27) $("#popup_ok").trigger('click');
                    });
                    break;
                case 'confirm':
                    $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
                    $("#popup_ok").click(function() {
                        $.alerts._hide();
                        if (callback) callback(true);
                    });
                    $("#popup_cancel").click(function() {
                        $.alerts._hide();
                        if (callback) callback(false);
                    });
                    $("#popup_ok").focus();
                    $("#popup_ok, #popup_cancel").keypress(function(e) {
                        if (e.keyCode == 13) $("#popup_ok").trigger('click');
                        if (e.keyCode == 27) $("#popup_cancel").trigger('click');
                    });
                    break;
                case 'prompt':
                    $("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
                    $("#popup_prompt").width($("#popup_message").width());
                    $("#popup_ok").click(function() {
                        var val = $("#popup_prompt").val();
                        $.alerts._hide();
                        if (callback) callback(val);
                    });
                    $("#popup_cancel").click(function() {
                        $.alerts._hide();
                        if (callback) callback(null);
                    });
                    $("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(e) {
                        if (e.keyCode == 13) $("#popup_ok").trigger('click');
                        if (e.keyCode == 27) $("#popup_cancel").trigger('click');
                    });
                    if (value) $("#popup_prompt").val(value);
                    $("#popup_prompt").focus().select();
                    break;
            }

            // Make draggable
            if ($.alerts.draggable) {
                try {
                    $("#popup_container").draggable({ handle: $("#popup_title") });
                    $("#popup_title").css({ cursor: 'move' });
                } catch (e) { /* requires jQuery UI draggables */ }
            }
        },

        _hide: function() {
            $("#popup_container").remove();
            $.alerts._overlay('hide');
            $.alerts._maintainPosition(false);
        },

        _overlay: function(status) {
            switch (status) {
                case 'show':
                    $.alerts._overlay('hide');
                    $("BODY").append('<div id="popup_overlay"></div>');
                    $("#popup_overlay").css({
                        position: 'absolute',
                        zIndex: 99998,
                        top: '0px',
                        left: '0px',
                        width: '100%',
                        height: $(document).height(),
                        background: $.alerts.overlayColor,
                        opacity: $.alerts.overlayOpacity
                    });
                    break;
                case 'hide':
                    $("#popup_overlay").remove();
                    break;
            }
        },

        _reposition: function() {
            var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
            var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
            if (top < 0) top = 0;
            if (left < 0) left = 0;

            // IE6 fix
            if ($.browser.msie && parseInt($.browser.version) <= 6) top = top + $(window).scrollTop();

            $("#popup_container").css({
                top: top + 'px',
                left: left + 'px'
            });
            $("#popup_overlay").height($(document).height());
        },

        _maintainPosition: function(status) {
            if ($.alerts.repositionOnResize) {
                switch (status) {
                    case true:
                        $(window).bind('resize', function() {
                            $.alerts._reposition();
                        });
                        break;
                    case false:
                        $(window).unbind('resize');
                        break;
                }
            }
        }

    }

    // Shortuct functions
    jAlert = function(message, title, callback) {
        $.alerts.alert(message, title, callback);
    }

    jConfirm = function(message, title, callback) {
        $.alerts.confirm(message, title, callback);
    };

    jPrompt = function(message, value, title, callback) {
        $.alerts.prompt(message, value, title, callback);
    };

})(jQuery);




$(document).ready(function (){
/*jquery for faq type slide*/
   $('.black').next().hide();
   $('.black').click(function (){
      $('.black').next().slideUp("normal");
      $(this).next().slideDown("normal");
   });
   
   /* jquery for faq content */
   $('.answer').hide();
   $('.answer').slideDown("normal");
   

});




   /*
================================
JQuery for search box
================================
*/

$(document).ready(function() {

$('#Search_Box_Zwembaden').keypress(function(event){

    if(event.keyCode ==13 &&  $(this).val() !=''){
         onSearch_Zwembaden('Search_Box_Zwembaden') //do search
    }
});

$('#Search_Box_Beweging').keypress(function(event) {

    if (event.keyCode == 13 && $(this).val() != '') {
        onSearch_Zwembaden('Search_Box_Beweging') //do search
    }
});

$('#Search_Box_Beheer').keypress(function(event) {

    if (event.keyCode == 13 && $(this).val() != '') {
        onSearch_Zwembaden('Search_Box_Beheer') //do search
    }
});

});


function onSearch_Zwembaden(textBoxId){

    var searchQuery = document.getElementById(textBoxId).value;

    location.replace("/zwembaden/search_zwembaden.aspx?search=" + searchQuery);
 }

 function onSearch_Beweging(textBoxId) {

     var searchQuery = document.getElementById(textBoxId).value;

     location.replace("/beweging/search_beweging.aspx?search=" + searchQuery);

 }

 function onSearch_Beheer(textBoxId) {

     var searchQuery = document.getElementById(textBoxId).value;

     location.replace("/beheer/search_beheer.aspx?search=" + searchQuery);
 }

/*for print*/

$(document).ready(function (){
   $('#printen').click(function() {
      var printUrl=window .location.href;
      window.open("SportSpectRum_Print.aspx");
   }
);

   $('#print-zwembaden').click(function() {
      var printUrl=window .location.href;
      window.open("SportSpectRum_print_zwembaden.aspx");
   }
);






});








function testSearch_Zwembaden(){
    if (window.location.pathname = "/SportSpectRum_Search_Zwembaden.aspx") {
        return true;
    }
    return false;

}

function testSearch_Beweging() {
    if (window.location.pathname = "/SportSpectRum_Search_Beweging.aspx") {
        return true;
    }
    return false;

}

function testSearch_Beheer() {
    if (window.location.pathname = "/SportSpectRum_Search_Beheer.aspx") {
        return true;
    }
    return false;

}


$(document).ready(function() {
   
    $('#logoDiv').click(function() {

    window.location.replace("/home.aspx");
    });


});

/* news letter page*/
function testInput() {
var Email =  new String(document.getElementsByName('Email')[0].value); 
var Correct = true; 
CharCount=1; 
strLength=Email.length; 
while ((CharCount < strLength) && (Email.charAt(CharCount) != '@')) 
{ 
	CharCount++ 
} 
if ((CharCount>= strLength) || (Email.charAt(CharCount) != '@'))  
{  
	alert ('Het e-mailadres is niet geldig.') 
	Correct = false; 
} 
else 
{ 
	CharCount += 2; 
} 
while ((CharCount < strLength) && (Email.charAt(CharCount) != '.')) 
{ 
	CharCount++ 
} 
if ((CharCount>= strLength - 1) || (Email.charAt(CharCount) != '.')) 
{ 
	alert ('Het e-mailadres is niet geldig.') 
	Correct = false; 
} 
return Correct 
}
