// JavaScript Document
$(document).ready(function()
{

if ($.browser.opera) {
	$("#menu li").css("list-style-image","url('/images/xb/images/o_li_arr_b.png')")
	$("#menu li.active").css("list-style-image","url('/images/xb/images/o_li_arr_w.png')")
		$("#menu li").hover(
		function(){
			$(this).css("list-style-image","url('/images/xb/images/o_li_arr_w.png')")		
		},function(){
			$(this).css("list-style-image","url('/images/xb/images/o_li_arr_b.png')")
		}
		)
 }
 items = $(".items")
 
	//if (items.length)
	//	setInterval(function(){			
	//	           init()							
	//	},500)
	if (items.length)
	//	setInterval(function(){			
		           init()							
	//	},500)
	
	$("#menu ul").each(function() { $(this).width(($("#menu").width()-3)/4)})	
	$("#content .items .item").each(function() { $(this).width(($("#content").width()-4)/3)})


	$(window).resize(function() {
		$("#menu ul").each(function() { $(this).width(($("#menu").width()-3)/4)})	
		$("#content .items .item").each(function() { $(this).width(($("#content").width()-4)/3)})
		if (items.length) init()
	})
	
	
	$("#main_menu #top_menu").corner("10px top")
	$("#main_menu #bottom_menu li a:last").css("border","0")
	$("#menu ul:last").css("border","0")
	
	$max = 0;	
	$("#menu ul").each(function() { $max = Math.max($(this).height(), $max)})
	$("#menu ul").each(function() { $(this).height($max)})
	if ($("#menu #news"))
		{
			$max = Math.max($("#menu #news").height(), $max)
		}
	$("#menu").height($max+10)
	
	
$("#content #description .head").corner("5px")

$("#gray_block").corner("bevel br 15px")

})

function init() {

	
$("#content .items .item ").css("float","left")
$("#content .items").find(".item:lt(3)").css("border-top","1px #ccc solid")

if (!$.browser.msie){
$("#content .items").find(".item:eq(0)").corner("5px tl")
$("#content .items").find(".head:eq(0)").corner("5px tl")

$("#content .items").find(".item:eq(2)").corner("5px tr")
$("#content .items").find(".head:eq(2)").corner("5px tr")
}

$(".items").find(".item").each(function() {$(this).css("height", $(this).find(".head").height()+$(this).find(".item_content").height()+50) })

$top = $(".items .item:first").offset()["top"];
$max = 0;
var $items = [];

$(".items").find(".item").each(function() { 

next = $(this).next();
if (!next[0])
	$items.push($(this));		

	if ($(this).offset()["top"] == $top && next[0])
		{
			$items.push($(this));
		}
		else {					
			for(var i = 0; i < $items.length; i++) {
				$max = Math.max($max, $items[i].height())
			}			
			for(var i = 0; i < $items.length; i++)
				$items[i].height($max)
				
			$max = 0;
			
			if ($items[1])
				$items[1].css({"border-left":0, "border-right":0})
				
			
			$top = $(this).offset()["top"]
			
			$items = []
			$items.push($(this));
			}
	})
$(".items").find(".item:last").css({"border-right": "1px solid #CCCCCC"})

}
