var popUpWin=0;


function sh_popup(URLStr,widthw,heightw)
{
  var width=(widthw>0) ? widthw:380;
  var height=(heightw>0) ? heightw:470;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr+'?popup', 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

var preloadFlag = false;

function preloadImagesSplash() {
		menu1_over = newImage("/images/splash/m1a.gif");
		menu2_over = newImage("/images/splash/m2a.gif");
		menu3_over = newImage("/images/splash/m3a.gif");
		menu4_over = newImage("/images/splash/m4a.gif");
		menu5_over = newImage("/images/splash/m5a.gif");
		menu6_over = newImage("/images/splash/m6a.gif");
	preloadFlag = true;
}


function setHeight(){
var a1 = document.getElementById('textureFixBody').clientHeight;
var b1 = a1 % 16;
	if (b1!=0) a1=a1-b1+16;
	document.getElementById('textureFixBody').height=a1;


document.getElementById('textureFixContent').style.height=document.getElementById('2xInfoboxFix').clientHeight+'px';
var a2 = document.getElementById('textureFixContent').clientHeight;
var b2 = a2 % 96;
	if (b2!=0) a2=a2-b2+96;
	document.getElementById('textureFixContent').style.height=a2+'px';
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var timer;


function popImage(imageURL,imgTitle) {
	imageURL=location.protocol+'//'+location.host+imageURL;
	var defWidth=0.75*screen.availWidth;
	var defHeight=0.75*screen.availHeight;
	var defWidth1=10;
	var defHeight1=10;
	var f="width="+defWidth1+",height="+defHeight1;
	f+=",left="+((screen.availWidth-defWidth)/2)+",scrollbars=yes,resizable=yes,top="+((screen.availHeight-defHeight)/2);
	imgWin=window.open('about:blank','',f);
	imDoc=imgWin.document;
	with (imDoc) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);if (width>0.75*screen.availWidth) width=0.75*screen.availWidth;');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);if (height>0.75*screen.availHeight) height=0.75*screen.availHeight;');
		writeln('window.resizeTo(width,height);}');writeln('else {');
		writeln('window.innerWidth=document.images["George"].width<0.75*screen.availWidth ? document.images["George"].width:0.75*screen.availWidth;');
		writeln('window.innerHeight=document.images["George"].height<0.75*screen.availHeight ? document.images["George"].height:0.75*screen.availHeight;}}');
		writeln('function doTitle(){document.title="'+imgTitle+'";}');writeln('</sc'+'ript>');
		writeln('</head><body bgcolor="#FFFFFF" onload="reSizeToImage();doTitle();self.focus()">')
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');

		close();
	}
}


function sitemap_open(img, id){
	if (document.getElementById(id).style['display']=='block'){
		document.getElementById(id).style['display']='none';
		img.src='/images/plus.gif';
	}
	else{
		document.getElementById(id).style['display']='block';
		img.src='/images/minus.gif';
	}
}

function mmidle(i1,i2,ii1,ii2) {
	var f1=(i1==ii1 || i1==ii2) ? 'a':'n';
	var f2=(i2==ii1 || i2==ii2) ? 'a':'n';
	return '/images/m'+f1+f2+'.gif';
}

function mrepaint(mact2) {
	document.getElementById('m1').src=(mact==1 || mact2==1) ? '/images/m1a.gif':'/images/m1.gif';
	document.getElementById('m2').src=(mact==2 || mact2==2) ? '/images/m2a.gif':'/images/m2.gif';
	document.getElementById('m3').src=(mact==3 || mact2==3) ? '/images/m3a.gif':'/images/m3.gif';
	document.getElementById('m4').src=(mact==4 || mact2==4) ? '/images/m4a.gif':'/images/m4.gif';
	document.getElementById('m12').src=mmidle(1,2,mact,mact2);
	document.getElementById('m23').src=mmidle(2,3,mact,mact2);
	document.getElementById('m34').src=mmidle(3,4,mact,mact2);
}

function minit() {
	mrepaint(0);
	newImage('/images/m1a.gif');
	newImage('/images/m2a.gif');
	newImage('/images/m3a.gif');
	newImage('/images/m4a.gif');
	newImage('/images/mnn.gif');
	newImage('/images/man.gif');
	newImage('/images/mna.gif');
	newImage('/images/maa.gif');
}

function mover(mact2) {
	mrepaint(mact2);
}

function mout(mact2) {
	mrepaint(0);
}

/* menu for Alape */
cm = null;
hide_delay = 500;
tstat = 0;

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(objElement,bolVisible)
{
  if (isNS4||isIE4)
  {
    if (!bolVisible) {objElement.visibility ="hidden";}
      else {objElement.visibility ="visible";}
  }
  else if (isIE5 || isNS6)
  {
    if (!bolVisible) {objElement.style.display = "none";}
      else {objElement.style.display = "";}
  }
  return 1;
}

function getPos(el,sProp)
{
  var iPos = 0;
  while (el!=null)
  {
    iPos+=el["offset" + sProp];
    el = el.offsetParent;
  }
  return iPos;
}

function getelementbyid(myid)
{
  if (isNS4) {objElement = document.layers[myid];}
    else if (isIE4) {objElement = document.all[myid];}
      else if (isIE5 || isNS6) {objElement = document.getElementById(myid);}
  return(objElement);
}

function show(el,m)
{
  if (cm!=null)
  {
    switchDiv(cm,false);
  }

  if (m!=null)
  {
    m = getelementbyid(m);
    /*m.style.left = getPos(el,"Left") + "px";
    m.style.top =  getPos(el,"Top") + el.offsetHeight+"px";*/
    switchDiv(m,true);
    cm = m;
  }
}

function show_box(el,m)
{
  if (cm!=null)
  {
    switchDiv(cm,false);
  }

  if (m!=null)
  {
    m = getelementbyid(m);
    /*m.style.left = getPos(el,"Left") + "px";
    m.style.top =  getPos(el,"Top") - el.offsetHeight + "px";*/
    switchDiv(m,true);
    cm = m;
  }
}


function hidemenu()
{
  timer1 = setTimeout("show(null,null)",hide_delay);
  tstat = 1;
  return 1;
}

function cancelhide()
{
  if (tstat==1)
  {
    clearTimeout(timer1);
    tstat = 0;
  }
  return 1;
}

function hiddennow(v)
{
  k1 = getelementbyid('unternehmen');
  k2 = getelementbyid('private_spaces');
  k3 = getelementbyid('public_spaces');
  if (isNS4 || isIE4)
  {
    k1.visibility = "hidden";
    k2.visibility = "hidden";
    k3.visibility = "hidden";
  }
  else if (isIE5 || isNS6)
  {
    k1.style.display = "none";
    k2.style.display = "none";
    k3.style.display = "none";
  }
}

function hiddennow_box(v)
{
  k1 = getelementbyid(v);
  if (isNS4 || isIE4)
  {
    k1.visibility = "hidden";
  }
  else if (isIE5 || isNS6)
  {
    k1.style.display = "none";
  }
}

function externalLinks()
{
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i < anchors.length; i++)
  {
    if (anchors[i].getAttribute("href").match(/http:\/\//) && !anchors[i].getAttribute("href").match(/(web-entwicklung.net|alape\.(com|de|at|biz|ch|info|net|co\.uk|eu|be|nl|kreadoc)|waterlounge\.net|system-wand\.(com|de)|systemwand.net|shaping-space\.com|alape-systemwand\.com)/))
    {      anchors[i].target = "_blank";
    }
  }
}
window.onload = externalLinks;
