$(document).ready(function(){
	$('#cat').hover(function(){
		$('#submenu').slideDown();	
		if($('#submenu').css('display') != 'none') {
			$('#submenu').fadeTo('fast', 0.8);
		}
		return false;
	}, function(){
		//$('#submenu').hide();
	});
  $('#submenu').mouseleave(function(){
    $(this).hide();
  });
  
	$('#on').hover(function(){
		$('#on').hasClass('on-b') ? $('#on').css('background-position','right bottom') :$('#on').css('background-position','left bottom');
													},
	function(){
		$('#on').hasClass('on-b') ? $('#on').css('background-position','right top') :$('#on').css('background-position','left top');
	});

	$('#on').toggle(function() {
		$('#on').css('background-position','right top');		
		$('#intro').css('background-position','bottom');	
		$('#logo').css('background-position','bottom');	
		$('#dilers').css('background-position','bottom');	
		$('#dostavka').css('background-position','bottom');
		$('body').css('background','#000');	
		$('#phone').css('color','#ffffff');
		$('#on').addClass('on-b');
		return false;

	},
	function() {
		$('#on').css('background-position','left top');
		$('#intro').css('background-position','top');	
		$('#logo').css('background-position','top');
		$('#dilers').css('background-position','top');	
		$('#dostavka').css('background-position','top');
		$('body').css('background','#fff');	
		$('#phone').css('color','#333');
		$('#on').removeClass();
		return false;
	});
	 if($.browser.msie){
			var offset = $('#cat').position();
			$('#submenu').css('left', (offset.left-30)+'px');
			$('#submenu').css('top', (offset.top+18)+'px');
	 }
	 $('#prop').click(function() {
      $("#info").remove();
			var fn = $(this).attr("href").substr(0,6) + "_tech.gif";
			//var fnhtm = $(this).attr("href").substr(0,6) + ".html";
			var dir = '';
			var img = $(this).parent().next().children().eq(0);
			var s = img.attr("src").indexOf('/')+1;
			var n = img.attr("src").indexOf('.') - s;
			var fnhtm = img.attr("src").substr(s,n) + ".html";
			if (img.attr("src").charAt(0) == "b") {
				dir = "besedka/";
			} else {dir = "naves/"}
			var w = img.width();
			var h = img.height();//background: #000 url("+ dir + fn +") no-repeat center center;
			$("body").append("<div id='info'> </div>");
			//$("#info").width(w);
			//$("#info").height(h);
			var offset = img.offset();
			$("#info").css("left", offset.left);
			$("#info").css("top", offset.top);
			$("#info").load(dir+fnhtm, "11!", function (responseText, textStatus, XMLHttpRequest) {$("#info br").remove();$("#info img").before("<br />");$("#info").append("<div id='close'> </div>");$("#close").click(function(){$("#info").remove();})});//$("#close").css("top", offset.top + "px");
			$("#info").fadeTo("slow", .80);
			return false;
	});
});

