function addCSSClass(obj, class_name)
{
  if (obj.className.indexOf(class_name) == -1)
    obj.className += ' ' + class_name;
}

function removeCSSClass(obj, class_name)
{
  if (obj.className.indexOf(class_name) != -1)
    obj.className = obj.className.replace(class_name, '');
}

function activate_input(obj)
{
  addCSSClass(obj, 'hover');
  val = obj.title;
  if (obj.value == val)
    obj.value = '';
  obj.focused = true;
}

function deactivate_input(obj)
{
  removeCSSClass(obj, 'hover');
  val = obj.title;
  if (obj.value == '')
    obj.value = val;
  obj.focused = false;
}

function mouseover_input(obj)
{
  addCSSClass(obj, 'hover');
}

function mouseout_input(obj)
{
  if (document.activeElement != obj)
    removeCSSClass(obj, 'hover');
}

function fixScroll() {
  var s = document.body.scrollTop;
  document.body.focus();
  document.body = s;
}

function numeric_KeyFilter(event) {
   var charCode = (navigator.appName == "Netscape") ? event.which : event.keyCode;

   // only numbers
   if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
   return true;
}

function basename(filepath)
{    
    var res = filepath.match(/[\/|\\]([^\\\/]+)$/);
    return (res) ? res[1] : filepath; 
}

function jumpTo(targ, selObj, restore)
{
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  //if (restore) selObj.selectedIndex=0;
}



/*
   Datei: add_event.js

	* Version 0.1
	* Datum: 11.06.2007

   Einen Eventaufruf einem Objekt zufügen.

   Folgende Parameter werden übergeben:
  

   obj 		- Das Objekt auf dem der Event stattfindet. [Default: window]
   event 	- Der Event der beobachtet werden soll (ohne 'on') [Default: load]
   function 	- Eine Funktionsreferenz


   Die Funktion kann auf 2 Arten benutzt werden. 
   
   addEvent( obj, event, func);
   addEvent( { func: function, evt: event, obj: obj})

*/
( function() {
if (typeof window.addEvent == 'undefined'){
	// Name der lokalen Eventhandlerliste des Objektes
	var evtHnd = '__EVT__HANDLER__'; 

	window.addEvent = function () {
		var obj, name, func;
		// Parameterauswertung
		var args = arguments;
		if( args.length == 1 && typeof args[0] == 'object') {
			// Der Parameter ist ein Objekt
			obj = args[0]['obj']; name = args[0]['evt']; func = args[0]['func'];
		} else {
			// Parameterliste
			obj = args[0]; name = args[1]; func = args[2];
		}
		// Defaultwerte 
		if(!obj) obj = window;
		if(!name) name = 'load';
		if( typeof func != 'function') return alert('Keine Funktionsreferenz!');
		
		// Die Objekte, die die Handler aufnehmen vorbereiten.
		if(!obj[evtHnd]) obj[evtHnd] = {};
		if(!obj[evtHnd][name]) obj[evtHnd][name] = [];
		// Die Funktion abgespeichern. 
		obj[evtHnd][name].push( func );
		
		// Den Handler des Objektes registrieren
		// Der Rückgabewert des events ist immer der Rückgabewert der
		// zuletzt registrierten Funktion
		
		if(!obj['on' + name])  obj['on' + name] = function(e){
			if(!e) e = window.event;
			if(!obj[evtHnd] || !obj[evtHnd][name]) return false;
			
			var ret = false;
			for(var i = 0; i < obj[evtHnd][name].length;i++)  ret = obj[evtHnd][name][i].call(obj, e);
			
			return ret;
		};
		
		return true;
	};
	window.removeEvent = function (o, n, f) {
		if(o[evtHnd] && o[evtHnd][n]) {
			for(var i = 0; i < o[evtHnd][n].length;i++) 
				if(o[evtHnd][n][i])  {
					o[evtHnd][n].splice(i, 1);
					return true;
				}
			}
		}
	}; // ENDE --> if (typeof addEvent == 'undefined')
}())


/*


 Beschreibung:
 -------------
 Ein Skript um ein Fenster in der Größe eines Bildes öffnen.

 Einbinden:
 ----------
 <script src="popup.js"></script>
 
 <a href="grosses_bild.jpg" target="bild" class="popup"><img src="kleines_bild.jpg"></a>
*/
///////////////////////////////////////////////////////////
// Globale Definitionen
var popup_bgColor = '#fff';
var rahmen        = '1px solid black';
var abstand_w      = 1;
var abstand_h      = 1;
var center_popup  = false;
var popup_close   = 'click'; // Mögliche Werte: 'blur', 'click', ''

addEvent(window, 'load', function() {
	var all = document.links;

	for(var i = 0; i < all.length; i++) {
		if(all[i].className && all[i].className.indexOf('popup') > -1 )  {
			
			all[i].onclick = function () { showBild(this); return false;};
		}
	}
});

///////////////////////////////////////////////////////////
// showBild(a, name) - die Hauptfunktion.
var default_site = window.opera ? '' : '';
function showBild(a) {
	if(!a.target) a.target = "Foto";
    var default_width   = 800;
    var default_height  = 488;
	if(a.target == window.name) a.target += '0';

    if(popup_close == 'blur' || !showFenster || showFenster.closed)
    showFenster = popUp(default_site, a.target, default_width, default_height);

    showFenster.document.open();
    showFenster.document.write( getHTML(a.href, a.title || a.alt || 'PicPopup') );
    showFenster.document.close();

    var img = new Image();
    img.ready = false;
    img.onload = function() { fitWin(this, showFenster); };
    img.src = a.href;
    if(img.complete) fitWin(img, showFenster);
    return false;
}
///////////////////////////////////////////////////////////
// fitWin(Image, window) - wird aus dem Popup aufgerufen.
function fitWin(i, win) {
	win.focus();
	if(i.ready) return;
	i.ready = true;
	var w = i.width;
	var h = i.height;
	var w_s = getWinSize(win);
	var r = 2 * parseInt(rahmen);
	
	win.resizeBy((w - w_s.width + ( 2 * abstand_w) + r), (h - w_s.height + ( 2 * abstand_h) + r) );
	if(center_popup) {
	w_s = getWinSize(win);
		win.moveTo( (screen.width - w_s.width) / 2, (screen.height - w_s.height) / 2 );
	}
}

/////////////////////////////////////////////////////////////////////
// getHTML(bild, titel, farbe)
function getHTML(src, title, bgcolor) {
	if(!title) title = 'kein Titel';
	if(!bgcolor) bgcolor = popup_bgColor;
	var NL = "\n";
	var text = '<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01\/\/EN" http:\/\/www.w3.org\/TR\/html4\/strict.dtd">\n'
	+ '<html>\n<head>' + NL
	+ '<title>' + title + '<\/title>' + NL
	+ '<style type="text/css">' + NL
	+ 'body{margin:0;padding:0;overflow:hidden;' + NL
	+ 'background-color:' + popup_bgColor + ';' + NL
	+ (popup_close.toLowerCase() == 'click' ? ' cursor:pointer;\n' : '')
	+ '}' + NL
	+ 'img{padding:0;'
	+ (rahmen ? 'border:' + rahmen + ';'  : '')
	+ 'margin-top:' + abstand_h +'px;' + NL
	+ 'margin-bottom:' + abstand_h +'px;' + NL
	+ 'margin-left:' + abstand_w +'px;' + NL
	+ 'margin-right:' + abstand_w +'px;' + NL
	+ '}\n' + NL
	+ '<\/style>' + NL
   + '<\/head>' + NL
   + '<body'
   + (popup_close.toLowerCase() == 'blur' ? ' onblur="self.close();"' : '')
   + '>'
   + '<img src="' + src + '" alt="' + title + '"'
   + (popup_close.toLowerCase() == 'click' ? ' onclick="window.close();"' : '')
   + '>' + NL
   + '<\/body><\/html>'
   ;
   return text;
}
/////////////////////////////////////////////////////////////////////
// Ein popup öffnen
function popUp(url, fname, w, h) {
	var tmp = new Array();
	tmp[tmp.length] = 'resizable=yes';
	tmp[tmp.length] = 'scrollbars=no';
	if(w) tmp[tmp.length] = 'width=' + w;
	if(h) tmp[tmp.length] = 'height=' + h;

	return window.open(url, fname, tmp.join(','));
}
////////////////////////////////////////////////////////////
// getWinSize(window)
function getWinSize(win) {
	if(!win) win = window;
	// IE: Quirks- oder Standardmode
	var body = (win.document.compatMode && win.document.compatMode == "CSS1Compat") ? 
		win.document.documentElement : 
		win.document.body || null
	;
	return {
	width: (win.innerWidth || body.clientWidth),
	height: (win.innerHeight || body.clientHeight)
	};
}
var showFenster = null;
/////////////////////////////////////////////////////////////////////
// ... und am schluss alle Fenster schliessen.
window.onunload = function () {
	if(showFenster && !showFenster.closed) showFenster.close();
}

function showIMG( IMG_Name, width, height)
{

	Browser = navigator.appName;
	BrowserVersion = navigator.appVersion;
	var Ergebnis = BrowserVersion.search(/MSIE 6.0/);
	if (Ergebnis != -1)
	{
		document.write("<img src='upload/sitelayout/spacer.png' style=\"width: "+width+"px; height: "+height+"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.woehner.com/cms/"+ IMG_Name +"', sizingMethod='scale');\"  border='0' />");
	}
	else
	{
		document.write("<img src=\""+ IMG_Name + "\" border='0'>");
	}
}


function showIMG_class( IMG_Name, width, height, css_class)
{

	Browser = navigator.appName;
	BrowserVersion = navigator.appVersion;
	var Ergebnis = BrowserVersion.search(/MSIE 6.0/);
	if (Ergebnis != -1)
	{
		document.write("<img class='"+css_class+"' src='upload/sitelayout/spacer.png' style=\"width: "+width+"px; height: "+height+"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.woehner.com/cms/"+ IMG_Name +"', sizingMethod='scale');\"  border='0' />");
	}
	else
	{
		document.write("<img class='"+css_class+"' src=\""+ IMG_Name + "\" border='0'>");
	}
}