// Funktionen zum Textwechseln
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6||this.ie7
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie8 || this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this	  
}
var bw=new lib_bwcheck()


if(document.layers){ //NS4 resize fix...
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}

//ChangeText object constructor.
function makeChangeTextObj(obj){
   	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;	
   	this.writeref = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj].document:0;	
	this.writeIt = b_writeIt;					
}
function b_writeIt(text,num){
	if (bw.ns4){
		this.writeref.write(text)
		this.writeref.close()
	}
    else this.writeref.innerHTML = messages[num]
}

//The mouoseover function. Calls the writeIt method to write the text to the div.
function changeText1(num){
	if(bw.bw) oMessage1.writeIt(messages[num], num)
}
function changeText2(num){
	if(bw.bw) oMessage2.writeIt(messages[num], num)
}
function changeText3(num){
	if(bw.bw) oMessage3.writeIt(messages[num], num)
}
function changeText4(num){
	if(bw.bw) oMessage4.writeIt(messages[num], num)
}
function changeText5(num){
	if(bw.bw) oMessage5.writeIt(messages[num], num)
}

//The init function. Calls the object constructor and initiates some properties.
function changeTextInit(){
	//Fixing the browsercheck for opera... this can be removed if the browsercheck has been updated!!
	bw.opera5 = (navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?true:false
	if (bw.opera5) bw.ns6 = 0
	
	oMessage1 = new makeChangeTextObj('divMessage1')
	oMessage2 = new makeChangeTextObj('divMessage2')
	oMessage3 = new makeChangeTextObj('divMessage3')
	oMessage4 = new makeChangeTextObj('divMessage4')
	oMessage5 = new makeChangeTextObj('divMessage5')
	oLinks = new makeChangeTextObj('divLinks')
	//Setting the style properties of the text layer.
//	if(bw.dom || bw.ie4){
//		with(oMessage.writeref.style){fontFamily=msgFont; fontSize=msgFontSize+"px"; color=msgFontColor}
//	}
	//Both layers are hidden by default to prevent users from mousing over them and creating errors while the page loads.
	oMessage1.css.visibility= "visible"
	oMessage2.css.visibility= "visible"
	oMessage3.css.visibility= "visible"
	oMessage4.css.visibility= "visible"
	oMessage5.css.visibility= "visible"
	oLinks.css.visibility= "visible"
}




// Ende Funktionen zum Textwechseln

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWinGMfs(theURL){
detail = window.open(theURL, 'win','width=1020,height=800,scrollbars=auto,resizable=yes');
}
function openWin2(theURL){
detail = window.open(theURL, 'win','width=760,height=500,scrollbars=yes,resizable=yes');
}

function openWinGM(theURL){
detail = window.open(theURL, 'win','width=1020,height=620,scrollbars=auto,resizable=yes');
}

/*
function openWinFoto(theURL){
detail = window.open(theURL, 'win','width=900,height=620,scrollbars=auto,resizable=yes');
}
*/

function openEditWin(theURL){
detail = window.open(theURL, 'edit_h3','width=1020,height=800,scrollbars=yes,resizable=yes');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function make_article(wert,menu,lang,site){
	var theURL = "cms_include/article_edit.php?modul_id="+wert+"&menu_id="+menu+"&lang="+lang+"&site="+site;
	if(site != "main") theURL = "../"+theURL;
//	alert(theURL);
	if(wert > 0) openEditWin(theURL)
	document.edit_area.new_article.selectedIndex = 0;
}

function make_article_news(wert,menu,lang,site){
	var theURL = "cms_include/article_edit.php?modul_id="+wert+"&menu_id="+menu+"&lang="+lang+"&site="+site;
	if(site != "main") theURL = "../"+theURL;
//	alert(theURL);
	if(wert > 0) openEditWin(theURL)
	document.edit_area_news.new_article_news.selectedIndex = 0;
}

function fertig(){
opener.location.reload();
setTimeout('self.close()',1000);
//alert("OK");
}

function framefertig(){
parent.location.reload();
setTimeout('self.close()',1000);
}

if (document.getElementById){
	document.write('<style type="text/css">')
	document.write('.switchcontent{display:none;}')
	document.write('</style>')
}

function expandcontent(cid){
	//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
    document.getElementById(cid).style.display="block";
}

function collapsecontent(cid){
	//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : "block"
        document.getElementById(cid).style.display="none";
}

function expandcontent_pos(pos,cid){
	//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
    var p = pos, x = 0, y = 0; 
    while(p != null) 
    { 
        x += parseInt(p.offsetLeft); 
        y += parseInt(p.offsetTop); 
        p = p.offsetParent; 
    } 
    //alert("Position von "+pos.id+":nx = "+x+"ny = "+y); 
	document.getElementById(cid).style.left=x; 
    document.getElementById(cid).style.top=y+22;
    document.getElementById(cid).style.display="block";
}

function setFontSize(fs) { 
	document.body.style.fontSize=fs+"%";
	//set_footer_height("footer");
	setcookie('msf_font_size', fs, 365, '/');
}

function movepic(whatpic,moveleft,movetop){
	var moveleft;
	var movetop;
	var whatpic;
	document.getElementById(whatpic).style.left = -moveleft;
	document.getElementById(whatpic).style.top = -movetop;
}

function setcookie(name, value, days, path, domain, secure) { 
	var expires = -1; 
	if(typeof days == "number" && days >= 0) { 
		var d = new Date(); 
		d.setTime(d.getTime()+(days*24*60*60*1000)); 
		expires = d.toGMTString(); 
	} 
	value = escape(value); 
	document.cookie = name + "=" + value + ";" + (expires != -1 ? " expires=" + expires + ";" : "") + (path ? "path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "; secure" : ""); 
}

function delcookie(name) { 
	setcookie(name, "-", 0); 
}

function getcookie(name) { 
	var idx = document.cookie.indexOf(name+'='); 
	if(idx == -1) { return null; } 
	value = document.cookie.substring(idx+name.length+1); 
	var end = value.indexOf(';'); 
	if(end == -1) { end = value.length; } 
	value = value.substring(0, end); 
	value = unescape(value); 
	return value; 
}
function cookiesenabled() {
	return navigator.cookieEnabled;
}

