/*---------------------------------------------------------------------------
 *
 * lib.js
 * © 2001 Struppi struebig@gmx.net
 * home.nexgo.de/struebig/js/
 *
 * standard JS Funktionen.
 * ------------------------
 *
 * setCookie(name, value, Tage)
 * getCookie(name)
 *
 *
 *---------------------------------------------------------------------------*/

//////////////////////////////////////////////////////////////////////////////
//

function getGrafikFolder()
{
      var url = "http://www.BILDungsluecke.de";
      if(window.location.href.indexOf("127.0.0.1") != -1) url = "http://127.0.0.1/bildungsluecke/neu";
      if(window.location.href.indexOf("localhost") != -1) url = "http://127.0.0.1/bildungsluecke/neu";
      return url + "/grafiken/";
}
function getPath()
{
      var path = "/";
      if(window.location.href.indexOf("127.0.0.1") != -1 || window.location.href.indexOf("localhost") != -1)
      path = "/bildungsluecke/neu/";
      return path
}
//////////////////////////////////////////////////////////////////////////////
//
// setCookie(Name, Wert, tage)
//
// setzt ein Cookie.

function setCookie(name, value, days)
{
     if(!days) days = 1;
     var ms = 1000 * 60 * 60 * 24 * days;
     var expire = new Date();
     expire.setTime(expire.getTime() + ms);

     document.cookie = ( name + "=" + escape(value) +  "; expires=" + expire.toGMTString() + ";");
}

//////////////////////////////////////////////////////////////////////////////
//
// getCookie(Name)
//
// Ein Cookie lesen.

function getCookie(name)
{
    var search = name + "=";
    if (document.cookie.length > 0) {

        var offset = document.cookie.indexOf(search);

        if (offset != -1) {

             offset += search.length;
             var end = document.cookie.indexOf(";", offset)
             if (end == -1) end = document.cookie.length;

             return unescape(document.cookie.substring(offset, end));
        }
    }
    return "";
}


function setMail(el)
{
     var mail = getCookie('email');

     el.value = mail;
}



/* =======================================================
    debugObj(obj)
=======================================================*/
function debugObj(obj)
{
     var text = "";
     for(var i in obj)
     {
          if (typeof obj[i] == "function" || typeof obj[i] == "object" ) continue;
          text += ("\n" + i + "(" + typeof obj[i] + ")");
          text += ( ' = "' + obj[i] + '"');
     }
     return text;
}