/* DHTML-Bibliothek */

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0, tableHeight = 0;

/*Testen der Browser Fähigkeiten*/
function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
 if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }

}
 

/*----Funktionen zum Anzeigen der Tooltips--------*/
function showtip(current,e,text){ //zeigt tooltip mit details zum Projekt an
  document.getElementById("textknoten").firstChild.nodeValue=text;  
  if(document.all)
    document.all.text.style.setAttribute("visibility","visible");
  else document.getElementById("text").style.visibility="visible";
}

function hidetip(){ //blendet Tooltip aus
  if (document.getElementById)
    document.getElementById("text").style.visibility="hidden";
}

/*----Funktionen zum Scrollen der Projekt-thumbnails------*/
var isScrolling = false;
var pd = null;
var scrollTimeout = null;
var scrollAmount = 391; //Differenz zwischen buttonup und buttondown


function calcTableHeight(){
  if(document.getElementById) {//berechenen der tablellenhöhe
    for (var i=0; i < document.getElementsByTagName("img").length; i++){
      tableHeight += parseInt(document.getElementsByTagName("img")[i].height + 11);
    }
    initShortcut();
  }
}

function initShortcut(){
  pd = eval(document.getElementById("table"));
  pd.style.top=0;
}

function scrollUp(){
  if(DOM){
    if(parseInt(pd.style.top)<0){
      pd.style.top = parseInt(pd.style.top) + 5;
    }else{
      pd.style.top = 0;
    }
  }
}

function scrollDown(){
  if(DOM){
    if(tableHeight - scrollAmount > (parseInt(pd.style.top))*(-1)){
      pd.style.top = parseInt(pd.style.top) - 5;
    }
  }
}

function repeatStep(direction){
  //alert("repeatStep dir "+direction);
  if(!isScrolling){
    clearTimeout(scrollTimeout);
  }else{
    if(direction==0) scrollUp();
    if(direction==1) scrollDown();
    scrollTimeout = setTimeout("repeatStep("+direction+")",20);
  }
}

function startScrolling(direction){
  isScrolling = true;
  repeatStep(direction);
}

function stopScrolling(){
  isScrolling = false;
}

/*----Ende Scroll-funktionen--------*/


/*----Generische DHTML Hilfsfunktionen------*/
function getElem(p1,p2,p3) {
 var Elem;
 if(DOM) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.getElementsByTagName(p2) == "object" ||
        (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(MS) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(NS) {
   if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
        Attr=getElem(p1,p2)[p3][p4]
       else
        Attr=getElem(p1,p2)[p4]
         return Attr;
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

DHTML_init();
/*------Ende der generischen DHTML-Funktionen-----*/

/*------Funktion zum öffnen von Pop-Ups------*/
function openPopUp(URL,x,y){ 
tohip = window.open(URL,"tohip","width="+x+",height="+y+",dependent=no, resizable=no,scrollbars=no");
}

/*-----Funktion überprüft FIleUpload Formular------*/
function validateUploadForm()
{
  if(document.upload_form.image_file.value == "" || document.upload_form.image_file.value == "Big_Image.jpg")
    {
      alert("Es muss ein Bildfile angegeben werden");
      document.upload_form.image_file.focus();
      return false;
    }
  if(document.upload_form.thumbs_file.value == "" || document.upload_form.thumbs_file.value == "Thumbnail_Image.jpg")
    { 
      alert("Es muss ein Thumbnailfile angegeben werden");
      document.upload_form.thumbs_file.focus();
      return false;
    }
  else return true;
}

/*-----Funktion zum überprüfen des Links Formulars----*/
function validateLinkForm()
{
  if(document.link_form.image_file.value == "" || document.link_form.image_file.value == "Big_Image.jpg")
    {
      alert("Bitte ein Bild für den Link auswählen");
      document.link_form.image_file.focus();
      return false;
    }
  if(document.link_form.link.value == "")
    {
      alert("Bitte einen Link angeben");
      document.link_form.image_file.focus();
      return false;
    }
  else if(document.link_form.link.value.substr(0,3) == "www")
    {
      document.link_form.link.value = "http://"+document.link_form.link.value;
    }
  else if(document.link_form.link.value.substr(0,7) != "http://")
    {
      alert("Link muss die Form http://www.linkname.de haben");
      document.link_form.link.focus();
      return false;
    }
}

/*-----Funktion zum Austauschen der Menu Bilder----*/
var notnormal="";
function Bildwechsel(Bildnr,Bildobjekt)
{
  if(Bildobjekt!=notnormal){
    window.document.images[Bildnr].src = Bildobjekt.src;
  }
}
 


