window.onload = init;

function init() {
	document.getElementById("search").onfocus = function() { this.value=""; };
	
	/*var elements= document.getElementsByTagName("img");
	for(var i=0;i<elements.length;i++) {
		if(elements[i].className.match("arrow")) {
			var element= elements[i];
			elements[i].onmouseover= clapTree;
		}
	}*/
	
    //set $ to JQuery for this function
    (function($) {
        $(".matrix .element, .matrixbig .element").hover(function() {
            if ($(this).children(".matrixbg").length == 0) {
                var el = $(this).children().children(".matrixbg");
                el.attr("oldSrc", el.attr("src"));
                el.attr("src", el.attr("src").replace(/.jpg/i, "_hover.jpg"));
            }
        }, function() {
            if ($(this).children(".matrixbg").length == 0) {
                var el = $(this).children().children(".matrixbg");
                el.attr("src", el.attr("oldSrc"));
            }
        });
    })(jQuery);    
	
	//show javascript menu
	if ($("standardmenu")) $("standardmenu").style.display = "none";
	if ($("alternativemenu")) $("alternativemenu").style.display = "block";
}

function showOverviewNavigation() {
	new Effect.Puff("alternativemenu");
	new Effect.Appear("standardmenu");
}

/*function clapTree() {
	resetTabs();
	alert(this.parentElement);
	if(this.parentElement.parentElement.className=="off") {
		this.parentElement.parentElement.className= "tempon";
		this.src= "_img/varrow.gif";
	} else if(this.parentElement.parentElement.className=="tempon") {
		this.parentElement.parentElement.className= "off";
		this.src= "_img/harrow.gif";
	}
}

function resetTabs() {
	var elements= document.getElementsByTagName("img");
	for(var i=0;i<elements.length;i++) {
		if(elements[i].className.match("arrow")) {
			if(elements[i].parentElement && elements[i].parentElement.parentElement && elements[i].parentElement.parentElement.className=="tempon") elements[i].parentElement.parentElement.className= "off";
			elements[i].src= "_img/harrow.gif";
		}
	}
}*/



function tab(tab, that) {
    if (!tab) return;

    var tabId = parseInt(tab.replace(/tab-/,'')); 
    var sep = $$("#tab .header .sep");

    $$("#tab .handler").invoke("removeClassName", "on");
    $$("#tab .tab").invoke("hide");
    sep.invoke("removeClassName", "left-on");    

    if (sep[tabId]) {
        sep[tabId].addClassName("left-on");
    }

    Element.extend(that);
    that.addClassName("on"); 

    $(tab).style.display = "block";

    (function($) {

   if(tab == 'tab-3') {
            $('#resultArea').show();
             //set height for both tabels .labels / .contents
        for (var i=0; i <= $('.contents tr').size(); i++) {
            var height = $('.contents tr:nth-child(' + i + ')').height();
            if (height < 26) {
                height = 26;
                //$('.contents tr:nth-child(' + i + ') td').height(height);
            }
            $('.labels tr:nth-child(' + i + ') td').height(height);
        }
   }
   
   })(jQuery); 

}



/* sid: get the missing thumbnail value */
function getMissingDimension(fullHeight, fullWidth, dimension, dimensionValue) {
	
	var missingDimension = {};
	
	switch (dimension) {
		case "height":
			missingDimension.width = Math.round((dimensionValue / fullHeight) * fullWidth);
			missingDimension.height = dimensionValue;
			break;
			
		case "width":
			missingDimension.height = Math.round((dimensionValue / fullWidth) * fullHeight);
			missingDimension.width = dimensionValue;
			break;
			
		default:
			//alert("foisch");
			break;
	}
	
        //alert("missingDimension.width: " + missingDimension.height + " :: missingDimension.width: " + missingDimension.width);

	return missingDimension;
}
 
/* Popup-Fenster für Uni Bull Gewinnspiel */
function popup_window(url) { newwindow=window.open(url,'name','height=600,width=810');
 if (window.focus)  {  newwindow.focus() } return false;}