$(document).ready(function(){
  $("div.menu-wrapper:not(#ingatlankeresok)").hide();
  $("#ingatlankeresok_header").attr('className', 'ymenu-header');
  


  $("div.menu-header-closed a").hover(function() {
		 if ($(this).parent().attr("className") == "menu-header-closed") $(this).parent().attr("className", "menu-header-closed-over");
   },function(){
   		if ($(this).parent().attr("className") == "menu-header-closed-over") $(this).parent().attr("className", "menu-header-closed");
   		return false;
   });

  $("div.ymenu-header-closed a").hover(function() {
		 if ($(this).parent().attr("className") == "ymenu-header-closed") $(this).parent().attr("className", "ymenu-header-closed-over");
   },function(){
   		if ($(this).parent().attr("className") == "ymenu-header-closed-over") $(this).parent().attr("className", "ymenu-header-closed");
   		return false;
   });

  $("div.menu-header-static a").hover(function() {
		 if ($(this).parent().attr("className") == "menu-header-static") $(this).parent().attr("className", "menu-header-static-over");
   },function(){
   		if ($(this).parent().attr("className") == "menu-header-static-over") $(this).parent().attr("className", "menu-header-static");
   		return false;
   });

  $("div.ymenu-header-static a").hover(function() {
		 if ($(this).parent().attr("className") == "ymenu-header-static") $(this).parent().attr("className", "ymenu-header-static-over");
   },function(){
   		if ($(this).parent().attr("className") == "ymenu-header-static-over") $(this).parent().attr("className", "ymenu-header-static");
   		return false;
   });

  $("div.hmenu-header-static a").hover(function() {
		 if ($(this).parent().attr("className") == "hmenu-header-static") $(this).parent().attr("className", "hmenu-header-static-over");
   },function(){
   		if ($(this).parent().attr("className") == "hmenu-header-static-over") $(this).parent().attr("className", "hmenu-header-static");
   		return false;
   });

  $("div.rmenu-header-static a").hover(function() {
		 if ($(this).parent().attr("className") == "rmenu-header-static") $(this).parent().attr("className", "rmenu-header-static-over");
   },function(){
   		if ($(this).parent().attr("className") == "rmenu-header-static-over") $(this).parent().attr("className", "rmenu-header-static");
   		return false;
   });


  /*
  $("div.menu-header-closed a").toggle(function() {
		$(this).parent().parent().find("div.menu-wrapper:first").slideDown("slow");
		$(this).parent().attr("className","menu-header");
		return false;
   },function(){
   		$(this).parent().parent().find("div.menu-wrapper:first").slideUp("slow", function() {
   				$(this).parent().find("div:first").attr("className","menu-header-closed-over");
   			});
   		return false;
   });
   */

  $("div.menu-header-closed a").click(function() {
  		if ($(this).parent().parent().find("div.menu-wrapper").is(':visible')) {
			$(this).parent().parent().find("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed-over");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed-over");
				});
  		} else {
			$("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed");
				});
			$(this).parent().parent().find("div.menu-wrapper").slideDown("slow");
			$(this).parent().attr("className","menu-header");
		}
		return false;
   });


  $("#ingatlankeresok_header a").click(function() {
  		if ($(this).parent().parent().find("div.menu-wrapper").is(':visible')) {
			$(this).parent().parent().find("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed-over");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed-over");
				});
  		} else {
			$("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed");
				});
			$(this).parent().parent().find("div.menu-wrapper").slideDown("slow");
			$(this).parent().attr("className","ymenu-header");
		}
		return false;
   });


  $("div.ymenu-header-closed a").click(function() {
  		if ($(this).parent().parent().find("div.menu-wrapper").is(':visible')) {
			$(this).parent().parent().find("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed-over");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed-over");
				});
  		} else {
			$("div.menu-wrapper").slideUp("slow", function() {
					if ($(this).parent().find("div:first").attr("className") == "ymenu-header")
						$(this).parent().find("div:first").attr("className","ymenu-header-closed");
					if ($(this).parent().find("div:first").attr("className") == "menu-header")
						$(this).parent().find("div:first").attr("className","menu-header-closed");
				});
			$(this).parent().parent().find("div.menu-wrapper").slideDown("slow");
			$(this).parent().attr("className","ymenu-header");
		}
		return false;
   });

    
  var loc = document.location.pathname;
  obj = $('#menu-container a[@href$="' + loc + '"]');
  if (obj.attr('id') != null) {
    if (obj.parent().attr('class').search('static') == -1) {
	if (obj.parent().parent().parent().parent().parent().find("div:first").attr('id') == 'ingatlankeresok_header') {
	    var item_clsn = obj.parent().attr('class');
	    obj.parent().attr('className', item_clsn + '-selected');
	} else {
	obj.parent().parent().parent().parent().show();
	$("#ingatlankeresok").hide();
	$("#ingatlankeresok_header").attr('className', 'ymenu-header-closed');
	var item_clsn = obj.parent().attr('class');
	var wr_obj = obj.parent().parent().parent().parent().parent().find("div:first");
	var menu_clsn = wr_obj.attr('class');
	var clsn_parts = menu_clsn.split('-');
	obj.parent().attr('className', item_clsn + '-selected');
	wr_obj.attr('className', clsn_parts[0] + '-header')
	}
     }
  }
  

  var loc = document.location.pathname;
  obj = $('#mwin a[@href$="' + loc + '"]');
  if (obj.attr('id') != null) {
    //alert(obj.attr('className'));
    obj.css('font-weight', 'bold');
    obj.css('color', '#c00404');
  }


  var winHeight = $(window).height();
  var docHeight = $(document.body).height();
  if (winHeight > docHeight) {    
  if ($("#mcont").height() < winHeight)  $("#mcont").css('height', winHeight - 95);
  } else {
  if ($("#mcont").height() < docHeight)  $("#mcont").css('height', docHeight - 95);
  }


});