// browser detection
var ie4 = (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
var nn4 = (navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4);
// general variables
var totalpath = window.location.pathname;
var pos = totalpath.lastIndexOf(".nsf");
var urlPath = totalpath.substring(0,pos + 4);
var oldSelfURL = "";
// open an additional browser window, parameters: source, width, height and scrollbar-option
function openWin(winSrc,winW,winH,winSb) {
  dsp = open(winSrc , 'addwin' , 'width=' + winW + ',height=' + winH + ',scrollbars=' + winSb + ',resizeable=no');
  setTimeout('dsp.focus()',500);
}
// trigger for statistic function
function intPageCount(und) {
	c = open(urlPath + '/(CountDocumentRequests)?OpenAgent&' + und , 'counter' , 'width=1,height=1,scrollbars=no,resizeable=no');
	c.close();
}
// trims beginning and end of filed entries, cuts white spaces
function trim(obj){
  	obj.value = obj.value.replace(/^ +/,"");
  	obj.value = obj.value.replace(/ +$/,"");
    	obj.value = obj.value.replace(/  +/g," ");
}
// trims search string in the query field of the search form
function trimSearch(obj){
  	obj.value = obj.value.replace(/^ +/,"");
  	obj.value = obj.value.replace(/ +$/,"");
    	obj.value = obj.value.replace(/  +/g," ");
  	obj.value = obj.value.replace(/\W+/g,"+");
}
// changes URL
function chgURL(doc) {
  var winOpen = false;
  location.href = urlPath + "/" + doc;
}
// print script
function prCurrDoc() {
	if (navigator.appName == "Netscape") {
	window.print();
	}
	
	else {
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </OBJECT>';
	
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	WebBrowser1.ExecWB(6,2);						//Use a 1 vs. a 2 for a prompting dialog box
	WebBrowser1.outerHTML = "";
	}
}
// input validation
function checkQuery(fld) {
	f = document.forms[0];
	result = true;
	if(fld.value == "" && (f.LUPContCat.selectedIndex == 0 && f.LUPContTitle.selectedIndex == 0)) {
		alert("Geben Sie bitte einen Suchbegriff ein.");
		fld.focus();
		result = false;
	}
	return result;
}
function checkMail() {
	f = document.forms[0];
	result = true;
	if(f.Conf_Company.value == "" && f.Conf_Name.value == "" && f.Conf_FstName.value == "") {
		alert("Bitte nennen Sie uns Ihren Firmennamen oder eine Person als Ansprechpartner.");
		result = false;
		f.Conf_Name.focus();
	}
	if(f.Conf_Phone.value == "" && f.Conf_Fax.value == "" && f.Conf_Mail.value == "") {
		alert("Um mit Ihnen Kontakt aufnehmen zu können, brauchen wir\neine Telefon- bzw. Faxnummer und/oder eine EMailadresse.");
		result = false;
		f.Conf_Phone.focus();
	}
	if(f.Conf_Subject.value == "") {
		alert("Bitte geben Sie zur besseren Bearbeitung einen Betreff an.");
		result = false;
		f.Conf_Subject.focus();
	}
  	// -- checking spelling of the mailaddress --
  	mail_test = /.@(\w.+).(\w{2,})/;
 	if(f.Conf_Mail.value != "" && mail_test.test(f.Conf_Mail.value) == false) {
   		alert("Ihre Mailadressen-Angabe enthält einen Formfehler.");
   		result = false;
		f.Conf_Mail.focus();
  	}
	return result;
}
// Ticker onmouseover handling for MSIE
function delayScrolling(speed) {
	if(document.all) document.all.scrMsg.setAttribute("scrollamount", speed ,"false");
}
// Login and document/frame reloading
function login() {
	if(parent.frames.length == 0) {
		getURL = location.href;
		location.href = getURL + "&login";
	}
	else {
		getURL = new Array;
		for(i = 0 ; i < parent.frames.length ; i++) {
			getURL[i] = parent.frames[i].location.href;
			parent.frames[i].location.href = getURL[i] + "&login";
		}	
	}
}

