var men = 0;
var submenu = 0;
var timeoutID='';

$(document).ready(function() {
	//var hashes = window.location.href;
	//var elems=hashes.split('#');
	//alert(elems[1]);
	
	$('.license a.butlicense').each(function(index) {
		$(this).click(function() {
		 $('#boxlicense .detailtext').css("display","none");
		 $("#" + $(this).attr("id").replace('but_','')).css("display","block");
		});
	  });
	$('.rental a.butrental').each(function(index) {
		$(this).click(function() {
		 $('#boxrental .detailtext').css("display","none");
		 $("#" + $(this).attr("id").replace('but_','')).css("display","block");
		});
	  });


	var fullsize = function() {
		//alert("win "+$(window).height());   // returns width of browser viewport
		//alert("doc "+$(document).height()); // returns width of HTML document
		var x = $(window).width();
		var y = $(window).height();
		
		var width  = $('#bg_img').attr('width');
		var height = $('#bg_img').attr('height');

		var over = width / height;
		var under = height / width;
	
		$('#bg_img').width(x);
		$('#bg_img').height(y);
	
		if((x / y) >= over) {
			$('#bg_img').width(x);
			$('#bg_img').height(under*x);
		} else {
			$('#bg_img').width(over*y);
			$('#bg_img').height(y);
		}
		if(y < 800) y = 800;
		$("#scale").css("height",y+"px");
	}
	
	function refigure() {
		fullsize();
		if(jQuery.browser) setTimeout(fullsize,50);
	}
	
	jQuery.event.add(window, "load", refigure);
	jQuery.event.add(window, "resize", refigure);


	refigure();
	
	$('#menubar').css("height","40px")
			     .css("opacity","1")
				 .css("z-index","2");
	$('ul.menulist li a').css("opacity","0.6");
	//$('#menubar').animate({shadow: '0 0 30px #000000'}); 
	$('#content').css("top", "-300px");
	$('#content').animate({top: '50px'},1600); 
	//$('#content').animate({shadow: '0 0 30px #000000'}); 

	$('#menubar').mouseover(function() {
		$(this).children('.menulist').animate({"top": "0px"},100);
		$(this).children('.rightmenulist').animate({"top": "50px"},100);
		$(this).animate({"height": "130px","top": "-30px"}, 100);
		$(this).css("z-index","900");
		submenu = 1;
	});
	
	$('#menubar').mouseout(function() {
		submenu = 0;
		timeoutID = setTimeout('close_menu_bar()', 200);
		
	});

	$('ul.menulist').mouseout(function(index) {
		submenu = 1;
	});
	
	$('ul.menulist').mouseover(function(index) {
		submenu = 1;
	});
	
	$('ul.menulist li a').mouseover(function(index) {
		$(this).animate({"opacity": "1"}, 200);
	});
	$('ul.menulist li a').mouseout(function(index) {
		$(this).animate({"opacity": "0.6"}, 200);
	});

});	


function close_menu_bar()
	{
		if( submenu == 0){
			$('#menubar').children('.menulist').animate({"top": "-45px"},100);
			$('#menubar').children('.rightmenulist').animate({"top": "12px"},100);
			$('#menubar').animate({"height": "40px","top": "0px"}, 100);
			$('#menubar').css("z-index","2");
			submenu = 0;
		}
	}
