$(document).ready(function(){
	var $nav = $("#nav"),
		navWidth = $nav.width();
	
	$nav.find("li.listItem01").each(function(i){
											 
		$(this).css({position:'relative'});
		
		var count = $(this).find("li.listItem00, li.active01").length,
			width = (210*count) + 58,
			middleWidth = width/2-95,
			tabDist = i*210;
	
		$(this).find("div.drop").each(function(){
			var $this = $(this);
			$this.css({width: width + 'px', right: -middleWidth + 'px'});
			$this.find("div.t div.middle, div.b div.middle").css({width: (width-27) + 'px'});
			$this.find("div.c").height();
					
			if(middleWidth > tabDist){
				$this.css({left:'0'});
				$this.parent().css({position:'static'});
			}
			if(tabDist + middleWidth > (navWidth-210)){
				$this.css({right:'0'});
				$this.parent().css({position:'static'});
			}
		});
		
		$(this).hover(
			function(){
				$(this).addClass('hover').find('div.drop').css('display','block');
				if($.browser.msie && parseInt($.browser.version) < 7) $(this).find("div.c div.right_ie").height($(this).find("div.c").height());
			},
			function(){
				$(this).removeClass('hover').find('div.drop').css('display','none');
			}
		);
		
	});
});

//IE6 
var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand; 
try {if(!!m) {m("BackgroundImageCache", false, true);}}catch(e) {};

(function($) {

	$(function(){
		
		//tabs
		if ($.fn.tabs) {
			$('div.tabs').tabs({
				tabs: 'ul.control',
				node: 'div.tabContent',
				selected: 'selected'
			});
		};
	});

})(jQuery);


function popwin(url, width, height){
	var _width = screen.availWidth; 
	var _height = screen.availHeight; 
	var centered_width = 0;
	var centered_height = 0;	
	if (_width > width) centered_width = (_width - width) / 2;
	if (_height > height) centered_height = (_height - height) / 2;
	viewer = window.open(url,"viewer","top=" + centered_height + ",left=" + centered_width + ",status=yes,scrollbars=yes,menubar=no,resizable=yes,width=" + width + ",height=" + height);
	viewer.focus();
	return false;
}
