
var $j = jQuery.noConflict();
jQuery(document).ready(function() {
	
	$j("img.a").hover(
		function() {
		$j(this).stop().animate({"opacity": "0"}, "slow");
		},
		function() {
		$j(this).stop().animate({"opacity": "1"}, "slow");
		});
	
	$j('a[href=#top]').click(function(){
        $j('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

	jQuery("#tree").treeview({
			collapsed: true,
			animated: "medium",
			control:"#sidetreecontrol"
	});


	$j('ul#mainmenu li.parent').each(function(){
		$j(this).mouseenter(function(){
			ShowMenu($j(this).find('ul.sub_menu'),250,true);
		}).mouseleave(function(){
			ShowMenu($j(this).find('ul.sub_menu'),250,false);
		});
	});
	$j('ul.sub_menu li.subparent').each(function(){
		$j(this).mouseenter(function(){
			ShowMenu($j(this).find('ul.sub_sub_menu'),250,true);
		}).mouseleave(function(){
			ShowMenu($j(this).find('ul.sub_sub_menu'),250,false);
		});
	});
	
	setTimeout('setDivHeight();','200');
});

var curHeight;
function setDivHeight() {
	jQuery('div.novisites_wrapper div.novisites_p4').each(function() {
		curHeight = jQuery(this).height();
		if (curHeight != 0) {
			curHeight+=35;
			jQuery(this).find('.novisites_col3').each(function(){
				jQuery(this).css('height', curHeight + 'px');
			});
		}
	});
}

function ShowMenu(el,duration,dir){
	var $el = $j(el);
	xx = $el.attr('id');
	yy = xx.split('_');
	height = yy[1];
	if(dir){
		$el.show().stop().animate({height: height}, {duration: duration,complete:function(){
				$el.css({'visibility':'visible','width':'auto'});
			}
		});
	}else{
		$el.stop().animate({height: 0}, {duration: duration, complete:function (){
	        $el.hide();
	      }
	    });
	}
}

function slideToggle(el, bShow){
	var $jel = $j(el), height = $jel.data("originalHeight"), visible = $jel.is(":visible");

	// if the bShow isn't present, get the current visibility and reverse it
	if( arguments.length == 1 ) bShow = !visible;

	// if the current visiblilty is the same as the requested state, cancel
	if( bShow == visible ) return false;

	//alert(height);
	//height = $jel.innerHeight();
	// get the original height
	if( !height ){
		// get original height
		height = $jel.show().height();
		// update the height
		$jel.data("originalHeight", height);
		// if the element was hidden, hide it again
		if( !visible ) $jel.hide().css({height: 0});
	  }

	  // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
	  if( bShow ){
	    $jel.show().animate({height: height}, {duration: 400});
	  } else {
	    $jel.animate({height: 0}, {duration: 400, complete:function (){
	        $jel.hide();
	      }
	    });
	  }
	}
        
