﻿/// <reference path="../jquery-1.3.2.js" />

//jQuery(function($) {

$(document).ready(function() {
    //fade in on different siteparts
    //currently disabled
    //hide siteparts
    //    $("#siteHeading").hide();
    //    $("#siteLangMenu").hide();
    //    $("#siteMenu").hide();
    //    $("#siteContent").hide();

    //fadein siteparts
    //    $("#siteHeading").fadeIn(1000);
    //    $("#siteLangMenu").fadeIn(5000);
    //    $("#siteMenu").fadeIn(4000);
    //    $("#siteContent").fadeIn(5000);


    //contactplannen
    //initially hide maps
    $(".routeplan").hide();
    //show map when click on icon
    $(".routeplanicon").click(function() { $(".routeplanhint").hide(); $(".routeplan").slideDown(1000); });


    //accordion for image gallery
    //hide the all of the element with class msg_body
    $(".msg_body, #outputimage, #backtolist").hide();
    //slides the element with class "msg_body" when paragraph with class "msg_head" is clicked
    $("#fotopane p.msg_head").click(function() {
        $("#backtolist").show();
        $(this).next("div.msg_body").slideToggle(700).siblings("div.msg_body, p.msg_head").slideUp("slow");
    });





    //make printables : print only route description and map
    //first append buttons
    $(".routeplantable").before("<table> \
                                    <tr> \
                                        <td><a id='sluitroutebeschrijving'><img alt='close' class='icon' src='Images/deleteIcon.gif'/> &nbsp;Sluit routebeschrijving</a></td> \
                                    </tr> \
                                    <tr> \
                                        <td><a id='printrouteplan'><img alt='close' class='icon' src='Images/print.png'/> &nbsp;Print routebeschrijving</a></td> \
                                    </tr> \
                                 </table>");

    //define printfunction and attach to printbutton
    $(function() {

        // Hook up the print link.
        $("a#printrouteplan").attr("href", "javascript:void( 0 )").click(
						function() {
						    $("#sluitroutebeschrijving, #printrouteplan").hide();
						    // Print the DIV.
						    $(".routeplan").print();
						    $("#sluitroutebeschrijving, #printrouteplan").show();
						    // Cancel click event.
						    return (false);
						});
    }
			);




    //define closefunction and attach to closebutton
    $(function() {

        // Hook up the close link.
        $("a#sluitroutebeschrijving").attr("href", "javascript:void( 0 )").click(
						function() {
						    // close route and show hint
						    $(".routeplan").slideUp(1000);
						    $(".routeplanhint").show(1000);

						    // Cancel click event.
						    return (false);
						});

    }
			);


    //show ckfinder to change header
    $("#btnManageFiles").click(function() {
        $(".CKFinderFrame, #btncloseckfinder").show();
        $("#btnManageFiles").hide();
    });

    //function to close ckfinder
    $("#btncloseckfinder").click(function() { $(".CKFinderFrame, #btncloseckfinder").hide(); $("#btnManageFiles").show(); })


    $('#videoImage').click(function() {$('#showvideo').modal();})

});


    // This is a function which is called when a file is selected in CKFinder.
    function ChangeHeader(fileUrl, data) {
        //alert('The selected file URL is "' + fileUrl + '"');
        // Display additional information available in the "data" object.
        // For example, the size of a file (in KB) is available in the data["fileSize"] variable.
        //for (_info in data)
        //alert('data["' + _info + '"]' + ' = ' + data[_info]);

        //put the ajax call to change header
//        $.ajax({
//            type: "POST",
//            url: "testpagemethod.aspx/ChangeHeader",
//            data: "{headerurl:'" + fileUrl + "'}",
//            contentType: "application/json;  charset=utf-8",
//            dataType: "json",
//            success: function(xhr) {
//                if (xhr.d == "true") {}
//                else {
                    //header could not be changed
//                    alert("Header kon niet aangepast worden door een technische fout");}},
//            error: function(xhr, error) {
//                alert("Header kon niet aangepast worden door een technische fout");}
//        });

}


//});


//redux simple query menu
/* 
Simple JQuery menu.
HTML structure to use:

Notes: 

1: each menu MUST have an ID set. It doesn't matter what this ID is as long as it's there.
2: each menu MUST have a class 'menu' set. If the menu doesn't have this, the JS won't make it dynamic

Optional extra classnames:

noaccordion : no accordion functionality
collapsible : menu works like an accordion but can be fully collapsed
expandfirst : first menu item expanded at page load

<ul id="menu1" class="menu [optional class] [optional class]">
<li><a href="#">Sub menu heading</a>
<ul>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
...
...
</ul>
<li><a href="#">Sub menu heading</a>
<ul>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
...
...
</ul>
...
...
</ul>

Copyright 2008 by Marco van Hylckama Vlieg

web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl

Free for non-commercial use
*/

function initMenus() {
    //hide all submenus
    $('ul.menu2 ul').hide();

    //show ul of selected item and add 'selected' class
    var path = location.pathname;
    var page = path.substring(path.lastIndexOf('/') + 1);
    var querystring = location.search;
    if (!querystring) querystring = location.hash;
    $('.menu2 li ul li a[href="' + page + querystring + '"]').addClass('selected').parent().parent().show().parent().children('a').addClass('selected');
    //$('.menu2 li a[href="' + page + querystring + '"]').addClass('selected').parent().parent().parent('ul a').children('ul').show();
    $('.menu2 li a[href="' + page + querystring + '"]').addClass('selected').parent().children('ul').show()

    //click event on menuitem selction
    $('ul.menu2 li a').click(
		function() {

		    var checkElement = $(this).next();
		    var parent = this.parentNode.parentNode.id;

		    		    if ($('#' + parent).hasClass('noaccordion')) {
		    		        if ((String(parent).length > 0) && (String(this.className).length > 0)) {
		    		            $(this).next().slideToggle('normal');
		    		        }
		    		    }
		    		    if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
		    		        if ($('#' + parent).hasClass('collapsible')) {
		    		            $('#' + parent + ' ul:visible').slideUp('normal');
		    		        }
		    		        return true;
		    		    }
		    if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		        $('#' + parent + ' ul:visible').slideUp('normal');
		        checkElement.slideDown('normal');
		        return true;
		    }
		}
	);
}
$(document).ready(function() { initMenus(); });



