/*****************************************************************************
**
**  misc.js
**
**  same useful tools
**
**  Rainer Müller
*/
function LayerNewObject(obj)
	{
	this.obj = obj;
	this.id = obj.id;
	this.Hide = objHide;
	this.Show = objShow;
	this.GetLeft = objGetLeft;
	this.GetTop = objGetTop;
	this.GetHeight = objGetHeight;
	this.GetWidth = objGetWidth;
	this.GetisHidden = objGetisHidden;
	this.SetTop = objSetTop;
	this.SetLeft = objSetLeft;
	this.SetHeight = objSetHeight;
	this.SetWidth = objSetWidth;
	this.SetbgColor = objSetbgColor;
	this.SetClip = objSetClip;
	this.SetContainer = objSetContainer;
	}

function objHide()
{
if (is_ie4)	 this.obj.style.visibility = "hidden";
else if(is_nav4)	 this.obj.visibility = "hidden";
else if(is_opera)	 this.obj.style.visibility = "hidden";
else this.obj.style.visibility = "hidden";
return;
}

function objShow()
{
if (is_ie4)	 this.obj.style.visibility = "visible";
else if(is_nav4) this.obj.visibility = "visible";
else if(is_opera) this.obj.style.visibility = "visible";
else this.obj.style.visibility = "visible";
return;
}

function objGetLeft()
{
if (is_ie4) return parseInt(this.obj.offsetLeft);
if (is_nav4) return parseInt(this.obj.left);
if (is_opera) return parseInt(this.obj.style.pixelLeft);
return parseInt(this.obj.offsetLeft);
}

function objGetTop ()
{
if (is_ie4) return parseInt(this.obj.offsetTop);
if (is_nav4) return parseInt(this.obj.top);
if (is_opera) return parseInt(this.obj.style.pixelTop);
return parseInt(this.obj.offsetTop);
}

function objGetHeight ()
{
//ob(this.obj);
if (is_ie4) return parseInt(this.obj.clientHeight);
if (is_nav4) return parseInt(this.obj.clip.height);
if (is_opera) return parseInt(this.obj.style.pixelHeight);
return parseInt(this.obj.offsetHeight);
}

function objGetWidth ()
{
//ob(this.obj);
if (is_ie4) return parseInt(this.obj.clientWidth);
if (is_nav4) return parseInt(this.obj.clip.width);
if (is_opera) return parseInt(this.obj.style.pixelWidth);
return parseInt(this.obj.offsetWidth);
}

function objGetisHidden()
{
if (is_ie4) {if (this.obj.style.visibility !="visible") return true;}
else if(is_nav4) {if (this.obj.visibility == "hide") return true;}
else if(is_opera) {if (this.obj.style.visibility != "VISIBLE") return true;}
else {if (this.obj.style.visibility != "visible") return true;}

return false;
}

function objSetTop(top)
{
if (is_ie4)	this.obj.style.posTop = top;
else if(is_nav4) this.obj.top=top;
else if(is_opera) this.obj.style.pixelTop=top;
else this.obj.style.top=top;
return;
}

function objSetLeft(left)
{
if(is_ie4) this.obj.style.posLeft=left;
else if(is_nav4) this.obj.left = left;
else if(is_opera)	this.obj.style.pixelLeft=left;
else this.obj.style.left=left;
return;
}

function objSetHeight(height)
{
if(is_ie4) this.obj.style.posHeight=height;
else if(is_nav4) this.obj.clip.height = height;
else if(is_opera)	this.obj.style.pixelHeight=height;
else this.obj.style.height=height;
return;
}

function objSetWidth(width)
{
if(is_ie4) this.obj.style.posWidth=width;
else if(is_nav4) this.obj.clip.width = width;
else if(is_opera) this.obj.style.pixelWidth=width;
else this.obj.style.width=width;
return;
}

function objSetbgColor(color)
{
if(is_ie4) this.obj.style.backgroundColor=color;
else if(is_nav4) this.obj.bgColor = color;
else if(is_opera)	this.obj.style.background=color;
else this.obj.style.backgroundColor=color;
return;
}

function objSetClip(a1,a2,a3,a4)
{
if(is_ie4 || is_ie5) this.obj.style.clip="rect("+a1+" "+a2+" "+a3+" "+a4+")"; //top,width,height,left
else if(is_nav4){this.obj.clip.left=a4;this.obj.clip.top=a1;this.obj.clip.width=a2;this.obj.clip.height=a3;}
else if(is_opera){}  // weiss noch nicht
else
	{
	this.obj.style.clip="rect("+a1+" "+a2+" "+a3+" "+a4+")"; //top,right,bottom,left
	}
return;
}

function objSetContainer(txt)
{

if (is_ie4)
{
  this.obj.innerHTML ='<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td nowrap height=15 black8>'+txt+'</td></tr></table>';
}
else if(is_nav4)
{
  this.obj.document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td nowrap height=15 black8>'+txt+'</td></tr></table>');
  this.obj.document.close();
}
else if(is_opera)
{
 //  ???? noch keine Ahnung
}
else
{
  this.obj.innerHTML = '<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td nowrap height=15 black8>'+txt+'</td></tr></table>';  // nur übergangsweise
}
return;
}

/*********************************/

// for IE4
function IECreateObjects()
{
   theelements = document.all.tags("DIV");
   LayObj = new Array();
   LayObjID = new Array();
   for (i = 0; i < theelements.length; i++)
   	{
      if (theelements[i].id != "")
      	{
	   	LayObj[theelements[i].id] =	new LayerNewObject(theelements[i]);
	   	LayObjID[LayObjID.length]=theelements[i].id;
	   	}
     }
// alle Forms suchen
   LayObjF = new Array();
   theelements=document.all.tags("FORM");
   for (i = 0; i < theelements.length; i++)
		{
	   LayObjF[theelements[i].name] = theelements[i];
   	}
// alle Bilder suchen
   LayObjI = new Array();
   theelements=document.all.tags("IMG");
   for (i = 0; i < theelements.length; i++)
		{
	   LayObjI[theelements[i].name] = theelements[i];
   	}
}
// for NN4
function NNCreateObjects()
{
   LayObj = new Array(document.layers.length);
   LayObjID = new Array();
   for (i = 0; i < document.layers.length; i++)
		{
	   for (i1 = 0; i1 < document.layers[i].document.layers.length; i1++)   // untergeordnete Layer suchen
				{
	 	     	if (document.layers[i].document.layers[i1].id.substring(0,3) != "_js") // von NN selbstbenannte Div's ausklammern
 		     		{
   			   LayObj[document.layers[i].document.layers[i1].id] = new LayerNewObject(document.layers[i].document.layers[i1]);
 		   		LayObjID[LayObjID.length]=document.layers[i].document.layers[i1].id;
 		   		}
				}
 	     if (document.layers[i].id.substring(0,3) != "_js") // von NN selbstbenannte Div's ausklammern
 	     		{
   		   LayObj[document.layers[i].id] = new LayerNewObject(document.layers[i]);
 		   	LayObjID[LayObjID.length]=document.layers[i].id;
 		   	}
   		}
// alle Forms suchen
   LayObjF = new Array();
   for (i = 0; i < document.forms.length; i++)
		{
	   LayObjF[document.forms[i].name] = document.forms[i];
   	}
   for (i = 0; i < LayObjID.length; i++)
		{
		Lay1=LayObj[LayObjID[i]].obj.document.forms;
	   for (i1 = 0; i1 < Lay1.length; i1++)
			{
	   	LayObjF[Lay1[i1].name] = LayObj[LayObjID[i]].obj.document.forms[i1];
   		}
		}
// alle Images suchen
   LayObjI = new Array();
   for (i = 0; i < document.images.length; i++)
		{
	   LayObjI[document.images[i].name] = document.images[i];
   	}
   for (i = 0; i < LayObjID.length; i++)
		{
		Lay1=LayObj[LayObjID[i]].obj.document.images;
	   for (i1 = 0; i1 < Lay1.length; i1++)
			{
	   	LayObjI[Lay1[i1].name] = LayObj[LayObjID[i]].obj.document.images[i1];
   		}
		}
}
// for DOM  NN6
function DOMCreateObjects()
{
   theelements = document.getElementsByTagName("DIV");
   LayObj = new Array();
   LayObjID = new Array();
   for (i = 0; i < theelements.length; i++)
   	{
      if (theelements[i].id != "")
      	{
	   	LayObj[theelements[i].id] =	new LayerNewObject(theelements[i]);
	   	LayObjID[LayObjID.length]=theelements[i].id;
	   	}
      }
// alle Forms suchen
   LayObjF = new Array();
   theelements=document.getElementsByTagName("FORM");
   for (i = 0; i < theelements.length; i++)
		{
	   LayObjF[theelements[i].name] = theelements[i];
   	}
// alle Images suchen
   LayObjI = new Array();
   theelements=document.getElementsByTagName("IMG");
   for (i = 0; i < theelements.length; i++)
		{
	   LayObjI[theelements[i].name] = theelements[i];
   	}

}
// for OPERA 5.0
function OPERACreateObjects()
{
   theelements = window.document.all;
   LayObj = new Array();
   LayObjID = new Array();
   LayObjF = new Array();
   LayObjI = new Array();
   for (i = 0; i < theelements.length; i++)
   	{
// alle Divs suchen
      if (theelements[i].id != "" && theelements[i].tagName == "DIV")
      	{
	   	LayObj[theelements[i].id] =	new LayerNewObject(theelements[i]);
	   	LayObjID[LayObjID.length]=theelements[i].id;
	   	}
// alle Forms suchen
      if (theelements[i].name != "" && theelements[i].tagName == "FORM")
      	{
		   LayObjF[theelements[i].name] = theelements[i];
		   }
// alle Images suchen
      if (theelements[i].name != "" && theelements[i].tagName == "IMG")
      	{
		   LayObjI[theelements[i].name] = theelements[i];
		   }
   	}
}

function initLayObj()
{
	setTimeout("Laden()",5000);
	if (is_opera)
		{
		while (i_opera<1){}
		}
	if (is_ie4)
		IECreateObjects();
	else if (is_nav4)
		NNCreateObjects();
	else if (is_opera)
		OPERACreateObjects();
	else
		DOMCreateObjects();
}

function ObjectProps(Objekt, ObjName)
{
 var Ergebnis = "";
 for (var Eigenschaft in Objekt)
 {
   Ergebnis += ObjName + "." + Eigenschaft + " = " + Objekt[Eigenschaft] + "\t";
 }
 return Ergebnis;
}


var i_opera=0;
function Laden() {i_opera=1;}  // for Opera

function CheckAuswahl(elem) {
 for(i_check=0;i_check<elem.length;++i_check)
  if(elem.options[i_check].selected == true)
   return elem.options[i_check].value;
}

function groesse(x)
{
if (x=="")
	x=620;
y1=LayObj['unten'].GetTop()+LayObj['unten'].GetHeight();
if (is_ie || is_nav5up) y1+=0;
if (is_nav4) y1-=50;
if(screen.availHeight < y1)
	y1=screen.availHeight;

window.resizeTo(x,y1);
window.moveTo(0,0);
window.focus();
}

function agb_ok(elem)
{
if (elem.form.agb_anerkennung.checked)
	elem.form.submit();
	else
	alert("Sie müssen unsere AGB\'s anerkennen! \n\nClicken Sie dazu das Kontrollkästchen an.");
}	

function swapImage(bild,name,was)
{
eval("bild.src=bilder["+name+"]["+was+"].src");
}

function swapImg0(name)
{
eval("document.bild_"+name+".src=bilder["+name+"][0].src");
}

function swapImg1(name)
{
eval("document.bild_"+name+".src=bilder["+name+"][1].src");
}

function change_img(ELEM,bild)
{
ELEM.src="shop_image/category/"+bild;
}

function aktuell()
{
	window.status="Infos zu aktuellen Anlässen";
	F1=window.open("?open_fenster=aktuell/html/aktuell_klein","aktuelles","width=500,height=300,resizable,scrollbars");
	F1.focus();
}

function bedingungen(n,b)
{
	F0=window.open("?open_fenster=betteln/html/"+n+"&b="+b,"bedingungen","width=500,height=500,scrollbars");
	F0.focus();
	F0.moveTo(0,0);
}

function buchung_form(z,t)
{
	F0=window.open("?open_fenster=buchung/html/buchung_form&z="+z+"&d="+t+"&b=","buchungsform","width=700,height=600,resizable");
	F0.focus();
	F0.moveTo(0,0);
}
function buchung_info(z,t)
{
	F0=window.open("?open_fenster=buchung/html/buchung_info&z="+z+"&d="+t,"bedingungen","width=500,height=500,resizable");
	F0.focus();
	F0.moveTo(0,0);
}
function buchung_info_b(b)
{
	F0=window.open("?open_fenster=buchung/html/buchung_info_b&b="+b,"bedingungen","width=500,height=500,resizable");
	F0.focus();
	F0.moveTo(0,0);
}
function zimmer_bilder(z)
{
	F0=window.open("?open_fenster=templates/zimmer_bilder&z="+z,"zimmerbilder","width=500,height=600,resizable,scrollbars");
	F0.focus();
	F0.moveTo(0,0);
}
function anzeige_empfehlen(n)
{
	window.status="Empfehlung";
	F1=window.open("?open_fenster=betteln/html/empfehlen&anzeigen_id="+n,"empfehl","width=500,height=300,resizable");
	F1.focus();
}
function empfehlen_ok(n)
{
	F1=window.open("?open_fenster=betteln/html/empfehlen_ok&text="+n,"empfehlok","width=500,height=300,resizable");
	F1.focus();
}

function nop()
{

}
