var lastList
/***/

/***/
function showSubmenu(obj) {
	var oldMouseOver = obj.onmouseover
	//obj.onmouseover = function() {}

	var arrEle = []
	var list = obj.parentNode.getElementsByTagName('ul');
	list = list[0]
	if(!list) {
		return;
	}
	if(lastList) {
		clearInterval(lastList.iv)
		lastList.style.display = 'none';
	}
	lastList = list
	var i = -1;
	//if(document.all) {
		list.style.display = 'block';
	//}

	//obj.onmouseover = oldMouseOver
	obj.onmouseout = function () {
		var dontClose = false
		var ele = list.getElementsByTagName('li');
		var n = -1
		while(++n < ele.length) {
			ele[n].onmouseover = function() {
				dontClose = true
			}
			ele[n].onmouseout = function() {
				dontClose = false
				clearInterval(list.iv);
				list.iv = setInterval(function(){
					if(!dontClose) {
						clearInterval(list.iv);
						list.style.display = 'none';
					}
				}, 400)
			}
		}

		list.iv = setInterval(function(){
			if(!dontClose) {
				clearInterval(list.iv);
				list.style.display = 'none';
			}
		}, 400)
	}
}
function closeList(list) {
	clearInterval(list.iv);
	list.isOpen = false
	list.style.display = 'none';
}


var orgBoxHeight = 0
function resizeBody($) {
	var headHeight = $('#main-head').outerHeight()
	var bodyHeight = $(window).height() - headHeight-2

	$('#main-body').css('height',bodyHeight)
	$('#main-body div.scrollable').css('height',bodyHeight)
	$('#main-body div#leftColumn').css('height',bodyHeight)
	$('#main-body div#leftColumn').css('overflow','hidden')

	var smHeight = $('#main-body div#leftColumn #sub-menu').outerHeight();

	if(!orgBoxHeight) {
	orgBoxHeight = smHeight
	}

	var cmHeight = $('#main-body div#leftColumn .content-context-box').outerHeight();

	var boxHeight = smHeight;
	boxHeight += cmHeight

//alert(':'+smHeight +','+ cmHeight)
	if(boxHeight>bodyHeight || (smHeight < orgBoxHeight)) {
		var space = boxHeight-bodyHeight;
		var nHeight = (smHeight-space) - $('#main-body div#leftColumn #sub-menu').css('paddingTop').replace('px','')
//		var smHeight = $('#main-body div#leftColumn #sub-menu').outerHeight();
		$('#main-body div#leftColumn #sub-menu').css('height', ''+nHeight+'px')
	} else {
		var nHeight = (orgBoxHeight) - $('#main-body div#leftColumn #sub-menu').css('paddingTop').replace('px','')
		$('#main-body div#leftColumn #sub-menu').css('height', ''+nHeight+'px')
	}
}
var iv = null
function slideSwitch() {
		var $ = jQuery
    var $active = $('#slideshow img.active');
    if ( $active.length == 0 ) $active = $('#slideshow img');

		if(!$active.next().length) {
		//	clearInterval(iv)
			//return
		}
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, 'easeOutBack', function() {
            $active.removeClass('active last-active');
        });

}
jQuery(function($) {
	iv = setInterval( "slideSwitch()", 5000 );

	resizeBody($)
	$(window).resize(function(){
  	resizeBody($)
	});
})


