var isSet_timerID=0;
var timerID=1;
var timeSr=1;
var subNavActive=0;
var subNavPosActive=0;

var timerID2=1;


function resize_me(n)
{
    d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    
    if (window.frames[n]){
	    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
	    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
    }
}


function lesezeichen_moeglich()
{
  if(!window.external)
    return false
  return true
}

function addfavourite(verweis, name)
{
  if(!lesezeichen_moeglich())
  {
    alert("Diese Funktion wird von Ihrem Browser nicht unterstuetzt!")
    return
  }
  window.external.AddFavorite(verweis, name)
}

 function ImageBook(){
 }

/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 *
 * @return  boolean  whether pointer is set or not
 */

function setPointer(theRow, thePointerColor, thePointerColor2, activemenu, line1, line2)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    
    // ********* navi
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }
    var counter=0;
    var rowCellsCnt  = theCells.length; 
    
    for (var c = 0; c < rowCellsCnt; c++) {
        counter=counter+1
        if (counter!=1 && counter!=2 && counter!=3 && counter!=4 && counter!=6 && counter!=5)
            theCells[c].style.backgroundColor = thePointerColor;
        if (counter==2)
            theCells[c].style.backgroundColor = thePointerColor2;

    }


    // ********* line1
    lineRow = document.getElementById(line1);

    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = lineRow.getElementsByTagName('td');
    }
    else if (typeof(lineRow.cells) != 'undefined') {
        var theCells = lineRow.cells;
    }
    else {
        return false;
    }
    var counter=0;
    var rowCellsCnt  = theCells.length;
    
    for (var c = 0; c < rowCellsCnt; c++) {
        counter=counter+1
        if (counter!=1 && counter!=2 )
            theCells[c].style.backgroundColor = thePointerColor;
        if (counter==2)
            theCells[c].style.backgroundColor = thePointerColor2;

    }

    // ********* line2
    lineRow = document.getElementById(line2);

    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = lineRow.getElementsByTagName('td');
    }
    else if (typeof(lineRow.cells) != 'undefined') {
        var theCells = lineRow.cells;
    }
    else {
        return false;
    }
    var counter=0;
    var rowCellsCnt  = theCells.length;
    
    for (var c = 0; c < rowCellsCnt; c++) {
        counter=counter+1
        if (counter!=1 && counter!=2   )
            theCells[c].style.backgroundColor = thePointerColor;
        if (counter==2)
            theCells[c].style.backgroundColor = thePointerColor2;

    }

    return true;
} // end of the 'setPointer()' function


function setPointerCell(theCell, thePointerColor, activemenu)
{
    if (thePointerColor == '' || typeof(theCell.style) == 'undefined') {
        return false;
    }

       //if (counter!=1 && counter!=5)
    theCell.style.backgroundColor = thePointerColor;

    return true;
} // end of the 'setPointer()' function



function openDoc(doc)
{
  popup_window = open(doc,"","width=700,height=600,screenX=0,screenY=0, resizable=yes");
  popup_window.focus();
}

function openDocxy(doc,name,x,y)
{
  popup_window = open(doc,name,"width="+x+",height="+y+",screenX=0,screenY=0, resizable=yes scrollbars=yes");
  popup_window.focus();
}

function openDocxy2(doc,name,x,y)
{
  popup_window = open(doc,name,"width="+x+",height="+y+",screenX=0,screenY=0, resizable=yes scrollbars=no");
  popup_window.focus();
}

function turnoff() {
   if (isSet_timerID==0) {
      if (timeSr) {
         timerID = setTimeout('all_menu(0)',1200)
         isSet_timerID=1
      } else { timeSr=1; }
   }
   return;
}

function cmtimeout() {
   if (timerID==0) { timeSr=0; return; }
   clearTimeout(timerID);
   isSet_timerID=0;
   timerID=0;
   return;
}

var old_name = old_name2;
function navigate(nr,onoff,name)  {
//alert(subYNavPosition);
    if (loaded==1 && subYNavPosition  && subXNavPosition && menus){
        if (onoff==1)  {
           cmtimeout();
           if (!all_menu_on) { all_menu(1) };
           if (old_name != '') {
              if (old_nr == nr) {
                   hideMenu(menuToHide);
                  }
                  else {
                    hideMenu(menuToHide);               
                 }
              }
           old_name=name;
           old_nr=nr;
           activateMenu(nr);
        } else {
           turnoff();
        }
    }
}

var version  = navigator.appVersion.substr(0,1);
var isNS = (navigator.userAgent.indexOf('MSIE')  == -1);
var isIE = (navigator.userAgent.indexOf('MSIE')  > -1);
if (isIE) {version  = navigator.appVersion.substr(22,1)};
var isMacIE = ( (navigator.userAgent.indexOf('IE 4')  > -1) && (navigator.userAgent.indexOf('Mac')  > -1) );
var browser = (isNS) ? 'NS' : ((isMacIE) ? 'MacIE' : 'IE');
var layerRef = (isNS) ? 'document' : 'document.all';
var styleRef = (isNS) ? '' : '.style';
var isDynamic = ( (document.layers || document.all || ((isNS || isIE) && version>4)) && !isMacIE );

//var query = location.href.split('?');
//if (!(isIE && version==5) && !query[1]) {location.replace(location.href + '?' + browser + version)};

function element(el_name) {
  if (el_name){
      if (version>4) {
          if (document.getElementById(el_name))
              return document.getElementById(el_name).style
      } else {
        if (isNS) {
          return document[el_name]
        } else {
          return document.all[el_name].style
        }
      }
  }
}

var activeMenu = 0;

function activateMenu(menuLayerRef) {
   if (isDynamic && activeMenu != menuLayerRef) {
      if (activeMenu) 
        hideMenu('menu' + activeMenu);
      menuID = 'menu' + menuLayerRef;
      activeMenu = menuLayerRef;
      showMenu(menuID);
   }
}

function locateSubNavigation(menuLayerRef, ypos, xpos) {

   if (activeMenu != menuLayerRef) {
     menuNr = 'menu' + menuLayerRef;

if (element(menuNr))
    if (isNS ) {
            // NETSCAPE
            if (version>4){
              element(menuNr).top = ypos+plop_subnav_ns2_y;
              element(menuNr).left = xpos+plop_subnav_ns2_x;
            }
            else
            { // NETSCAPE
              element(menuNr).top = ypos+plop_subnav_ns1_y;
              element(menuNr).left = xpos+plop_subnav_ns1_x;
            }
         }
         else
         {  // IE
            element(menuNr).pixelTop = ypos+plop_subnav_ie_y;
            element(menuNr).pixelLeft = xpos+plop_subnav_ie_x;
         }
       }
}

function locateTip(menuLayerRef, ypos, xpos) {
   if (activeMenu != menuLayerRef) {
     menuNr = menuLayerRef;
     if (isNS) {
        if (version>4){
          element(menuNr).top = ypos+1;
          element(menuNr).left = xpos+131;
        }
        else
        {
          element(menuNr).top = ypos-1;
          element(menuNr).left = xpos+130;
        }
     }
     else
     {
        element(menuNr).pixelTop = ypos+15;
        element(menuNr).pixelLeft = xpos+136;
     }
   }
}

function showMenu(layerID) {
   if (element(layerID)){
    element(layerID).visibility = "visible";
   }
}

function hideMenu(layerID) {
 if (element(layerID)){
   element(layerID).visibility = "hidden"
}
}

function killMenu(e) {
   if (activeMenu) {
      menuID = 'menu' + activeMenu;
      hideMenu(menuID);
   if (activemenu_open==1)   
      showMenu(menuToHide);
      activeMenu = 0;
   }
}


function showTip(mainMenu, subMenu) {
    var tipNr;
    cmtimeout();
    mainMenuNr = 'menu'+mainMenu;
    tipNr = 'tip_'+mainMenu+'_'+subMenu;
    locateTip(tipNr,(subYNavPosition[mainMenu-1]+5+(16*subMenu)),subXNavPosition[mainMenu-1]+101);
    showMenu(tipNr);
}

function hideTip(mainMenu, subMenu) {
    hideMenu('tip_'+mainMenu+'_'+subMenu);
    turnoff();
}



var all_menu_on=0
function all_menu(onoff) {
    all_menu_on=onoff;

    if (onoff == 0) { killMenu(); locateSubNavigation(subNavActive,subNavPosActive); activateMenu(subNavActive) }
    return;        
}


function changeforum(forum, forum1){
    document.location.href = 'mainpage.php?option=viewForum&forumid=' + forum;
}


function check_submit(section, task_val, type){

    switch (section){
        case "article":
            switch (task_val){
            case "savenew":
            
                if ((document.inputform.title.value == "")      ||
                   (document.inputform.content.value == "")){
                    alert('>Bitte alle Felder ausfüllen!');
                }
                else{
                    do_submit(task_val);
                }
            break;
            default:
                do_submit(task_val);
            break;
            }
        break;            
        case "mysite":
            switch (task_val){
            case "update":
            
                if ((document.inputform.title.value == "")      ||
                   (document.inputform.content.value == "")){
                    alert('>Bitte alle Felder ausfüllen!');
                }
                else{
                    do_submit(task_val);
                }
            break;
            default:
                do_submit(task_val);
            break;
            }
        break; 
        case "link":
            switch (task_val){
            case "savenew":
            
                if ((document.inputform.userlink.value == "http://www.") 
                     || (document.inputform.userlink.value == "")){
                    alert('>Bitte alle Felder ausfüllen!');
                }
                else{
                    do_submit(task_val);
                }
            break;
            default:
                do_submit(task_val);
            break;
            }
        break; 
    }
}

function do_submit(task_val){
    document.inputform.task.value=task_val; 
    document.inputform.submit();
}  

function swappic(origpic,picobject) {
 origpic.src = picobject.src;
}

    savebutton_f = new Image();
    savebutton_f.src = ""+server_js+"/img/system/save_f."+picformat_icons; 
    savebutton_t = new Image();
    savebutton_t.src = ""+server_js+"/img/system/save_t."+picformat_icons; 

    editorbutton_f = new Image();
    editorbutton_f.src = ""+server_js+"/img/system/editor_f."+picformat_icons; 
    editorbutton_t = new Image();
    editorbutton_t.src = ""+server_js+"/img/system/editor_t."+picformat_icons;

    uploadbutton_f = new Image();
    uploadbutton_f.src = ""+server_js+"/img/system/upload_f."+picformat_icons; 
    uploadbutton_t = new Image();
    uploadbutton_t.src = ""+server_js+"/img/system/upload_t."+picformat_icons; 


function setVariables() { 

if (navigator.appName == "Netscape") {
	if (navigator.appVersion.substring(0,1)>=5){
		visib=".visibility";
		horz=".left"; 
		vert=".top"; 
		docStyle=""; 
		styleDoc=".style"; 
		innerW="window.innerWidth"; 
		innerH="window.innerHeight"; 
		offsetX="window.pageXOffset"; 
		offsetY="window.pageYOffset"; 

		objectXY = "document.getElementById('upbutton')";
	}
	else
	{
		visib=".visibility";
		horz=".left"; 
		vert=".top"; 
		docStyle="document."; 
		styleDoc=""; 
		innerW="window.innerWidth"; 
		innerH="window.innerHeight"; 
		offsetX="window.pageXOffset"; 
		offsetY="window.pageYOffset"; 

		objectXY="upbutton"; 
	} 
}

else { 
visib=".visibility";
horz=".pixelLeft"; 
vert=".pixelTop"; 
docStyle=""; 
styleDoc=".style"; 
innerW="document.body.clientWidth"; 
innerH="document.body.clientHeight"; 
offsetX="document.body.scrollLeft"; 
offsetY="document.body.scrollTop"; 

objectXY="upbutton"; 
} 

} 
function checkLocation() { 

var availableX=eval(innerW); 
var availableY=eval(innerH); 
var currentX=eval(offsetX); 
var currentY=eval(offsetY); 
x=availableX-(imgwidth+30)+currentX-10;
//x=currentX;
y=availableY-(imgheight+20)+currentY-30;

evalMove(); 
setTimeout("checkLocation()",10); 
}

function evalMove() { 
//alert (docStyle + objectXY + styleDoc + visib + "='visible'");
eval(docStyle + objectXY + styleDoc + visib + "='visible'");
eval(docStyle + objectXY + styleDoc + horz + "=" + x); 
eval(docStyle + objectXY + styleDoc + vert + "=" + y); 
} 