$(document).ready( function() {		
    var menu_id;
    if($.cookie('menustate') != '' )
    {
     menu_id = $.cookie('menustate');
	 $( "."+menu_id+" .menu-entry").show();   
    }
	$('.menu-main-button').click(function(){
    if(  $("."+menu_id+" .menu-entry").is(":visible") == "true" ){
       //alert('do something');
       $( "."+menu_id+" .menu-entry").hide();
    }
    else{
       //alert('do something else');
       //$.cookie('menustate', menu_id);
       menu_id        = $(this).attr('id');        //klick id 
       $( "."+menu_id+" .menu-entry").toggle("slow");
    }
    $.cookie('menustate', menu_id);              
	});
	//delete the cookie
    $('.delete-cookie').click(function(){
		$.cookie('menustate', null);   
	});
			
//js for old menu	
		$('#btn-show-1').click(function(){
	      //$(".cat-level-1").toggle("slow"); 
		});
		
		$('#btn-show-2').click(function(){
	      //ceck  if singel is shown
		  if($(".cat-level-single").is(':visible')){
		    $(".cat-level-single").toggle("slow"); 
		  }
		  $(".cat-level-service").toggle("slow"); 
		});
		
		$('#btn-show-3').click(function(){
		  $(".cat-level-10").toggle("slow"); 
		});
		
		$('#btn-show-4').click(function(){
		  //ceck  if service is shown
		  if($(".cat-level-service").is(':visible')){
		    $(".cat-level-service").toggle("slow"); 
		  }
	    
		$(".cat-level-single").toggle("slow"); 		       
});
	
			
	
		//Kontakt auf der rechten Seite
		var name_edit = true;
		var nr_edit = true;
		
		$('#call-service').click(function(){
		      $("#button-row").hide(); 
		      $('#hotline').css({'background' : 'url() bottom right no-repeat'});
		      $('#hotline-front').fadeOut('slow', function(){
		    	  $('#hotline-back').fadeIn('fast');
		      });
              return false;
			});
		 $('#clear').click(function(){
		    		 
		      $('#hotline-back').fadeOut('slow', function(){
		    	  $('#hotline-front').fadeIn('fast');
		    	  $('#hotline').css({'background' : 'url(./template/img/hotline-bg.png) bottom right no-repeat'});
		      });
		      $("#button-row").show(); 
            return false;
		 });
		 
		 $('#send').click(function(){
			 if ($('#hotline-name').val()=='' || $('#hotline-name').val()=='Name')
			 {
				 alert('Bitte geben Sie einen Name an');
				 return false;
			 }
			 if ($('#hotline-nr').val()=='' || $('#hotline-nr').val()=='Telefonnummer')
			 {
				 alert('Bitte geben Sie einen Telefonnummer an');
				 return false;
			 }
			 
			 $.ajax({ 
					url: "index.php?action=service_call", 
					type: "POST",
	                data: {
							name : $('#hotline-name').val(),
							nummer : $('#hotline-nr').val()		
						 },
					
					success: function(data){
	           		     $('#hotline-back').html(data);
	        			//$('#table').html('Load was performed.'+data);
	      		    }
			    });
				
				return false;
		 });
		 
		 $('#hotline-name').click(function(){
			if(name_edit)
			{
				$(this).val('');
				name_edit = false;
			}
		 });
		 $('#hotline-nr').click(function(){
			 if(nr_edit)
			 {
				 $(this).val('');
				 nr_edit = false;
			 }
		 });
});

