/* Copyright (c) 2007 by Stefan Goehler

This is integral part of the Crossfire Designs content management.
Any copying without permission or modification prohibited.
*/

                  n = navigator;
                  nua = n.userAgent;
                  var msie6 = ((nua.indexOf( 'MSIE 6') != -1)&&(nua.indexOf( 'Opera') == -1));
                  var msie7 = ((nua.indexOf( 'MSIE 7') != -1)&&(nua.indexOf( 'Opera') == -1));
                  var msie = ((nua.indexOf( 'MSIE') != -1)&&(nua.indexOf( 'Opera') == -1));
                  var onloadfunc; // MSIE workaround

               /*   function togglecomment(objectid,active,fadecount)
                  {

                    var comment = document.getElementById(objectid);
                    if (active)
                    comment.style.display="block";
                    else
                    comment.style.display="none";

                  } */


                /*  function togglevis_delay(objectid,startopacity,endopacity,duration,delay)
                  {
                    var domnode = document.getElementById(objectid);

                    if (startopacity < endopacity)
                    {
                      if (delay > 0) window.status = "in";

                      if (domnode.fading != "in")
                      {
                        if (domnode.timedelay != "in")
                        {
                          if (delay > 0)
                          {
                            domnode.timedelay = "in";
                            setTimeout("togglevis_delay('"+objectid+"',"+startopacity+","+endopacity+","+duration+",0)",delay);
                          }
                        }
                        else
                        {
                           if (domnode.timedelay == "in") togglevis(objectid,startopacity,endopacity,duration,0);
                         if (delay == 0) setTimeout("var domnode = document.getElementById('"+objectid+"');  if (domnode.timedelay == 'in') domnode.timedelay = '';",duration+50);
                        }
                      }
                    }
                    else
                    {
                      window.status = "out";
                      if (domnode.fading == "")
                      {
                        if (domnode.timedelay == "in")
                          domnode.timedelay = "";
                        else
                        {
                          domnode.timedelay = "out";
                          togglevis(objectid,startopacity,endopacity,duration,0);
                        }
                      }
                      else if (domnode.fading == "in")
                        {
                          domnode.timedelay = "out";
                          togglevis(objectid,startopacity,endopacity,duration,0);
                        }
                    }
                  }   */


                  function timebase_item()
                  // Object <item> is used to allocate memory. i.e. the data parts of the linked list
                  {
                      this.func = null;
                      this.next = null;
                  }

                  function timebase_addEvent(eventfunc, eventtime, list)
                  // Adds a new element to the start of the list
                  {
                      var temp = new timebase_item();
                      temp.eventtime = eventtime;
                      temp.func = eventfunc;
                      temp.next = list;
                      return temp;
                  }

                  function timebase_getNextEvent(list,currenttime)
                  // Returns shelflet variable with the specified ID
                  {
                      lasttime = 9999999999999;
                      if (list != null)
                      {
                        if (list.eventtime < lasttime)
                        {
                          temp_list = list;
                        }
                        else timebase_getNextEvent(list.next,currenttime);
                      }
                      else
                      return "";
                  }

                  function timebase_create(repeattime)
                  // if repeattime != 0, function will repeat at time point of repeat time
                  {
                    this.repeattime = repeat;
                  }

                  function timebase_start(timeobject)
                  {
                    if (timeobject != null)
                    if (timeobject.repetition == 0)
                    {
                      timeobject.started = true;
                      if (timeobject.repeattime > 0)
                        setTimeout("timebase_start('"+timeobject+"')",timeobject.repeattime);
                    }
                  }

                  function timebase_stop(timeobject)
                  {
                    timeobject.stopped = true; // disallows
                  }

                  function timebase_handleEvent()
                  {

                  }


                  function togglevis_delay(objectid,startopacity,endopacity,duration,delay)
                  {
                    var domnode = document.getElementById(objectid);

                    if (startopacity < endopacity)
                    {
                     // if (delay > 0) window.status = "in";

                      if (delay > 0)
                      {
                        if (domnode.timedelay != "in")
                        {
                          domnode.timedelay = "in";
                          setTimeout("togglevis_delay('"+objectid+"',"+startopacity+","+endopacity+","+duration+",0)",delay);
                        }
                      }
                      else if (domnode.timedelay == "in") togglevis(objectid,startopacity,endopacity,duration,0);
                    }
                    else
                    {
                      //window.status = "out";
                      if (domnode.timedelay == "in")
                      {
                        domnode.timedelay = "out";
                      }

                      togglevis(objectid,startopacity,endopacity,duration,0);
                    }

                  }


                  var fadeupdatespeed = 30;

                  function togglevis(objectid,startopacity,endopacity,duration,fadecount)
                  {
                    var comment = document.getElementById(objectid);
                    if (comment != null)
                    {
                      if (!msie)
                      {
                        if (comment.style.opacity == null) comment.style.opacity = startopacity;
                        var opacity = parseFloat(comment.style.opacity);
                      }
                      else
                      {
                        if (comment.filters.alpha.opacity == null) comment.filters.alpha.opacity = 100;
                        var opacity = comment.filters.alpha.opacity/100;
                      }

                      var delta = (endopacity-startopacity)/(duration/fadeupdatespeed);

                      if (startopacity < endopacity)
                      {
                        if ((fadecount == 0)||(fadecount > 0)&&(comment.fading == "in"))
                        {
                          if (fadecount == 0) { opacity = startopacity; comment.fading = "in"; }
                          opacity+= delta;
                          if (!msie) comment.style.opacity = opacity;
                          else comment.filters.alpha.opacity = opacity*100;
                          if ((fadecount == 0)&&(startopacity == 0)) comment.style.display="block";

                          if (opacity <= endopacity)
                          setTimeout("togglevis('"+objectid+"',"+startopacity+","+endopacity+","+duration+","+(fadecount+1)+")",fadeupdatespeed);
                          else comment.fading = "";
                        }
                      }
                      else
                      {
                        if ((fadecount == 0)&&(comment.fading != "out")||(fadecount > 0)&&(comment.fading == "out"))
                        {
                          if (fadecount == 0) { comment.fading = "out"; }
                          opacity+= delta;
                          comment.style.opacity = opacity;
                          if (!msie) comment.style.opacity = opacity;
                          else comment.filters.alpha.opacity = opacity*100;

                          if (opacity <= endopacity)
                          { if (endopacity == 0) comment.style.display="none"; else comment.style.opacity = endopacity; }
                          else
                          setTimeout("togglevis('"+objectid+"',"+startopacity+","+endopacity+","+duration+","+(fadecount+1)+")",fadeupdatespeed);
                        }
                      }
                    }
                  }

                  function addLoadEvent(func)
                  {
                    if (!msie) // MSIE7 says window.onload not implemented... f*** MS
                    {
                      var oldonload = window.onload;
                      if (typeof window.onload != 'function')
                        window.onload = func;
                      else
                      {
                        window.onload = function()
                        {
                          oldonload();
                          func();
                        }
                      }
                    }
                    else
                    {
                      var oldonload = onloadfunc;
                      if (typeof onloadfunc != 'function')
                        onloadfunc = func;
                      else
                      {
                        onloadfunc = function()
                        {
                          oldonload();
                          func();
                        }
                      }
                    }

                  }

