var crlf=String.fromCharCode(13,10)
var lookBackColor="e7e7e7";var lookForeColor="000000";var lookBoxBackColor="666666";var lookBoxForeColor="ffffff";
var picEnlargeNr=0
var bodyOverflowEx="";if(b_sys==0){if(b_type==1){bodyOverflowEx="overflow: auto;"}}
var mw_rot="#D55E61"
var mw_gruen="#8BB57D"
var mw_blau="#6B75C7"
var mw_dklblau="#394980"
var mw_gelb="#FF9933"
var mw_oliv="#C2C76B"
var mw_grau="#CCCCCC"


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function windowPlace(w,h){
	winPos=new Array
	if(window.innerWidth){allX = (window.innerWidth - w) / 2}
	else{allX=(document.body.offsetWidth-w-4)/2}
	if(allX<0){allX=0};allX=Math.floor(allX)
	if(window.innerHeight){allY = (window.innerHeight - h) / 2}
	else{allY=(document.body.offsetHeight-h-4)/2}
	if(allY<0){allY=0};allY=Math.floor(allY)
	if(window.screenX){allX=allX+window.screenX}
	else{allX=allX+window.screenLeft;}
	if(window.screenY){allY=allY+window.screenY}
	else{allY=allY+window.screenTop;}

	winPos=[allX,allY]
	return winPos
}

function drawDiv(name,x,y,w,h,backCol,foreCol,borderCol,bordW,cur,t,fontFam,cl,ext,styleEx){
	if (cur!==""){
		if(b_sys==0){
			if(b_type!==1){if(cur=="hand"){cur="cursor: pointer;"}}
			else{cur="cursor: " + cur + ";"}
		}
		else{if(cur=="hand"){cur="cursor: pointer;"}}
	}
	else{cur="cursor: default;"}
	
	if(backCol!==""){
		if(backCol.substr(0,1)=="#"){backC="background-color: " + backCol + ";"}
		else{backC="background-image: url(" + backCol + ");"}
	}
	else{backC=""}
	if(b_sys==0){
		if ((b_type!==1) &&  borderCol!==""){w=w-(bordW*2);h=h-(bordW*2);}
	}

	if(borderCol!==""){bord='border: ' + bordW + 'px solid ' + borderCol + ';'}else{bord=''}
	if(cl==1){clTag="</div>"}else{clTag=""}
	re='<div id="' + name + '" class="' + fontFam + '" style="position:absolute; margin: 0px; width:' + w + 'px; height:' + h + 'px; z-index:3; left: ' + x + 'px; top: ' + y + 'px; color: ' + foreCol + '; ' + bord + cur + backC + styleEx + '" ' + ext + '>' + t + clTag
	return re
}

function drawDivPic(name,x,y,w,h,backCol,foreCol,borderCol,bordW,cur,t,fontFam,cl,ext,styleEx,pic,alt){
	if (cur!==""){
		if(b_sys==0){
			if(b_type!==1){if(cur=="hand"){cur="cursor: pointer;"}}
			else{cur="cursor: " + cur + ";"}
		}
		else{if(cur=="hand"){cur="cursor: pointer;"}}
	}
	else{cur="cursor: default;"}	
	
	
	var re=""
	re+=drawDiv(name,x,y,w,h,backCol,foreCol,borderCol,bordW,cur,t,fontFam,0,ext,styleEx)
	if(borderCol!==""){w=w-(bordW*2);h=h-(bordW*2)}
	re+='<img name="pic' + name + '" id="pic' + name + '" src="' + pic + '" width="' + w + 'px" height="' + h + 'px" galleryimg="no" style="position: absolute; left: 0px; top:0px; ' + cur + ' " alt="' + alt + '">'
	re+='</div>'
	return re
}


function goPicView(p,t,a){
	if(t!==""){t="&pictext=" + t}
	if(a!==""){a="&picauthor=" + a}
	//closeAllWin()
	pictureWindow=myWindowOpen("showpicture.php?c1=" + lookBackColor + "&c2=" + lookForeColor + "&c3=" + lookBoxBackColor + "&c4=" + lookBoxForeColor + "&picPath=" + p + t + a,"","width=100px , height=100px, left=50px, top=50px, scrollbar=none")
}

function drawInputBox(n,x,y,w,t,l,val,ex){
	HTMLst=""
	if(b_sys==0 && b_type!==1){y=y+1}
	if(t!==""){
		HTMLst+='<div id="' + n + 'Text" class="normTextBold" style="font-weight: bold; position:absolute; width:' + w + 'px; height:16px; z-index:0; left: ' + x + 'px; top: ' + y + 'px;">' + t + '</div>'
		y=y+12
	}
	HTMLst+='<div id="' + n + 'Back" style="position:absolute; width: ' + w + 'px; height: 19px; left: ' + x + 'px; top: ' + y + 'px; z-index:10"><input type="text" name="' + n + '" id="' + n + '" class="normTextBold" style="border: 1px solid #000000; background-color: #ffffff; color: #000000;  width: ' + w + 'px; height: 18px;" maxlength="' + l + '" value="' + val + '" ' + ex + '></div>'
	return HTMLst
}

function getCookie(name){
	var arg = name + "=";var alen = arg.length;var clen = document.cookie.length;var i = 0;
	while (i < clen) {
   		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
    		i = document.cookie.indexOf(" ", i) + 1;
    		if (i == 0)
       			break;
		}
	return null;
}

function getCookieVal (name) {
	var offset = document.cookie.indexOf (name);
    if (offset > -1){
		//endstr == -1
     	endstr = document.cookie.length;
     	return unescape(document.cookie.substring(offset, endstr));
	}
}

function setCookie (name, value) {  
	var argv =setCookie.arguments;
    var argc = setCookie.arguments.length;

	var expires = new Date();
	expires.setTime(expires.getTime() + (24*60*60*365*1000));       
	var path = (argc > 3) ? argv[3] : null;  
    var domain = (argc > 4) ? argv[4] : null;  
    var secure = (argc > 5) ? argv[5] : false;  
        
	document.cookie = name + "=" + escape (value) + 
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
    ((path == null) ? "" : ("; path=" + path)) +  
    ((domain == null) ? "" : ("; domain=" + domain)) +    
    ((secure == true) ? "; secure" : "");
}

function deleteCookie (name, value) {  
        //alert (value)
	var argv =deleteCookie.arguments;
    var argc = deleteCookie.arguments.length;

	var expires = new Date();
	expires.setTime(expires.getTime() - 1);       
	var path = (argc > 3) ? argv[3] : null;  
        var domain = (argc > 4) ? argv[4] : null;  
        var secure = (argc > 5) ? argv[5] : false;  
        
	document.cookie = name + "=" + escape (value) + 
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
        ((path == null) ? "" : ("; path=" + path)) +  
        ((domain == null) ? "" : ("; domain=" + domain)) +    
        ((secure == true) ? "; secure" : "");
}

function checkUrl(t){
	if(t==""){return t}
	t2=t.toLowerCase()
	if(t2.indexOf("http://")!==0 && t2.indexOf("https://")!==0){if(t2.indexOf("ww")<0){t="www." + t};t="http://" + t}
	return t
}

function checkEmail(emailStr){
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	
	if(matchArray==null){return false;}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	for(i=0; i<user.length; i++){if(user.charCodeAt(i)>127){return false;}}
	for(i=0; i<domain.length; i++){if(domain.charCodeAt(i)>127){return false;}}
	if(user.match(userPat)==null){return false;}
	var IPArray=domain.match(ipDomainPat);
	if(IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){return false;}}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for(i=0;i<len;i++){if (domArr[i].search(atomPat)==-1){return false;}}
	if(checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1){return false;}
	if(len<2){return false;}
	return true;
}

function testedFileName(fN){
	fN=fN.toLowerCase()
	fN=fN.replace(/ /g,"_")
	fN=fN.replace(/\ä/g,"ae")
	fN=fN.replace(/\ö/g,"oe")
	fN=fN.replace(/\ü/g,"ue")
	fN=fN.replace(/\ß/g,"ss")
	return fN
}

function trim(t){
	if(t!==""){
		start=0
		for(i=0;i<t.length;i++){if(t.substr(i,1)==" "){start=i+1}else{break}}
		ende=(t.length)
		for(i=(t.length-1);i>-1;i--){if(t.substr(i,1)==" "){ende=i}else{break}}
		t=t.substr(start,ende-start)
	}
	return t
}

function replaceSigns(t,signList,leer){
	if(leer==1){t=trim(t)}
	for(i=0;i<signList.length;i++){t2=t.split(signList.substr(i,1));t=t2.join("")}
	if(leer==3){t=t.replace(/\r\n/g,"<br>")}
	return t
}

function replaceQuotes(t){
	t=t.replace(/\\\'/g,"\'")
	t=t.replace(/\\\"/g,'\"')
	return t
}

function presseTextDeco(index,ob){
	weight=["normal","bold"];deco=["","underline"]
	obj=eval("document.getElementById('" + ob + "')")
	obj.style.fontWeight=weight[index];obj.style.textDecoration=deco[index]
}
		
		

var b_sys=0
var b_type=1
var b_vers=-1

var uAgent= navigator.userAgent.toLowerCase()

if (uAgent.indexOf("mac")!= -1){
	b_sys=1//Macintosh System
}
else{
	if ((uAgent.indexOf('mozilla') != -1) && (uAgent.indexOf('spoofer')== -1) && (uAgent.indexOf('compatible') == -1) && (uAgent.indexOf('opera') == -1)) {
		if ((uAgent.indexOf('rv:1.') != -1) && (uAgent.indexOf("netscape") == -1)) {
			b_type=3//Mozilla
		} 
		else {
			b_type=2//Navigator
		}
	}
	if ((uAgent.indexOf("msie") != -1) && (uAgent.indexOf("opera") == -1)){b_type=1}//InternetExplorer
	if (uAgent.indexOf("opera") != -1){b_type=4}
}

var cookieEnabled=navigator.cookieEnabled

function formatHT(t){
	pStart=0;pos=0;t2="";urlNr=0;mailNr=0
	while(pos!==-1){
		pos=t.indexOf("{",pStart)
		if(pos>0){
			noClose=0;end=t.indexOf("}",pos)
			if(end>-1){end2=t.indexOf("{",pos+1);if(end2>-1){if(end>=end2){noClose=1}}}
			if(noClose==0){
				sText=t.substr(pos+1,end-pos-1)
				if(checkEmail(sText)){
					t=t.substr(0,pos-1) + ' <a id="email' + mailNr + '" onmousemove="presseSetBold(\'email' + mailNr + '\',1)" onmouseout="presseSetBold(\'email' + mailNr + '\',0)" href="mailto:' + sText + '" class="textBody" style="text-decoration: underline;cursor: pointer">' + sText + '</a>' + t.substr(end+1)
					mailNr++					
				}
				else{
					sText=checkUrl(sText)
					t=t.substr(0,pos-1) + ' <a id="url' + urlNr + '" onmousemove="presseSetBold(\'url' + urlNr + '\',1)" onmouseout="presseSetBold(\'url' + urlNr + '\',0)" onclick="presseGoWeb(\'' + sText + '\')" class="textBody" style="text-decoration: underline;cursor: pointer">' + sText + '</a>' + t.substr(end+1)
					urlNr++
				}
			}
		}
		pStart=pos+1
	}
	return t
}

function presseGoWeb(url){
	window.open(url)
}
function presseGoEMail(adr){
}
function presseSetBold(dObj,index){
	weight=["normal","bold"]
	obj=eval('document.getElementById("'+ dObj +'")')
	obj.style.fontWeight=weight[index]
}

function getRealWidth(obj){
	tab=document.getElementById("checkBoxSize");t=obj.innerHTML;t=t.replace(/ /g,".");tab.innerHTML=t;tab.className=obj.className
	return tab.offsetWidth
}

function getRealHeight(obj){
	tab=document.getElementById("checkBoxSize2");
	tab.innerHTML=obj.innerHTML;
	tab.style.width=obj.style.width;
	tab.style.height=10
	tab.style.overflow="scroll"
	tab.className=obj.className
	tab.style.height=tab.scrollHeight
	return tab.scrollHeight
}



