$(document).ready(function ()
{
	/* made by css
	  $(".hidden-related-box-content").hide();
	*/
	
	$("#RelatedNav li a").click(function(){
		$("#RelatedNav li a").removeClass("active");
		var selectString=$(this).attr("href");
		$(".hidden-related-box-content").hide();
		$(selectString).show();
		$(this).addClass("active");
		return false;
	});
	
	/* made by css
	var oActiveTab = $("#RelatedNav li a.active");
	var selectString = oActiveTab.attr("href");
	$(selectString).show();
	*/
							
	$('.col-02').hover(
		function()
		{
			$(this).css({ 'z-index':20 });
		},
		function()
		{
			$(this).css({ 'z-index':0 });
		}
	);
	
	highlighting.init();
	
	foldable.init();
	
	expandable.init();

	viewable.init();
});

var currentFormElem = null;
var showHideValue = function(obj,val)
{
	if (obj != currentFormElem)
	{
		currentFormElem = obj;
		if (obj.value == val)
			obj.value = '';
			
		obj.onblur = function()
		{
			showHideValue(obj,val);
		}
	}
	else
	{
		if (obj.value == '')
			obj.value = val;
		
		obj.onblur = null;
		
		currentFormElem = null;
	}
};

var highlighting = {
	
	iMaxWidth : 0,
	
	iLineCount : 0,
	
	init : function() {
		
		$('.entry-box-text pre ol li').hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});		
		
		$('.entry-box-text pre').hover(function() {
			highlighting.iMaxWidth = 0;
			highlighting.iLineCount = 0;
			$(this).find('li').each(function()
			{
				$(this).css({ position : 'absolute' });
				highlighting.iMaxWidth = $(this).width() > highlighting.iMaxWidth ? $(this).width() : highlighting.iMaxWidth;
				$(this).css({ position : 'static' });
				
				if (document.all && !window.opera && !window.XMLHttpRequest)
				{
					highlighting.iLineCount += 1;
					$(this).attr('value',highlighting.iLineCount);
				}
			});
			
			if (highlighting.iMaxWidth <= 760)
			{
				highlighting.iMaxWidth = 760;
			}
			
			$(this).find('li').css('width', highlighting.iMaxWidth + 'px');
			$(this).css('width', '797px');
			$(this).children('ol').css('width', '767px');
			
			if (highlighting.iMaxWidth > 760)
			{
				$(this).children('ol').css('overflow-x', 'scroll');
			}
			
		}, function() {
			$(this).children('ol').css('width', '410px');
			$(this).children('ol').css('overflow-x', 'hidden');
			if (document.all && !window.opera && !window.XMLHttpRequest)
			{
				$(this).css('width', '440px');
			}
			else
			{
				$(this).css('width', 'auto');
			}
			$(this).find('li').removeClass('hover');
		})
		
		
	}
	
}


var foldable = {
	
	
	init : function() {
		
		$('dl.foldable dt').click(function() {
			
			$oContainer = $(this).next();
			
			if($oContainer.is(':visible')) {
				$(this).removeClass('hover');
				$oContainer.css('display', 'none');
			}
			else {
				$(this).addClass('hover');
				$oContainer.css('display', 'block');
			}
			
			$(this).parent().children('dt').not(this).removeClass('hover');
			$(this).parent().children('dd').not($oContainer).css('display', 'none');
			
		});	
		
	}
	
}


var expandable = {
	
	
	init : function() {
		
		$('label.pre-filename').click(function() {
			
			$oCode = $(this).next('pre');
			
			sNewDisplay = ($oCode.is(':visible')) ? 'none' : 'block';
			
			$oCode.css('display', sNewDisplay);
			
		});
		
	}
	
}

var viewable = {
	
	init: function() {
		
		$('a.code-plain').click(function() {
			
			$oPre = $(this).parent('pre');
			
			if($(this).attr('rel') != 'plain') {
			
				_trigger = this;
				
				$(this).attr('rel','plain');
				
				if($oPre.children('div.plain-code').length < 1) {
					
					$(this).css('background-image','url(/src/img/structure/ico/pre-loading.gif)');
					
					$.ajax({
						url: $(_trigger).attr('href'),
						cache: false,
						success: function(html){
						  
						  $oPre.children('ol').css('display', 'none');
						  $oPre.append('<div class="plain-code">'+html+'</div>');
						  $(_trigger).css('background-image','url(/src/img/structure/ico/plain.png)').attr('title', 'Syntax highlighting einschalten');
						  
						}
					});
				}
				else {
					$oPre.children('ol').css('display', 'none');
					$oPre.children('div.plain-code').css('display', 'block');
				}
			
			}
			else {
				
				$(this).attr('rel','');
				$oPre.children('div.plain-code').css('display','none');
				$oPre.children('ol').css('display', 'block');
				
			}
			
			return false;
		})
		
	}
	
}

