//----------------------------------------------------------------------------
// Project : EFv3
// File    : functions.js
// Version : 0.1
// Author  : Holger "[EF]coyote" Kundisch
//----------------------------------------------------------------------------


function countdown()
{
 var days, hours, mins;
 var jetzt = new Date();
 var j = jetzt.getTime() / 1000;
 var party = new Date(2006,3,7,18,00,00);
 var p = party.getTime() / 1000;
 var diff = Math.floor(p - j);
 days = Math.floor(diff / 86400);
 rest = (diff / 86400) - days;
 hours = Math.floor(rest * 24);
 mins = Math.floor(((rest * 24) - hours) * 60);
 document.getElementById('tage').firstChild.nodeValue = days + " Tage";
 document.getElementById('stunden').firstChild.nodeValue = hours + " Stunden";
 document.getElementById('minuten').firstChild.nodeValue = mins + " Minuten";
 window.setTimeout("countdown()",6000);
 return
}

function strtrim() {
 return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
String.prototype.trim = strtrim;


function HighLight(obj,htmcol)
{
 var a, d, c, st, buf;
 for(c=0; c < obj.childNodes.length; c++) {
   if(obj.childNodes[c].nodeName.toLowerCase() == "td") {
 // IE - unsauber
     if(navigator.appName.search(/xplore.+/) != -1) {
       obj.childNodes[c].getAttribute('style').backgroundColor = htmcol;
      }
 // Firefox - sauber - node-Element
     else {
       if(obj.childNodes[c].getAttribute('style') != null) {
         st = obj.childNodes[c].getAttribute('style').split(";");
         for(d=0; d < st.length - 1; d++) {
           buf = st[d].split(":");
           if(buf[0].trim().toLowerCase() == "background-color") {
             st[d] = "background-color: " + htmcol;
             obj.childNodes[c].setAttribute("style", st.join(";"));
            }
          }
        }
      }
    }
  }
 return
}

function EditorInit() {
  if(document.getElementById("ifrm") != null) {
    var str1 = "<html><head><title>text</title></head><style type=\"text/css\">p{margin:0px;}</style><body style=\"font-size:9px;font-family:Verdana,Tahoma,Arial,Sans-Serif;margin:0px;cursor:text;\">";
    var val = document.getElementsByName("text")[0].getAttribute("value");
    var str2 = "</body></html>";
    
    document.getElementById("ifrm").contentWindow.document.designMode = "on";
    
    if(navigator.appName == "Netscape") {
      document.getElementById("ifrm").contentWindow.document.execCommand("styleWithCSS", false, false);
      document.getElementById("ifrm").contentWindow.document.body.innerHTML = val;
    }
    else {
      document.getElementById("image").disabled = true;
      document.getElementById("ifrm").contentWindow.document.write(str1 + val + str2);
    }
  }
  return true;
}

function EditorCommand(command, value) {
  if(navigator.appName == "Netscape") var tfrm = document.getElementById("ifrm").contentDocument;
  else var tfrm = ifrm.document;
  switch(command) {
    case "InsertImage":
    case "CreateLink":
      var szURL = navigator.appName == "Netscape" ? prompt("Gib eine URL ein:", "http://") : null;
      var ie = (navigator.appName != "Netscape");
      if (navigator.appName != "Netscape" || ((szURL != null) && (szURL != "http://"))) tfrm.execCommand(command, ie, szURL);
      break;
    default:
      tfrm.execCommand(command, false, value);
      break;
  }
  document.getElementById("ifrm").contentWindow.focus();
}

function EditorSend() {
  var val = document.createAttribute("value");
  val.nodeValue = document.getElementById("ifrm").contentWindow.document.body.innerHTML;
  document.getElementsByName("text")[0].setAttributeNode(val);
  document.frm_editor.submit();
}
