function adjustContainer(type)
{
	var height_main_content = document.getElementById("main_content").offsetHeight;
	var height_sub_navigation = document.getElementById("sub_navigation").offsetHeight;
	var windowHeight = window.innerHeight;

	if(type == "total"){
		document.getElementById("sub_navigation").style.height = (windowHeight+100)+"px";
		document.getElementById("main_content").style.height = (windowHeight+100)+"px";
	}
	
	else if(type ="relate"){
		//document.getElementById("sub_navigation").style.height = (height_main_content-12)+"px";
		
		if (height_main_content > height_sub_navigation)
		{
			document.getElementById("sub_navigation").style.height = (height_main_content-12)+"px";
			//alert ("sub_navigation wurde angepasst von "+height_sub_navigation+" auf "+(height_main_content-12));
		}
		else
		{
			document.getElementById("main_content").style.height = (height_sub_navigation-12)+"px";
			//alert ("main_content wurde angepasst von "+height_main_content+" auf "+(height_sub_navigation-12));
		}
	}
}

function createTitleTag(){
	var oldTitle = document.getElementsByTagName('title')[0].text;
	var newTitle = document.getElementById('main_title').innerHTML+" | "+oldTitle;
	document.getElementsByTagName('title')[0].text = newTitle;
}

function showElement (elementName) {
  if (document.getElementById)
    document.getElementById(elementName).style.visibility = "visible";
}

function hideElement (elementName) {
  if (document.getElementById)
    document.getElementById(elementName).style.visibility = "collapse";
}


function showDateTime() {
	var act = new Date();

	var hours= act.getHours();
	if  (hours <10) {hours="0"+hours;}
	
	var minutes= act.getMinutes();
	if  (minutes <10) {minutes="0"+minutes;}
	
	/*var seconds= act.getSeconds();
	if  (seconds <10) {seconds="0"+seconds;}
	var ms= act.getMilliseconds();
	if  (ms <1000) {ms="0"+ms;}*/

	var day = act.getDate();
	if  (day <10) {day="0"+day;}
	
	var month = act.getMonth()+1;
	if  (month <10) {month="0"+month;}
	
	var year = act.getFullYear();

	document.getElementById("time_container").innerHTML = hours+":"+minutes;
	document.getElementById("date_container").innerHTML = day+"."+month+"."+year;
	
	window.setTimeout('showDateTime()', 500);
}

function detectBrowser(){
	var browserString;
	var browser=navigator.userAgent;
	//var b_version=navigator.appVersion;
	//var version=parseFloat(b_version);
	
	if(browser.match("Firefox")){ browserString ="Firefox";}
	if(browser.match("MSIE")){ browserString ="InternetExplorer";}
	if(browser.match("Chrome")){ browserString ="Chrome";}
	if(browser.match("Opera")){ browserString ="Opera";}
	
	return browserString;
}

/*
 * imgPreview jQuery plugin
 * Copyright (c) 2009 James Padolsey
 * j@qd9.co.uk | http://james.padolsey.com
 * Dual licensed under MIT and GPL.
 * Updated: 09/02/09
 * @author James Padolsey
 * @version 0.22
 */
(function($){
    
    $.expr[':'].linkingToImage = function(elem, index, match){
        // This will return true if the specified attribute contains a valid link to an image:
        return !! ($(elem).attr(match[3]) && $(elem).attr(match[3]).match(/\.(gif|jpe?g|png|bmp)$/i));
    };
    
    $.fn.imgPreview = function(userDefinedSettings){
        
        var s = $.extend({
            
            /* DEFAULTS */
            
            // CSS to be applied to image:
            imgCSS: {},
            // Distance between cursor and preview:
            distanceFromCursor: {top:10, left:10},
            // Boolean, whether or not to preload images:
            preloadImages: true,
            // Callback: run when link is hovered: container is shown:
            onShow: function(){},
            // Callback: container is hidden:
            onHide: function(){},
            // Callback: Run when image within container has loaded:
            onLoad: function(){},
            // ID to give to container (for CSS styling):
            containerID: 'imgPreviewContainer',
            // Class to be given to container while image is loading:
            containerLoadingClass: 'loading',
            // Prefix (if using thumbnails), e.g. 'thumb_'
            thumbPrefix: '',
            // Where to retrieve the image from:
            srcAttr: 'href'
            
        }, userDefinedSettings),
        
        $container = $('<div/>').attr('id', s.containerID)
                        .append('<img/>').hide()
                        .css('position','absolute')
                        .appendTo('body'),
            
        $img = $('img', $container).css(s.imgCSS),
        
        // Get all valid elements (linking to images / ATTR with image link):
        $collection = this.filter(':linkingToImage(' + s.srcAttr + ')');
        
        // Re-usable means to add prefix (from setting):
        function addPrefix(src) {
            return src.replace(/(\/?)([^\/]+)$/,'$1' + s.thumbPrefix + '$2');
        }
        
        if (s.preloadImages) {
            (function(i){
                var tempIMG = new Image(),
                    callee = arguments.callee;
                tempIMG.src = addPrefix($($collection[i]).attr(s.srcAttr));
                tempIMG.onload = function(){
                    $collection[i + 1] && callee(i + 1);
                };
            })(0);
        }
        
        $collection
            .mousemove(function(e){
                
                $container.css({
                    top: e.pageY + s.distanceFromCursor.top + 'px',
                    left: e.pageX + s.distanceFromCursor.left + 'px'
                });
                
            })
            .hover(function(){
                
                var link = this;
                $container
                    .addClass(s.containerLoadingClass)
                    .show();
                $img
                    .load(function(){
                        $container.removeClass(s.containerLoadingClass);
                        $img.show();
                        s.onLoad.call($img[0], link);
                    })
                    .attr( 'src' , addPrefix($(link).attr(s.srcAttr)) );
                s.onShow.call($container[0], link);
                
            }, function(){
                
                $container.hide();
                $img.unbind('load').attr('src','').hide();
                s.onHide.call($container[0], this);
                
            });
        
        // Return full selection, not $collection!
        return this;
        
    };
    
})(jQuery);

