jQuery.noConflict();

jQuery(document).ready(function() {
	var pageUrl = location.href;
	var parms = pageUrl.split("/");
	var $ul;
	jQuery('#divLeft ul').each(function(){
		if (jQuery(this).children('li').html()=='Struktura Organizacyjna')
			$ul = jQuery(this);
	})
	$ul.children('li').each(function(){
		var $li = jQuery(this);
		$li.children('ul').css('display','none');
		jQuery('<a class="down" onclick="rozwin(this);" href="javascript:void(null);" style="float:left;padding-right:3px;">+</a>').insertBefore($li.children('a'));
	});
	$ul.find('a').each(function(){
		var $a = jQuery(this);
		if($a.attr('href').toLowerCase()=='/'+parms[parms.length-1].toLowerCase()) {	
			var obj = $a.parent();
			while (obj.html()!=null) {
				var oHtml = obj.html();
				var index1 = oHtml.indexOf('<');
				var index2 = oHtml.indexOf(' ',index1);
				var objTag = oHtml.slice(index1+1,index2).toLowerCase();
				if(objTag!='div') {
					obj.css('display','block');
					if(objTag=='a'){
						obj.children('ul').css('display','block');
						obj.children('a.down').html('-');
					}
					obj = obj.parent();
				}
				else {
					break;
				}
			}
		}
	});
});

function rozwin(obj){
	var $ul;
	jQuery('#divLeft ul').each(function(){
		if (jQuery(this).children('li').html()=='Struktura Organizacyjna')
			$ul = jQuery(this);
	})
	$ul.children('li').each(function(){
		var $li = jQuery(this);
		$li.children('ul').css('display','none');
	});
	jQuery('a.down').html('+');
	jQuery(obj).html('-');
	jQuery(obj).parent().children('ul').css('display','block');
}
