

var version=parseFloat(navigator.appVersion), agent=navigator.userAgent.toLowerCase();
var opera=(agent.indexOf('opera')!=-1)?true:false;
var ie=((document.all)&&(version>=4.0)&&(!opera))?true:false;
var ie4=(agent.indexOf('msie 4')>=0)?true:false;
var ie50=(agent.indexOf('msie 5.0')>=0)?true:false;
var nn4=document.layers?true:false;
var nn6=((version>=5.0)&&((agent.indexOf('netscape')>=0)||(agent.indexOf('gecko')>=0)))?true:false;
var dom=nn6||opera;
var mac=(agent.indexOf("mac")!=-1)?true:false;

var COL_GLOW="#E4E4E4";
var sPrev="", eventobj;
var intended=/INPUT|TEXTAREA|SELECT|OPTION/;

var gbChanges= false ;



function jmpFld(fld,fldTxt) {
	if (fld.value!=null) {
		if (fld.type=='text') {
			fld.focus();
			fld.select();
		}
	}
	else {
		alert(fldTxt);
	}
}

function glow(e) {
	if (!ie&&!dom) return;
	eventobj=nn6?e.target:event.srcElement;
	if (sPrev!="") {
		if (chkValid(sPrev)) {
			sPrev.style.backgroundColor="";
		}
		sPrev=eventobj;
		if (chkValid(eventobj)) {
			eventobj.style.backgroundColor=COL_GLOW;
		}
	} else {
		if (chkValid(eventobj)) {
			eventobj.style.backgroundColor=COL_GLOW;
		}
		sPrev=eventobj;
	}
}

function chkValid(which) {
	if (!ie&&!dom) return;
	if (which.style&&intended.test(which.tagName)){
		if (nn6&&eventobj.nodeType==3) eventobj=eventobj.parentNode.parentNode;
		return true
	} else return false
}

function SelectBox_CheckChange(selBox)
{
	if (selBox.options[selBox.selectedIndex].value == "-----") {
		for(var i=0; i<selBox.length; i++) {
			if (selBox.options[i].defaultSelected) {
				selBox.selectedIndex= i ;
				break ;
			}
		}
	} else {
		gbChanges=true ;
	}

}


function jmpFld(fld,fldTxt) {
	if (fld.value!=null) {
		if (fld.type=='text') {
			fld.focus();
			fld.select();
		}
	}
	else {
		alert(fldTxt);
	}
}


function setFldIn(frm)
{
	frm.style.background='#E4E4E4';
}

function setFldOut(frm)
{
	frm.style.background='#FFFFFF';
}

// function setFldIn(frm){}
// function setFldOut(frm){}



function openWin(lsURL, lsWinName, lbMenuBar, lbScrollBars, lbResizable, x, y)
{
	if (x == null || y == null) {
		x = 450; y = 350 ;
	}
	if (lsWinName == '')  {
		lsWinName = "_blank" ;
	}
	
	var lsWin = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+x+" ,height="+y;
	var theWin = window.open(lsURL, lsWinName, lsWin);
	theWin.creator = self;

	var z = parseFloat(navigator.appVersion);
	if (navigator.appName.substring(0,8) == "Netscape" || z >= 4)
	{
		theWin.focus();
	}

	return false ;
}


function openPrint (lsURL,lsWinName,x,y)
{
	var w =440;
	var h =580;
	var l = (screen.width) ? (screen.width-w)/2 : 0;
	var t = (screen.height) ? (screen.height-h)/2 : 0;

	if (x==null || y==null)
	{
		x=450;
		y=350;
	}

	var lsWin = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+x+" ,height="+y;
	var theWin=window.open (lsURL, lsWinName, lsWin);
	theWin.creator=self;

	var z=parseFloat(navigator.appVersion);
	if (navigator.appName.substring(0,8)=="Netscape" || z>=4)
	{
		theWin.focus();
	}
}

function openPic(url,winName,winParams)	{	//
	var theWindow = window.open(url,winName,winParams);
	if (theWindow)	{theWindow.focus();}
}


function imgPopUp(cont,text, winname,w,h,scroll) {
	var width = (w)? (w) : 700;
	var height = (h)? (h) : 500;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var scrolling = (scroll == 1)? ',scrollbars=yes, resizable=yes, menubar=no' : ',scrollbars=no, resizable=yes, menubar=no'
	var param = "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top; 
	newWin = window.open("", winname, param + scrolling);
	newWin.resizeTo(10, 10);
		setTimeout("putInWindow('" + cont + "', '" + text + "')", 50);
		newWin.focus();
	return false;
}

var xPath = "http://beta.webtop.de:9668/include/config/x.js";

function putInWindow(cont, text) {
	var newCont = "<html><head><title>Preview</title>";
	newCont += "<script type='text/javascript' src=" + xPath + "><\/script>\n";
	newCont += "<script>\n";
	newCont += "window.onload=function(){\n";
	newCont += "var th = 0;\n";
	newCont += "var ih = document.getElementById('img').height;\n";	
	newCont += "var bh = xHeight('body');\n";	
	newCont += "var w = document.getElementById('img').width;\n";
	newCont += "var bw = xWidth('body');\n";
	newCont += "var dw = w-bw;\n";
	newCont += "if(xGetElementById('textBox').innerHTML != ''){\n";
	newCont += "var th = xHeight('textBox')+10;\n";
	newCont += "xTop('textBox', ih);";
	newCont += "xShow('textBox');";
	newCont += "}\n";
	newCont += "var h = ih+th;\n";
	newCont += "var dh = h-bh;\n";	
	newCont += "window.resizeTo(w+8, 0);\n";
	newCont += "window.resizeBy(0, dh);\n";
	newCont += "window.focus();";	
	newCont += "}\n";
	newCont += "\n<\/script>";
	newCont += "</head>";
	newCont += "<body id='body' style='margin: 0; padding: 0; height: 100%; background: #E8E6E4;'>"
	newCont += "<div style='position: relative; z-index: 1; font: 11px Verdana, sans-serif; color:#8A8A8A; margin-top: 30%; text-align: center;'>Bild wird geladen...</div>";
	newCont += "<div id='imageBox' style='position: absolute; z-index: 100; top: 0'><img id='img' src='"+ cont + "' onclick='window.close();' style='cursor: pointer;' title='Fenster schließen'></div>";
	newCont += "<div id='textBox' style='position: absolute;visibility: hidden; z-index: 100; top: 0;padding: 5px 20px; font: 11px Arial, sans-serif; color:#8A8A8A;'>" + text + "</div>";
	newCont += "</body></html>";
	newWin.document.write(newCont);
	newWin.document.close();
}
