	/**
	 *	Animate homepage menu's slide up
	 *	
	 */	 	 
	
	if(typeof(jQuery)!="function"||($.browser.msie && $.browser.version < 7)){
	}else{
		// Animation variables
		var foldout_height 		= 230;
		var foldout_speed		= 600;
		var foldback_speed		= 400;
		
		// Animation script
		$(document).ready( function(){
				$("body").css("background-color","#fff");
				$("#menu > ul > li > ul").each(
					function(i){
						$(this).css("margin-top",10000).css("display","block").css({marginLeft:parseInt($(this).css("left"),10)}).css("display","none").css("margin-top",0).css("display","none");
					}
				).removeClass("patienten bezoekers verwijzers werken_leren");
				jQuery.easing.def = "easeOutBack";
				$("#menu > ul > li > ul").css({marginTop:0, paddingBottom:0, top:0, height:0, overflow:'hidden'});
				$("#menu > ul > li").hover(
					function(e){foldout(this, foldout_height, foldout_speed)},
					function(e){foldback(this, foldback_speed)}
				);
				
				
				// Foldoutmenu
				$("#foldoutMenu > ul > li > ul").each(
					function(i){
						$(this).css("margin-top",10000).css("display","block").css({marginLeft:parseInt($(this).css("left"),10)}).css("display","none").css("margin-top",0).css("display","none");
					}
				).removeClass("patienten bezoekers verwijzers werken_leren");
				jQuery.easing.def = "easeOutBack";
				$("#foldoutMenu > ul > li > ul").css({marginTop:0, paddingBottom:0, top:0, height:0, overflow:'hidden'});
				$("#foldoutMenu > ul > li").hover(
					function(e){foldout(this, foldout_height, foldout_speed)},
					function(e){foldback(this, foldback_speed)}
				);
				
			    $(".folder_checkbox").click( function(e) { togglevalue(this) } );	
			}
		)
		
		function foldout(obj, height, speed){
			$("ul",obj).css({top:8, height:0, display:''}).stop().animate({
				top:-height+8, height:height
			},speed)
		}
		function foldback(obj, speed){
			$("ul",obj).stop().animate({top:8, height:0 }, speed, "linear", function(){
				$(this).css({top:8, height:0, display:'none'})
			})
		}
		
		function togglevalue(obj) {		    
		    var checked = $(obj).is(":checked");		    
		    if (checked)
		        $("input[@value='" + obj.value + "']").attr("checked", "true");
		    else
		        $("input[@value='" + obj.value + "']").removeAttr("checked");
		}		
	}


	function togglefoldersdisplay(divid)
	{
		$(".folders:visible").slideUp("slow", function() {$(divid).slideDown("slow");}); 
		return false;
	}	
	
	function validatefolders() {	    
        var checkboxeschecked = $("input[@class='folder_checkbox']:checked").length;        
        if (checkboxeschecked == 0)
        {
            $("#folderserrormessage").html("U heeft geen folders geselecteerd om te bestellen");
            return false;
        }
        else
        {
            return true;
        }
    }
    
    $(document).ready(function()
    {
        $("fieldset[defaultsubmitbutton]").each(function()
        {
            var submitbuttonid = $(this).attr("defaultsubmitbutton");
            
            $("input[type='text']", this).keydown(function(e)
            {    
                var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;                
                if (key == 13)                    
                {
                    e.preventDefault();
                    var button = $("#" + submitbuttonid).eq(0);                    
                    if (button.length > 0) {
                        if (typeof(button.get(0).onclick) == 'function') {
                        	button.trigger('click');
                    	} else if (button.attr('href')) {
                        	window.location = button.attr('href');
                    	} else {
                        	button.trigger('click');
                        }               
                    }                    
                }   
            });
            $("input[type='password']", this).keydown(function(e)
            {    
                var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;                
                if (key == 13)                    
                {
                    e.preventDefault();
                    var button = $("#" + submitbuttonid).eq(0);                    
                    if (button.length > 0) {
                        if (typeof(button.get(0).onclick) == 'function') {
                        	button.trigger('click');
                    	} else if (button.attr('href')) {
                        	window.location = button.attr('href');
                    	} else {
                        	button.trigger('click');
                        }               
                    }                    
                }   
            });         
        });
    });