// JavaScript Document


// Dokument höhe
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getWinHeight() {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function get(id) { 
     return document.getElementById(id); 
} 

// goto navi laden
var navi_geladen=false
function load_navi(navi, gehezu)
	{
		get('cmd').src=navi+'.asp'
		gehezuseite(gehezu)
	}
	
function gehezuseite(gehezu)
	{
		if (navi_geladen==true)
			{
				get('cmd').src=gehezu
			}
			else
			{
				setTimeout(function(){gehezuseite(gehezu);},10)
			}
	}
// navigation
var aktive_navi=''

function init_navi()
	{
		get('home').style.color='#EF4238'
		aktive_navi='home'
		var n = document.getElementsByTagName('div');
		for (var i=0;i<n.length;i++) 
		{
			if(n[i].className=='navi')
				{
					n[i].onmouseover = function()
						{
						this.style.color ='#EF4238';
						}
					n[i].onmouseout = function()
						{
						if(this.id!=aktive_navi)
							{
								this.style.color ='#88939A';
							}
						}
					n[i].onclick = function()
						{
						if(aktive_navi!='')
							{
								get(aktive_navi).style.color ='#88939A';
							}
						this.style.color ='#EF4238';
						aktive_navi=this.id
						url=this.id+'.asp'
						if(url.indexOf('?')>-1)
							{
								url=url+'&r='+Math.random()
							}
							else
							{
								url=url+'?r='+Math.random()
							}
						get('cmd').src=url
						} // ende onclick
				
				} // ende if className
		}
	}// ende funktion
		
function navi_click(id, url)
	{
		window.scrollTo(0, 0);
		//fnSetLoader()
		if(aktive_navi!='')
			{
				elem=get(aktive_navi);
				elem.style.color='#FFFFFF';
				elem.style.backgroundColor=''
			}
		elem=get(id);
		elem.style.color=get(aktive_text_id).style.backgroundColor
		elem.style.backgroundColor='#FFFFFF'
		aktive_navi=id
		if(url.indexOf('?')>-1)
			{
				url=url+'&r='+Math.random()
			}
			else
			{
				url=url+'?r='+Math.random()
			}
		get('cmd').src=url
	}


var subnav_aktiv=''

function init_subnavi(bereich)
	{
		var n = document.getElementsByTagName('div');
		for (var i=0;i<n.length;i++) 
		{
			if(n[i].className=='subnavi')
				{
					n[i].onmouseover = function()
						{
						this.style.color ='#EF4238';
						}
					n[i].onmouseout = function()
						{
						if(this.id!=subnav_aktiv)
							{
								this.style.color ='#88939A';
							}
						}
					n[i].onclick = function()
						{
						if(subnav_aktiv!='')
							{
								if(get(subnav_aktiv))
									{
										get(subnav_aktiv).style.color ='#88939A';
									}
							}
						this.style.color ='#EF4238';
						subnav_aktiv=this.id
						if(bereich=='portfolio')
							{
								url=bereich+'/'+this.id+'01.asp'
							}
							else
							{
								url=bereich+'/'+this.id+'.asp'
							}
						if(url.indexOf('?')>-1)
							{
								url=url+'&r='+Math.random()
							}
							else
							{
								url=url+'?r='+Math.random()
							}
						//get('mainstage').innerHTML='<img src="img/loader.gif" class="mainstage_loader" />'
						get('cmd').src=url
						} // ende onclick
				
				} // ende if className
		}
	}// ende funktion

function init_portfolio_navi()
	{
		var n = document.getElementsByTagName('img');
		for (var i=0;i<n.length;i++) 
		{
			if(n[i].className=='pfeil_rechts' || n[i].className=='pfeil_links')
				{
					n[i].onmouseover = function()
						{
							this.style.opacity=.5
							this.style.MozOpacity=.5
							this.style.filter = 'alpha(opacity=50)';
						}
					n[i].onmouseout = function()
						{
						if(this.id!=subnav_aktiv)
							{
							this.style.opacity=.4
							this.style.MozOpacity=.4
							this.style.filter = 'alpha(opacity=40)';
							}
						}
					n[i].onclick = function()
						{
						
						url=get('cmd').src
						nr_ende=url.indexOf('.asp')
						nr_url=url.slice(nr_ende-2, nr_ende)
						nr=nr_url*1
						
						if(this.className=='pfeil_rechts'){nr=nr+1}
						if(this.className=='pfeil_links'){nr=nr-1}
						
						if(nr<10){nr='0'+nr}
						url=url.replace(nr_url,nr)
						
						get('cmd').src=url
						} // ende onclick
				
				} // ende if className
		}
	}// ende funktion



// Formular und Button
function $focus(id)
	{
	elem=get(id)
	//elem.style.background='#FFFFCC'
	elem.style.borderColor='#525C61'
	}

function $blur(id)
	{
	elem=get(id)
	elem.style.background='#FFFFFF'	
	elem.style.borderColor='#88939A'
	}

function btn_over()
	{
	elem=get('btn_kontakt')
	elem.style.borderColor='#525C61'
	elem.style.color='#525C61'
	}

function btn_out()
	{
	elem=get('btn_kontakt')
	elem.style.borderColor='#88939A'
	elem.style.color='#88939A'
	}

function $submit()
	{
		get('msg_loader').style.visibility='visible';
		h=getDocHeight()
		elem=get('msgoverlay')
		elem.style.height=h+'px';
		elem.style.visibility='visible';
		get('kontakt_form').submit()
	}

function btn_ok_over(id)
	{
		e=get(id);
		e.style.backgroundImage='url(img/nBack25over.png)';
	}

function btn_ok_out(id)
	{
		e=get(id);
		e.style.backgroundImage='url(img/nBack25.png)';
		e.style.color='#EAEAEA';
		e.style.lineHeight='24px';
	}

function btn_ok_down(id)
	{
	e=get(id);
	e.style.backgroundImage='url(img/nBack25down.png)';
	e.style.lineHeight='26px';
	}
function btn_ok_up(id)
	{
	e=get(id);
	e.style.backgroundImage='url(img/nBack25over.png)';
	e.style.lineHeight='24px';
	}

function close_msg()
	{
		get('msgbox').style.visibility='hidden';
		get('msg_loader').style.visibility='hidden';
		get('msgoverlay').style.visibility='hidden';
	}

function open_msg()
	{
		get('msgbox').style.visibility='visible';
		get('msg_loader').style.visibility='hidden';
		h=getDocHeight()
		elem=get('msgoverlay')
		elem.style.height=h+'px';
		elem.style.visibility='visible';
	}

// startsceen ausblenden
function loader_ausblenden()
	{
		elem=get('start_loader')
		if(elem.style.visiblity!='hidden')
			{
				get('loader_img').style.visibility='hidden'
				ausblenden('start_loader')
			}
	}

var tr=100
var step=1
function ausblenden(id)
	{
		if (tr>0)
			{
				tr=tr-step
				step=step+1
				elem=get(id)
				elem.style.visibility='visible'
				elem.style.opacity=tr/100
				elem.style.MozOpacity=tr/100
				elem.style.filter = 'alpha(opacity=' + tr + ')';
				setTimeout(function(){ausblenden(id);},80)
			}
			else
			{
				get(id).style.visibility='hidden'
			}
	}

// Gehe zu seite
function goto(url)
	{
	window.scrollTo(0, 0);
	url=url+'?r='+Math.random()
	get('cmd').src=url
	}


function emailForm(u,t){
	var daReferrer = document.referrer; 
	var email = ''; 
	var subject = t; 
	var body_message = '%0D'+u+'%0D';
	var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;

	win = window.open(mailto_link,'emailWindow'); 
	if (win && win.open &&!win.closed) win.close(); 
} 

function direkt_link(u){
	var daReferrer = document.referrer; 

	win = window.open(u,'newWindow'); 
} 

// add movies
function add_movie(film, breite, hoehe, ziel)
	{
			var so = new SWFObject( "media/player_flv_maxi.swf", "csSWF", breite, hoehe, "8", "#FFFFFF");
			so.addParam( "movie", "media/player_flv_maxi.swf" );
			so.addParam( "allowFullScreen", "true" );
			so.addParam( "wmode", "opaque" );
			so.addParam( "allowScriptAccess", "sameDomain" );
			so.addParam( "quality", "high" );
			so.addParam( "menu", "true" );
			so.addParam( "FlashVars", 'configxml=media/'+film+'.xml' );
			so.write(ziel);			
	}

