
var $j = jQuery.noConflict();
jQuery(document).ready(function() {
	jQuery('.datepicker2').datepicker({
		changeMonth: true,
		changeYear: true,
		yearRange: 'c-80:c'
	});
	jQuery('.smallGuest').click(function(){
		jQuery(this).css('display','none');
		jQuery(this).next().css('display','inline');
	});
	jQuery('.bigGuest').click(function(){
		jQuery(this).css('display','none');
		jQuery(this).prev().css('display','inline');
	});
	jQuery("#tree").treeview({
			collapsed: true,
			animated: "medium",
			control:"#sidetreecontrol"
	});
	
	jQuery("#main-menu ul li.active, div.he2 h2, div.post input[type=button], .menu_menu_1 ul li.active").each(function(){
		jQuery(this).css('behavior','url(img/pie.htc);');
	});
	
    jQuery('a.banner_stats').click(function(){
    	jQuery.post("../banner_stats.php",{rel : jQuery(this).attr('rel')},function(data) {
    		// nothing
    	});    
    });
	var exists = false;
	jQuery('.menu_menu_1 ul li').mouseover(function(){
		exists = true;
		if(!jQuery(this).hasClass('active')){
			exists = false;
			jQuery(this).addClass('active');
		}
	}).mouseout(function(){
		if(exists==false)
			jQuery(this).removeClass('active');
	});
	$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);
		});
	});

});
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();
	      }
	    });
	  }
	}
        
