//------------------------------------------------------------------
//JS standardmaessig deaktiviert
//------------------------------------------------------------------
JS_enabled						= false;

//------------------------------------------------------------------
//init-Routine
//------------------------------------------------------------------
function initJS()
  {
  JS_enabled					= true;
  }


//------------------------------------------------------------------
// Simple Browser Check
//------------------------------------------------------------------
var ns4 = (document.layers) ? 1 : 0;
var ie  = (document.all) ? 1 : 0;
var ns6 = (document.getElementById && !document.all) ? 1 : 0;


//------------------------------------------------------------------
//String-Funktionen
//------------------------------------------------------------------

//ueberprueft, ob in einem String (strToCheck) nur erlaubte Zeichen (strTyp) enthalten sind
function checkValue(strToCheck,strTyp)
  {
  for(i=0;i<strToCheck.length;i++)
    {
	if(strTyp.indexOf(strToCheck.charAt(i)) == -1)
	  {
	  return false;
	  }
	}
  return true;
  }
  
//zeichen ersetzen
function removeCharFromString(iStr, iChr)
  {
  var startpos = 0;
  var foundpos = 0;
  var newStr   = "";
  while ((foundpos = iStr.indexOf(iChr, startpos)) >= 0)
    {
    newStr = newStr + iStr.substring(startpos, foundpos);
    startpos = foundpos + iChr.length;
    }
  return newStr + iStr.substring(startpos);
  }

//function fuer den adminbereich
function goAdmin()
  {
  document.location.href	= JS_rb+'admin/';
  }
  
//------------------------------------------------------------------
//div funktionen
//------------------------------------------------------------------
function showDiv(strElement)
  {
  if(ie)
    {
	eval(strElement).style.visibility							= 'visible';
	}
  else if(ns4)
    {
	document.eval(strElement).visibility						= 'show';
	}
  else if(ns6)
    {
	document.getElementById(strElement).style.visibility		= 'visible';
	}
  }
  
function hideDiv(strElement)
  {
  if(ie)
    {
	eval(strElement).style.visibility							= 'hidden';
	}
  else if(ns4)
    {
	document.eval(strElement).visibility						= 'hide';
	}
  else if(ns6)
    {
	document.getElementById(strElement).style.visibility		= 'hidden';
	}
  }
  
  
  
//------------------------------------------------------------------
//Fenster-Funktionen
//------------------------------------------------------------------

//popup-fenster, welches erst verschwindet, wenn es tatsaechlich geschlossen wird
//aufruf: modelesswin("http://yahoo.com",600,600)
function modelesswin(url,mwidth,mheight,strOptions,strName)
  {
  if(strOptions != '')
    {
	strOptions		= ','+strOptions;
	}

  if(document.all&&window.print&&1==2) //if ie5
	{
	eval('window.showModelessDialog(url,"","help:0;resizable:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")');
	}
  else
    {
	if(modelesswin.arguments.length == 4)
	  {
	  eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px'+strOptions+'")');
	  }
	else
	  {
	  eval('window.open(url,\''+strName+'\',"width='+mwidth+'px,height='+mheight+'px'+strOptions+'")');
	  }
	}
  }

//Popup
function openAWindowPro(strPfad,strTitel,strOptions)
  {
  window.open(strPfad,strTitel,strOptions);
  }
 
//Popup
function JS_openWindow(strURL,strName,strOptions)
  {
  window.open(strURL,strName,strOptions);
  }

  
  
//------------------------------------------------------------------
//Browserfenster-abhängige Funktionen
//------------------------------------------------------------------
function get_min_breite(wert)
  {
  int_return														= parseInt(screen.width*0.7);
  if(int_return < wert)
    {
	int_return														= wert;
	}
  return int_return;
  }  

function get_min_hoehe(wert)
  {
  int_return														= parseInt(screen.height*0.7);
  if(int_return < wert)
    {
	int_return														= wert;
	}
  return int_return;
  }  
  
  
  
  
//------------------------------------------------------------------
//CS1.1
//neuer sniffer
//------------------------------------------------------------------
var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(/opera[\/ ][5]/.test(agt)){op5=1;}
	if(/opera[\/ ][6]/.test(agt)){op6=1;}
	if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}





//------------------------------------------------------------------
//Ctrl+Shift+A für Admin-Bereich
//------------------------------------------------------------------
function tastendruck(evt)
  {
  if(!evt)
    {
	evt																= window.event;
	}
  if(!document.all || (op7))
    {
	tastencode														= evt.which;
	kc_admin														= 65;
	kc_admin_neuesfenster											= 89;
	kc_admin_medien													= 77;
	kc_admin_logout													= 76;
	}
  else
    {
	tastencode														= evt.keyCode;
	kc_admin														= 1;
	kc_admin_neuesfenster											= 25;
	kc_admin_medien													= 13;
	kc_admin_logout													= 12;
	}

  //------------------------------------------------------------------
  //Ctrl+Shift+A für Admin-Bereich
  //------------------------------------------------------------------
  if(evt.ctrlKey && evt.shiftKey && tastencode == kc_admin)
    {
	document.location												= 'http://'+document.location.hostname+JS_rb+'admin/index.php';
	}
  //------------------------------------------------------------------
  //Ctrl+Shift+Y für Admin-Bereich im neuen Fenster
  //------------------------------------------------------------------
  if(evt.ctrlKey && evt.shiftKey && tastencode == kc_admin_neuesfenster)
    {
	window.open('http://'+document.location.hostname+JS_rb+'admin/index.php','','');
	}
  //------------------------------------------------------------------
  //Ctrl+Shift+M für Medien-Datenbank
  //------------------------------------------------------------------
  if(evt.ctrlKey && evt.shiftKey && tastencode == kc_admin_medien)
    {
	document.location												= 'http://'+document.location.hostname+JS_rb+'admin/index.php#medien';
	}
  //------------------------------------------------------------------
  //Ctrl+Shift+L für Logout
  //------------------------------------------------------------------
  if(evt.ctrlKey && evt.shiftKey && tastencode == kc_admin_logout)
    {
	document.location												= 'http://'+document.location.hostname+JS_rb+'?aktion=centix_user_logout';
	}
  
  /*
  if(evt.shiftKey)
    {
	alert(tastencode);
	}
  */
  }
document.onkeypress 												= tastendruck;




function show_hide_slide_divs(div1,div2)
  {
  document.getElementById(div1).style.display						= 'none';
  document.getElementById(div2).style.display						= 'block';
  }
  
  
  
  
  
  
  
  
var akt_size														= 11;
  
function set_fontsize(wert)
  {
  changeFontsize(parseInt(akt_size)+wert);
  }


function changeFontsize(size)
{
    document.cookie = "cxFontsize" + "=" + size + ";";
    markFontsize();
    setFontsize();
    return false;
};




function markFontsize() {

    var size;
    begin = document.cookie.indexOf("cxFontsize=");

    if (begin != -1) {
        begin += 11; /* Anfang des Wertes */
        end = document.cookie.indexOf(";", begin);
        if (end != -1) {
          size = document.cookie.substring(begin, end);
        } else {
            size = 12;
        }
    } else {
        size = 12;
    }

    /*document.getElementById("fs12").style.textDecoration = "none";
    document.getElementById("fs17").style.textDecoration = "none";
    document.getElementById("fs20").style.textDecoration = "none";

    document.getElementById("fs" + size).style.textDecoration = "underline";*/

    return false;
}


function setFontsize() {

    var size;

    begin = document.cookie.indexOf("cxFontsize=");

    if (begin != -1) {
        begin += 11; /* Anfang des Wertes */
        end = document.cookie.indexOf(";", begin);
        if (end != -1) {
          size = document.cookie.substring(begin, end);
        } else {
            size = 12;
        }
    } else {
        size = 12;
    }
    document.getElementsByTagName("body")[0].style.fontSize			= size + "px";
	//document.getElementsByTagName("td").style.fontSize				= size + "px";
	//document.getElementsByTagName("h3").style.fontSize				= (parseInt(size)+2) + "px";
	akt_size														= size;
    return false;
}


//------------------------------------------------------------------
// divs auf/zu
//------------------------------------------------------------------
function oc(ss_close,ss_open)
  {
  // schliessen
  if(ss_close != '')
    {
	arr_close														= ss_close.split(',');
	for(i=0;i<arr_close.length;i++)
	  {
	  document.getElementById(arr_close[i]).style.display			= 'none';
	  }
	}
  // oeffnen
  if(ss_open != '')
    {
	arr_open														= ss_open.split(',');
	for(i=0;i<arr_open.length;i++)
	  {
	  document.getElementById(arr_open[i]).style.display			= 'block';
	  }
	}
  }


//------------------------------------------------------------------
// screenbreite
//------------------------------------------------------------------
function setScreenType(screentype)
  {
  bclass															= document.body.className;
  document.body.className											= screentype;
  createCookie("ScreenType", screentype, 365);
  try
    {
    //map.checkResize();
    actions_after_set_screen_type();
	}
  catch(e)
    {}
  }
function createCookie(name,value,days)
  {
  if(days) 
    {
    var date														= new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires														= "; expires="+date.toGMTString();
    }
  else
    {
	expires															= "";
	}
  document.cookie													= name+"="+value+expires+"; path=/";
  }
