/*-------------------------------------------------------------------------
Elemente die ersetzt werden ausblenden um ein kurzes Aufflackern zu vermeiden
-------------------------------------------------------------------------*/
function hideElement(elementObj)
{
		elementObj.style.visibility = "hidden";
}

function showElement(elementObj)
{
		elementObj.style.visibility = "visible";
}

/*-------------------------------------------------------------------------
Wird ausgeführt, wenn die letzte Zeile HTML geladen ist
-------------------------------------------------------------------------*/
function HTMLloaded()
{
	if(document.getElementsByTagName)
	{
		//hideElement(document.getElementsByTagName('h1')[0]);
	}
	
	if(document.getElementById)
	{
		correctCopyHeight();
		correctFooterPosition();
	}
}

window.onresize = HTMLloaded;

function correctFooterPosition()
{	
	var agent = navigator.userAgent.toLowerCase();
	
	if(agent.indexOf('mac') != -1 && agent.indexOf('msie') != -1)
	{
		var screenHeight = document.getElementsByTagName('body')[0].offsetHeight;
		document.getElementById('menuUnten').style.top = (screenHeight-50)+"px";
	}
}

function correctCopyHeight()
{
	var marginTop = 215;
	var marginBottom = 56;
	var screenHeight = document.getElementsByTagName('body')[0].offsetHeight;
	
	if(window.innerHeight)
	{
		screenHeight = window.innerHeight;
	}
	
	var newHeight = screenHeight-marginTop-marginBottom;
	document.getElementById('content').style.height = newHeight+"px";
}

/*-------------------------------------------------------------------------
wird im onLoad des Body ausgeführt und startet Funktionen
-------------------------------------------------------------------------*/
function doOnload()
{    
	if(document.getElementById)
	{
		initWMRollover();
		var tmpH1 = document.getElementsByTagName('h1')[0];
		
		if(tmpH1)
		{
			showElement(tmpH1);
		}
		
		if(window.location.search == "?debug")
		{
			var head = document.getElementById("headline");
			
			if(head)
			{
				head.style.top = "51px";
				head.style.left = "242px";
			}
			
			header = new replaceContentClass('header','', 'h1','../IMG/RollAd/tmp.gif','503','55');	
		}				
	}
	
	if(window.pageOnload)
	{
		pageOnload();
	}
}

// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
picSwapClass = function(objName,containerID,swapPx,swapFrames)
{
	if(document.getElementById)
	{
		this.objName = objName;
		this.containerID = containerID;
		this.swapPx = swapPx;
		this.swapFrames = swapFrames;
		this.containerObj = document.getElementById(this.containerID);
		this.activeMenuID = null;
		this.showTransitions = false;
		
		if(this.containerObj)
		{
			if(document.all)
			{
				if(this.containerObj.filters)
				{
					if(this.containerObj.filters.revealTrans)
					{
						if(!navigator.userAgent.toLowerCase().indexOf('msie 5.0') != -1)
						{
							this.showTransitions = true;
						}
					}			
				}
			}
		}
	}
}

picSwapClass.prototype.mouseOver = function(me)
{
	if(this.mouseOutTimeout)
	{
		window.clearTimeout(this.mouseOutTimeout);
	}
	
	if(this.containerObj)
	{
		var tmpActiveMenu = me.id.substr(me.id.length-1,1)*1;
		var tmpSwap = (this.swapFrames-tmpActiveMenu) * this.swapPx;
		var tmpSwap = (tmpActiveMenu-1) * this.swapPx;
		
		if(this.showTransitions)
		{
			this.containerObj.filters.revealTrans.Apply();
		}
		
		this.containerObj.style.backgroundPosition = "-"+tmpSwap+"px 0px";
		
		if(this.showTransitions)
		{
			this.containerObj.filters.revealTrans.Play();
		}
	}
	return true;
}

picSwapClass.prototype.mouseOut = function(me)
{
	this.mouseOutTimeout = window.setTimeout(this.objName+".doMouseOut()",100);
}

picSwapClass.prototype.doMouseOut = function()
{
	this.mouseOutTimeout = false;
	
	if(this.containerObj)
	{
		if(this.activeMenu)
		{
			this.mouseOver(this.activeMenu);
		}
		
		else
		{
			if(this.showTransitions)
			{
				this.containerObj.filters.revealTrans.Apply();
			}
			
			this.containerObj.style.backgroundPosition ="0px 0px";
			
			if(this.showTransitions)
			{
				this.containerObj.filters.revealTrans.Play();
			}
		}
	}
	return true;
}

// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
initWMRollover = function()
{
	WMRollover = new picSwapClass("WMRollover","images",251,4);
}


// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
function findControl(parent, tagName, serverId) 
{
    var items = parent.getElementsByTagName(tagName);
    
    for (var i = 0; i < items.length; i++) 
    {
        var ctl = items[i];
        
        if (ctl && ctl.id) 
        {
            var subId = ctl.id.substring(ctl.id.length - serverId.length);
            
            if (subId == serverId) 
            {
                return ctl;                        
            }
        }
    }
       
    return null;
}

function loadTabPanel(sender, e) 
{   
    var tabContainer = sender;           
               
    if (tabContainer) 
    {
        var updateControlId = "TabButton" + tabContainer.get_activeTabIndex();
        var activeTab = tabContainer.get_activeTab();            

        if (findControl(activeTab.get_element(), "div", "TabContent" + tabContainer.get_activeTabIndex())) return;
    
        var updateControl =  findControl(activeTab.get_element(), "input", updateControlId);
        
        if (updateControl) 
        {
            updateControl.click();
        }              
    }
}

var subwindow= null;

function ClosePopUp()
{
    if (!subwindow)
        return;
    if (subwindow.closed)
        return;
  
    subwindow.close();
}

function NewWindow(mypage,myname,w,h)
{
    ClosePopUp();
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var settings ='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
    settings +='menubar=no,';
    settings +='toolbar=no,';
    settings +='status=no,';
    settings +='scrollbars=no,';
    settings +='resizable=no';
    subwindow=window.open(mypage,myname,settings);
    
    if(parseInt(navigator.appVersion) >= 4){subwindow.window.focus();}
}

