// Client Informationen auslesen OS und Browser
var bcDetect = navigator.userAgent.toLowerCase();
var _OS,_BROWSER;
var requireds = new Array();

function str_replace(from,to,str) {
	var ret;
	text = text.replace(/\//g,'\/');
	text = text.replace(/\^/g,'\\^');
	text = text.replace(/\$/g,'\\$');
	text = text.replace(/\+/g,'\\+');
	
	//from=from.replace(/\*/g,'\\/');
	var evl='ret=str.replace(/'+from+'/g,to);';
	//prompt('',evl);
	eval(evl);
	return ret;
}

function checkRequireds(form)
{
	retVal = true;
	for (a in form.elements) {
		el = form.elements[a];
		if (el.id in requireds) {
			if (!el.disabled) {
				if (el.value == "") {
					msg = requireds[el.id];
					alert(msg);
					el.focus();
					retVal = false;
					break;
				}
			}
		}
	}
	return retVal;
}

if (bcCheckIt('konqueror')) { _BROWSER = "KONQUEROR"; _OS = "LINUX"; }
else if (bcCheckIt('safari')) { _BROWSER = "SAFARI"; }
else if (bcCheckIt('omniweb')) { _BROWSER = "OMNIWEB"; }
else if (bcCheckIt('opera')) { _BROWSER = "OPERA"; }
else if (bcCheckIt('webtv')) { _BROWSER = "WEBTV"; }
else if (bcCheckIt('icab')) { _BROWSER = "ICAB"; }
else if (bcCheckIt('msie')) { _BROWSER = "INTERNET_EXPLORER"; }
else if (bcCheckIt('firefox')) { _BROWSER = "FIREFOX"; }
else if (!bcCheckIt('compatible')) { _BROWSER = "NETSCAPE"; }
else { _BROWSER = "UNKNOWN"};

if (!_OS)
{
	if (bcCheckIt('linux')) _OS = "LINUX";
	else if (bcCheckIt('x11')) _OS = "UNIX";
	else if (bcCheckIt('mac')) _OS = "MAC"
	else if (bcCheckIt('win')) _OS = "WINDOWS"
	else _OS = "UNKNOWN";
}

function bcCheckIt(string)
{
	var place = bcDetect.indexOf(string) + 1;
	return place;
}

function openWin(url, width, height, id) {
	popupWin = window.open(url, id, 
		'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=' + 
		width + ',height=' + height + ',left=50,top=50')
}

function showImage(url, width, height) 
{
	width += 25;
	height += 30;
	window.open(url, null, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width='+width+',height='+height+',left=50,top=50')	;
}	

function changeImage(imageName, image)
{
	if (image != "") {
		window.document.images[imageName].src = image;
	}
}

function loadPages(link1, link1Target, link2, link2Target, framesToReload, appendToUrl)
{
	if ((link1 != "") && (link1Target != link2Target)) {
		if (link1Target != "") {
    		parent.frames[link1Target].location.href = link1;
		} else {
			location.href = link1;
		}
	}

	if (link2 != "") {
		if (link2Target != "") {
			parent.frames[link2Target].location.href = link2;
		} else {
			location.href = link2;
		}
	}

	if (framesToReload) {
		framesArray = framesToReload.split(',');
		for (i = 0; i < framesArray.length; i++) {
			frameName = framesArray[i];
			if (parent.frames[frameName]) {
				link = parent.frames[frameName].location.href;
				if (appendToUrl) {
					link = link + "&" + appendToUrl;
				}
				parent.frames[frameName].location.href = link;
			}
		}
	}
}

function reloadMainFrame(mainFrameName, exchangeInUrl)
{
	if ((window.name != mainFrameName) && (parent.frames)) {
		frameCount = parent.frames.length;
		for (var i = 0; i < frameCount; i++) {
			if (parent.frames[i].name == mainFrameName) {
				targetUrl = parent.frames[i].location.href;
				
				if (exchangeInUrl != "") {
					params = exchangeInUrl.split("&");
					for (var k = 0; k < params.length; k++) {
						param = params[k].split("=");
						if (param.length == 2) {
							key = param[0];
							value = param[1];
							index = targetUrl.indexOf(key);
							if (index > -1) {
								newTargetUrl = targetUrl.substring(0, index) + key + "=" + value;
								tmp = targetUrl.substring(index, targetUrl.length);
								index2 = tmp.indexOf("&");
								if (index2 > -1) {
									newTargetUrl += tmp.substring(index2, tmp.length);
								}
								targetUrl = newTargetUrl;
							}
						}
					}
				}
				
				parent.frames[i].location.href = targetUrl;
				break;
			}
		}
	}
}

