function sandclock( )
{
	document.getElementsByTagName( "body" )[ 0 ].style.cursor="wait";
}

function Array_pop()
{
  	var response = this[this.length - 1]
  	this.length--
  	return response
}

if (typeof(Array.prototype.pop) == "undefined")
{
	Array.prototype.pop = Array_pop
}

function Array_push()
{
  var A_p = 0
  for (A_p = 0; A_p < arguments.length; A_p++) 
  {
  	this[this.length] = arguments[A_p]
  }
  return this.length
}

if (typeof Array.prototype.push == "undefined")
{
	Array.prototype.push = Array_push
}

// inarray-Funktion
function array_inArray( arr, value )
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
	var i;
	for (i=0; i < arr.length; i++) {
		// Matches identical (===), not just similar (==).
		if (arr[i] === value) {
			return true;
		}
	}
	return false;
};

// gibt die Gesamtmenge von Array und other Array zurück, eleminiert Duplikate;
// benötigt: Array.prototype.removeDuplicates
// funktioniert nur mit IE>5.0 wegen "splice" in removeDuplicates
function array_union( arr, otherArray )
{
	var retArray = arr.concat( otherArray );
	retArray = array_removeDuplicates( retArray, "s" );
	return retArray;
};

// gibt die Schnittmenge von Array und other Array zurück;
// benötigt: Array.prototype.inArray
function array_intersect( arr, otherArray )
{
	var retArray = new Array( );
	var testArray = arr.concat( otherArray );
	var i;
	for (i=0; i < testArray.length; i++) 
	{
		if ( array_inArray( arr, testArray[i] ) && array_inArray( otherArray, testArray[i] ) && ! array_inArray( retArray, testArray[i] ) ) 
		{
			// array.push( )-Ersatz für IE 5.0
			retArray[ retArray.length ]=testArray[i];
		}
	}
	return retArray;
};

// funktioniert nur mit IE>5.0 wegen "splice"
function array_removeDuplicates(arr,c)
{
   var i,j,temp;
   if(c==undefined) c = "s";
   temp = arr.slice();
   for(i = 0; i < temp.length; i++)
   {
   for(j = 0; j < temp.length; j++)
   {
     if((c=="s" ? temp[j] : temp[j].toLowerCase()) == 
(c=="s" ? temp[i] : temp[i].toLowerCase()) 
&& i != j){ temp.splice(j,1);   j-- }
      }
   }
}

function setVisibility( /* Layer */ objLayer,
                        /* boolean */ visible )
{

  if( document.layers )
  {
    objLayer.visibility  = ( visible == true ) ? 'show' : 'hide';
  }
  else
  {
    objLayer.style.visibility = ( visible == true ) ? 'visible' : 'hidden';
  }

}

function KategorieWaehlenOpenWindow( )
{
	var url = "kategorie_waehlen.php";
	var win = window.open(url, "Waehlen", "width=700,height=120,scrollbar, resizable=yes");

	if ( ! win.opener ) win.opener = self;
	if ( win.focus != null ) win.focus();
}

function KategorieWaehlenKlick( KID )
{
	window.opener.document.Edit.KategorieID.value=KID;
	self.close();
}


// München Standard

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features,popupblockermessage) { //v2.0
  if( ! window.open(theURL,winName,features) )
  	alert( unescape( popupblockermessage ) );
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// Reinz !!!!
function ReinzRollOver( name, status, bild)
{
	if (status == 1)
	{
		name.src = "../../skins/Reinz/"+bild+"";
	}

	if (status == 2)
	{
 		name.src = "../../skins/Reinz/"+bild+"";
	}
}

// Cookie-Funktionen Bill Dortch
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// --------------------------------------------------------------------------------------------
// Funktionen zum Fenster-Bewegen
// --------------------------------------------------------------------------------------------

var mylayx = '';
var mylayy = '';
var xdiff = 0;
var ydiff = 0;
var zielobj = '';
var zielobjArray = new Array( );
var scrollpos = new Array(0, 0);
var IE=false;
var hidesels = false;



if(!document.all)
{
	document.captureEvents(Event.MOUSEDOWN);
	document.captureEvents(Event.MOUSEUP);
	document.captureEvents(Event.MOUSEMOVE);
	document.captureEvents(Event.SCROLL);
	IE=false;
}
else
{
	IE=true;
}

function removeWindow( windowID )
{
	fensterobj = document.getElementById( windowID );
	parentobj = fensterobj.parentNode;
	parentobj.removeChild( fensterobj );
	// für IE iframe unter die Ebene legen:
	if( IE )
	{
		schutzframe = document.getElementById( windowID + "_iFrame" );
		parentobj.removeChild( schutzframe );
	}
	document.onmousedown = "";
	document.onmouseup = "";
	document.onmousemove = "";
	window.onscroll = "";
	if( IE && hideselects )
	{
		showselects( );
	}
}


document.onmousedown = setoffset;
document.onmouseup = release;
document.onmousemove = mymove;
//window.onscroll = adjustfunctionpos;


function registerWindow( divID, caption, cwidth, cheight )
{
	var captionArray = new Array( );
	captionArray[ "zielobj" ] = divID;
	if(IE)
	{
		captionArray["captionwidth"] = document.getElementById(caption).offsetWidth;
		captionArray["captionheight"] = document.getElementById(caption).offsetHeight;
	}
	else
	{
		myobj = document.getElementById(caption);
		captionArray["captionwidth"] = parseInt(document.defaultView.getComputedStyle(myobj, "").getPropertyValue("width"));
		captionArray["captionheight"] = parseInt(document.defaultView.getComputedStyle(myobj, "").getPropertyValue("height"));
	}
	// Notcaption für doofe Explorer
	if( captionArray["captionwidth"]==0 )
		captionArray["captionwidth"] = cwidth;
	if( captionArray["captionheight"]==0 )
		captionArray["captionheight"] = cheight;
		
		
	fensterobj = document.getElementById( divID );
	
	// für IE iframe unter die Ebene legen:
	if( IE )
	{
		parentobj = fensterobj.parentNode;
		schutzframe = document.createElement( "iframe" );
		schutzframe.style.position = "absolute";
		schutzframe.style.left = fensterobj.style.left;
		schutzframe.style.top = fensterobj.style.top;
		schutzframe.style.width = fensterobj.style.width;
		schutzframe.style.height = fensterobj.style.height;
		schutzframe.style.zindex = fensterobj.style.zindex - 1;
		schutzframe.frameBorder = 0;
		schutzframe.allowtransparency = true;
		//schutzframe.src = "/wcmsshow.php?";
		schutzframe.id = fensterobj.id + "_iFrame";
		parentobj.removeChild( fensterobj );
		parentobj.appendChild( schutzframe );
		parentobj.appendChild( fensterobj );
	}
	
	zielobjArray.push( captionArray );
	
	// wenn Cookie mit Positionen gesetzt ist, umpositionieren\n";
	xCookieName = "WCMS_Extra_" + divID + "_xpos";
	yCookieName = "WCMS_Extra_" + divID + "_ypos";
	xpos = Get_Cookie( xCookieName );
	ypos = Get_Cookie( yCookieName );
	if( xpos && ypos )
	{
		if( IE )
		{
			schutzframe.style.left = xpos;
			schutzframe.style.top = ypos;
		}
		fensterobj.style.left = xpos;
		fensterobj.style.top = ypos;
		setVisibility( fensterobj, false );
		setVisibility( fensterobj, true );
	}
	if( IE && hidesels )
	{
		setTimeout( "hideselects();", 500 );	
	}
}

//$ret.= "<iframe src=\"/wcmsshow.php\" id=\"".$this->Name."_iFrame\" scrolling=\"yes\"";
		//$ret.= " frameborder=\"0\" style=\"position:absolute; left:".$this->PopUpX."px; top:".$this->PopUpY."px; width:".$this->PopUpWidth."px;";
		//$ret.= " height:".$this->PopUpHeight."px; z-index:9;\"></iframe>";
		
function setoffset(e)
{
	var mousex, mousey;
	var scrolldisttop = 0;
	
	// Mausposition:
	mousex = (IE) ? window.event.x : e.pageX;
	mousey = (IE) ? window.event.y : e.pageY;
	// Abstand von oben
	if(IE)
	{
		scrolldisttop = document.body.scrollTop;
	}
	else
	{
		scrolldisttop = 0; //window.pageYOffset;
	}

	// zielobj ermitteln
	var i=0
	zielobj = '';
	ret = true;
	while( i<zielobjArray.length && ret )
	{
		zielname = zielobjArray[ i ]["zielobj"];
		testobj = document.getElementById(zielname);
		mylayx = parseInt(testobj.style.left, 10);
		mylayy = parseInt(testobj.style.top, 10);
		captionWidth = zielobjArray[ i ]["captionwidth"];
		captionHeight = zielobjArray[ i ]["captionheight"];
		//alert( i+": "+ zielname + " width: " + captionWidth + " height: " + captionHeight );
		
		if(mousex >= mylayx && mousey >= (mylayy - scrolldisttop) && mousex <= mylayx + captionWidth && mousey <= (mylayy + captionHeight - scrolldisttop))
		{
			zielobj = testobj;
			if( IE )
			{
				zielobjframe = document.getElementById(zielname+"_iFrame");
			}
			xdiff = mousex - mylayx;
			ydiff = mousey - mylayy;
			ret = false;
		}
		i++;
	}
	
	return(ret);
}


function release()
{
	if(zielobj)
	{
		// letzte Position des Fensters in Cookie schreiben:
		xCookieName = "WCMS_Extra_" + zielobj.id + "_xpos";
		yCookieName = "WCMS_Extra_" + zielobj.id + "_ypos";
		xpos = parseInt(zielobj.style.left, 10);
		ypos = parseInt(zielobj.style.top, 10);
		Set_Cookie( xCookieName, xpos );
		Set_Cookie( yCookieName, ypos );
		zielobj = '';
		if( IE )
		{
			zielobjframe = '';
		}
		return(false);
		
	}
	return(true);
}


function mymove(e)
{
	var mousex, mousey;


	if(zielobj)
	{
		mousex = (IE) ? window.event.x : e.pageX;
		mousey = (IE) ? window.event.y : e.pageY;
		zielobj.style.left = String(mousex - xdiff) + 'px';
		zielobj.style.top = String(mousey - ydiff) + 'px';
		if( IE )
		{
			zielobjframe.style.left = String(mousex - xdiff) + 'px';
			zielobjframe.style.top = String(mousey - ydiff) + 'px';
		}
		return(false);
	}
	else
	{
		//adjustfunctionpos();
	}
	
	return(true);
}

function hideselects( )
{
	for( sl=0; sl<document.getElementsByTagName("select").length; sl++ )
	{
		selbox = document.getElementsByTagName("select")[ sl ];
		setVisibility( selbox, false );
	}
}

function showselects( )
{
	for( sl=0; sl<document.getElementsByTagName("select").length; sl++ )
	{
		selbox = document.getElementsByTagName("select")[ sl ];
		setVisibility( selbox, true );
	}
}

function adjustfunctionpos()
{
	var myobj;
	var fposy = 0;
	
	
	if(document.body.scrollTop != scrollpos[0])
	{
		scrollpos[0] = document.body.scrollTop;
		for( var i=0; i<zielobjArray.length; i++ )
		{		
			zielname = zielobjArray[ i ]["zielobj"];
			myobj = document.getElementById(zielname);
			if( IE )
			{
				myobjframe = document.getElementById(zielname+"_iFrame");
			}
			if(parseInt(myobj.style.top, 10) < document.body.scrollTop)
			{
				myobj.style.top = document.body.scrollTop;
				if( IE )
				{
					myobjframe.style.top = document.body.scrollTop;
				}
			}
			if(parseInt(myobj.style.top, 10) > document.body.clientHeight - document.body.scrollTop)
			{
				myobj.style.top = document.body.scrollTop;
				if( IE )
				{
					myobjframe.style.top = document.body.scrollTop;
				}
			}
		}
	}
}
