var liWidth = 0;
/* simp styles */
$(document).ready(function(){
	$("#menu ul").first().each(function(){
		$("li.top", this).each(function(){
			liWidth += $(this).width() + 8;
		});
		liWidth += 5;
		$(this).css({'width': liWidth + 'px'});
	});
	$("a[rel^='pp']").prettyPhoto();
	/*
	$("#menu > li").each(function (i){
		if($(this).has("ul").html()){
			if($(this).hasClass("cm")){
				$(this).html('<span>-</span>'+$(this).html());
			} else {
				$("#menu li[!.cm] > ul").addClass("d_none");
				$(this).html('<span>\+</span>'+$(this).html());
			}
		}
	});
	$("#menu span").click(function(){
		var li = $(this).parent();
		li.parent().find("li.cm").removeClass("cm");

		if($(this).html()!='-'){
			li.parent().find("ul").slideUp(600);
			li.parent().find("span").html("+");
			li.find("ul:first").slideDown(600);
			$(this).html("-");
		} else {
			$(this).parent().find("ul").slideUp("slow");
			$(this).parent().find("span").html("+");
			$(this).html("+");
		}
	});*/
	$("#menu ul li").hover(
		function(){
			if($('ul', this).length > 0){
				$("ul", this).each(function(){/*
					if($('#header').length > 0){*/
						var shift = 61;/*
					}else{
						var shift = 61;
					}*/
					var offsetLeft = $(this).parent().position().left + 2;//- shift;
					var ulWidth = $(this).width();
					var parentWidth = $(this).parent().width();
					if(offsetLeft + ulWidth > $(window).width())
						offsetLeft -= (ulWidth - parentWidth + 20);
					$(this).css({
						left: offsetLeft
					});
					$(this).show();
				});
				$(".top", this).css({
					'border-bottom-width': '2px',
					'border-bottom-style': 'solid',
					'border-bottom-color': '#FDFCF9'
				});
			}
			$(".top", this).css({
				'background-color': '#FDFCF9',
				'color': '#6F2E2C'
			});
		}
	,
		function(){
			$("ul", this).hide();/*
			$(this).css({'border-bottom': 0});*/
			$(".top", this).removeAttr('style');
		}
	);
	$("#menu li ul").hover(
		function(){
			$(this).show();
		}/*,
		function(){
			$("a.top, b", $(this).parent()).css({
				'background-color': '6F2E2C'
			});
		}*/
	);
});

$(window).load(function(){/*
	$("#menu ul").first().each(function(){
		$("li.top", this).each(function(){
			liWidth += $(this).width() + 8;
		});
		liWidth += 5;
		//alert(liWidth);
		$(this).css({'width': liWidth + 'px'});
	});*/
});

