
function openNewWindow(url,width,height,iDefaultPosTop,iDefaultPosLeft,Userparam){
var iPosLeft;
var iPosTop;
if (screen.width){
	iPosLeft=(screen.width/2)-width/2;
	iPosTop=(screen.height/2)-height/2;
}
else{
	iPosLeft=iDefaultPosLeft;
	iPosTop=iDefaultPosTop;
}
param=Userparam+",top="+String(iPosTop)+",left="+String(iPosLeft);
window.open(url, "", "width="+width+",height="+height+","+param);
}

/*!!Do not delete this function!!.
You need this function to use the validation of the formulargenerator.*/

function getFieldValue ( theField, vType){
	//this function will return the field value (or value list) based on the element type
	theValue=""; 
	sep=";"; 
	hits=0;
	vType=vType.toLowerCase();
	//text is the user-entered value as a string
	if(vType=="text" ) return(theField.value); 
	//textarea is the user-entered value as a string array of one element
	if(vType=="textarea" ) return(theField.value);
	//select is an array of selection pointers to an array of strings representing the choices
	if(vType=="select"){
		for ( i=0; i<theField.options.length; i++){
			if(theField.options[i].selected){
				hits++;
				if(theField.options[i].value==""){
					e=theField.options[i].text;
				}else{ 
					e=theField.options[i].value;
				}
				if(hits==1){
					theValue=e;
				}else{
					theValue+= sep+e;
				}
			}
		}
		return(theValue);
	}
	if(vType=="dropdown"){
		if(theField.options[0].selected){
			return("");
		}
		return("True");
	}
	// check Emailaddress
	if(vType=="mail"){
		var mail=theField.value;
		if(mail==""){
			return ("");
		}else{
			var erg =mail.search(/.+@..+\...+/);
			if(erg==-1){
				return ("");
			}
			var erg=mail.search(/\s/);
			if(erg!=-1){
				return ("");
			}
		}
		return (mail);
	}
	//checkboxes & radio buttons
	if(vType=="checkbox"||vType=="radiobutton"){
		if(theField.value==null){
			//if we're here, we are validating a radio button or a nn multi-element checkbox
			for ( i=0; i<theField.length; i++){
				if(theField[i].checked){
					hits++;
					if(hits==1){
						theValue=theField[i].value;
					}else{
						theValue+= sep+theField[i].value;
					}
				} 
			}
		} 
		return(theValue);
	}else{
		return(theField.value);
	}
}

/* Use this function to open a link. Use any htmltag with parameter "value (URL [|"_self"])"  to open the url. */

function openElementLink(objField,sType){
var sFieldValue=getFieldValue(objField,sType);

if (sFieldValue!=""){
	var aValue=sFieldValue.split("|");
	if(aValue[1]=="_self"){
		 location.href=aValue[0];
	}
	else{
		window.open(aValue[0]);
	}
}
}

/*Bottomline*/

function addToFavoritesDE(pagename){
	var errmsg="Ihr Browser unterstützt leider kein automatisches Hinzufügen von Seiten zu den Favoriten. Vermutlich handelt es sich nicht um den Internet Explorer. Bitte verwenden Sie das entsprechende Menü-Kommando ihres Browsers, um diese Seite zu Ihren Lesezeichen hinzuzufügen. Vielen Dank!";
	return addToFavorites(pagename,errmsg);
}
function addToFavoritesEN(pagename){
	var errmsg="Your browser does not support automated adding to favourites, probably you are not using Internet Explorer. However, please yuse your browsers menu command for bookmarking instead. Thank you!";
	return addToFavorites(pagename,errmsg);
}
function addToFavorites(pagename,errmsg){
	if(window.external){
		window.external.AddFavorite(location.href,pagename)
	}else{
		// this is not an Internet Explorer
		alert(errmsg);
	}
	return false;
}

function switchCSS(element,classname){
	if(is.ie){
	 	obj=document.all[element];
	 	if(obj){
			obj.className=classname;
		}
	}
	if(is.moz||is.opera||is.opera6||is.ns6||is.ns7){
		obj=document.getElementById(element);
	 	if(obj){
			obj.className=classname;
		}
	}
}

/* 2 functions
function GetCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // a cookie with the requested name does not exist
  return null;
}

*/
function enter(){
	var hotkey=13;
	if (document.layers)
	document.captureEvents(Event.KEYDOWN)
	if (document.layers){		 		 		 
		if(e.which==hotkey)loginSubmit();
	}else if (document.all){
		 if(event.keyCode==hotkey)loginSubmit();
	}
}

var UNdefValue="Name";
var UNtmpStyle=null;
function UNonFocus(o){
	if(o){
		if(o.value){
			if(o.value==UNdefValue){
				o.value=''
			}
		}
		if(o.style.getAttribute){
			UNtmpStyle=o.style.getAttribute("bordercolor","false");
			o.style.setAttribute("bordercolor","#d00021","false");
		}
	}
}

function UNonBlur(o){
	if(o){
		if(o.value==''){
			o.value=UNdefValue;
		}
		if(o.style.setAttribute){
			o.style.setAttribute("bordercolor",UNtmpStyle,"false");
		}
	}
}

var PWtmpStyle=null;
function PWonFocus(o){
	if(o){
		if(o.style.getAttribute){
			PWtmpStyle=o.style.getAttribute("bordercolor","false");
			o.style.setAttribute("bordercolor","#d00021","false");
		}
		o.select();
	}
}

function PWonBlur(o){
	if(o){
		if(o.style.setAttribute){
			o.style.setAttribute("bordercolor",PWtmpStyle,"false");
		}
	}
}

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

function getCookie(name){
	var dc=document.cookie;
	var prefix=name+"=";
	var begin=dc.indexOf("; "+prefix);
	if(begin==-1){
		begin=dc.indexOf(prefix);
		if(begin!=0) return null;
	} 
	else begin+=2;
	var end=document.cookie.indexOf(";", begin);
	if(end==-1) end=dc.length;
	return unescape(dc.substring(begin+prefix.length, end));
}

function fixDate(date) {
        var base = new Date(0)
        var skew = base.getTime()
        if (skew > 0)
                date.setTime(date.getTime() - skew)
}
function startLogin() {
  formobj = document.formlogin;
  if(formobj.NickName.value == "")
  {
     alert("Please enter your Nickname");
     return false;
  }		
  var now = new Date();
  fixDate(now);
  now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
  setCookie("SametimeNickname",formobj.NickName.value, now,'/');
}

function NewWindowOPM(z)
{
 window.open(z,  "", "width=400,height=200,scrollbars=no,resizable=no");
}

function loginSubmit() {
var formobj = document._DominoForm;
document.cookie="sessionCookie=troet";
		 (getCookie("sessionCookie"))?formobj.submit():alert ("Please enable sessionbased cookies in your browser \npreferences and reload the page!");
}
