
function htmlspecialchars(s)
{
    s = s.replace(/&/g, '&amp;');
    s = s.replace(/</g, '&lt;');
    s = s.replace(/>/g, '&gt;');
    return s;
}

function cloneObject(what)
{
    var i;
    for (i in what)
    {
        if (typeof what[i] == 'object')
        {
            this[i] = new cloneObject(what[i]);
        }
        else
            this[i] = what[i];
    }
}

function tostring(what)
{
    var output = '';
    for (i in what) {
        if (typeof what[i] == 'object') {
            output += i + ' = Object\n';
           // output += tostring(what[i]);
        }
        else if (typeof what[i] == 'function')
        {
            output += i + ' = function()\n';
        }
        else
            output += i + ' = ' + what[i] + '\n';
    }
    return output;
}

function p_r(s)
{
    var out;

    if (typeof(s) == 'object')
        out = tostring(s);
    else  if (typeof(document.getElementById('debug')) != 'undefined')
        out = htmlspecialchars(s + '\n');
    document.getElementById('debug').innerHTML += (out + '\n');
}

/*
Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

var SCROLLER_CONTINUOUS = 1;
var scroller_lastmouse;

function scroller(globalvarname, content,width,height,speed,incr,bgcolor,option)
{
    // for events
    this.globalvarname = globalvarname;
    // the content
    this.option = option;
    if (typeof option == "undefined")
        this.option = 0;
    if (this.option & SCROLLER_CONTINUOUS)
        this.marqueecontent ='<nobr>' + content + content + '</nobr>';
    else
        this.marqueecontent ='<nobr>' + content + '</nobr>';

//p_r(this.marqueecontent); document.write(this.marqueecontent); return
    //Specify the marquee's width (in pixels)
    this.marqueewidthnum=width;
    this.marqueewidth=width+"px"
    //Specify the marquee's height
    this.marqueeheight=height+"px"
    //Specify the marquee's marquee speed (larger is faster 1-10)
    this.marqueespeed=speed
    //Specify the increment defau;t 8
    this.marqueeincr=(incr ? incr : 8)
    //configure background color:
    this.marqueebgcolor=bgcolor;
    //Pause marquee onMousever (0=no. 1=yes)?
    this.pauseit=1;

    this.windowonload=false;

    //Specify the marquee's content (don't delete <nobr> tag)
    //Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):



    ////NO NEED TO EDIT BELOW THIS LINE////////////
//    this.marqueespeed=(document.all)? this.marqueespeed : Math.max(1, this.marqueespeed-1) //slow speed down by 1 for NS
    this.copyspeed=this.marqueespeed;
    this.pausespeed=(this.pauseit==0)? this.copyspeed: 0
    this.iedom=document.all||document.getElementById;
    if (this.iedom)
        document.write('<span id="temp'+this.globalvarname+'" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+this.marqueecontent+'</span>')
    this.actualwidth='';
    this.cross_marquee=false, this.ns_marquee=false;

    this.populate = function()
    {
        if (this.iedom)
        {
            this.cross_marquee=document.getElementById? document.getElementById("iemarquee"+this.globalvarname) : document.all['iemarquee'+this.globalvarname];
            if (this.option & SCROLLER_CONTINUOUS)
                this.cross_marquee.style.left=this.marqueeincr+"px";
            else
                this.cross_marquee.style.left=parseInt(this.marqueewidth)+this.marqueeincr+"px"
            this.cross_marquee.innerHTML=this.marqueecontent
            var temp = "temp"+this.globalvarname;
            this.actualwidth=document.all? eval("temp"+this.globalvarname+".offsetWidth") : document.getElementById(temp).offsetWidth;
//            this.actualwidth-=this.marqueewidthnum;
        }
        else if (document.layers){
            this.ns_marquee=document.ns_marquee.document.ns_marquee2;
            if (this.option & SCROLLER_CONTINUOUS)
                this.ns_marquee.left=0+this.marqueeincr;
            else
                this.ns_marquee.left=parseInt(this.marqueewidth)+this.marqueeincr;
            this.ns_marquee.document.write(this.marqueecontent);
            this.ns_marquee.document.close();
            this.actualwidth=ns_marquee.document.width;
        }
        lefttime=setInterval(this.globalvarname + ".scrollmarquee()",20);

    }

    this.setspeed = function()
    {
        this.speed = this.copyspeed = this.marqueespeed = -this.marqueespeed;
    }

    this.scrollmarquee = function()
    {
        if (this.iedom)
        {
            if (this.copyspeed >= 0)
            {
                if ((this.option & SCROLLER_CONTINUOUS) && parseInt(this.cross_marquee.style.left)>(this.actualwidth*(-1)/2+this.marqueeincr)
                        || (!(this.option & SCROLLER_CONTINUOUS) && parseInt(this.cross_marquee.style.left)>(this.actualwidth*(-1)+this.marqueeincr)))
                {
                    this.cross_marquee.style.left=parseInt(this.cross_marquee.style.left)-this.copyspeed+"px";
                }
                else
                {
                    if (this.option & SCROLLER_CONTINUOUS)
                        this.cross_marquee.style.left=this.marqueeincr+"px";
                    else
                        this.cross_marquee.style.left=parseInt(this.marqueewidth)+this.marqueeincr+"px";

                }
            }
            else
            {
                if (((this.option & SCROLLER_CONTINUOUS) && parseInt(this.cross_marquee.style.left) < 0)
                        || (!(this.option & SCROLLER_CONTINUOUS) && parseInt(this.cross_marquee.style.left) < parseInt(this.marqueewidth)))
                {
                    this.cross_marquee.style.left=parseInt(this.cross_marquee.style.left)-this.copyspeed+"px";
                }
                else
                {
                    if (this.option & SCROLLER_CONTINUOUS)
                        this.cross_marquee.style.left=-this.actualwidth/2 + this.marqueeincr+"px";
                    else
                        this.cross_marquee.style.left= (-1)*parseInt(this.actualwidth)+this.marqueeincr+"px";

                }
            }
        }
        else if (document.layers)
        {
            if (this.ns_marquee.left>(this.actualwidth*(-1)+this.marqueeincr))
                this.ns_marquee.left-=this.copyspeed;
            else
                this.ns_marquee.left=parseInt(this.marqueewidth)+this.marqueeincr;
        }
    }

    this.start = function(oldfunc)
    {
        this.windowonload = oldfunc;

        eval("window.onload=function() {  " + globalvarname + ".populate(); if (typeof eval("+globalvarname+".windowonload) != 'undefined') "+ globalvarname+".windowonload(); } ");

//if (typeof eval(globalvarname+".windowonload") != 'undefined') alert(eval(globalvarname+".windowonload"))

        if (this.iedom||document.layers)
        {
            with (document)
            {
                out = '';
                out += ('<table border="0" cellspacing="0" cellpadding="0"><td>')
                if (this.iedom)
                {
                    out += ('<div style="position:relative;width:'+this.marqueewidth+';height:'+this.marqueeheight+';overflow:hidden">')
                    out += ('<div style="position:absolute;width:'+this.marqueewidth+';height:'+this.marqueeheight+';background-color:'+this.marqueebgcolor+
                        '" onmousedown="'+this.globalvarname+'.setspeed()" '+
                        '" onMouseover="'+this.globalvarname+'.copyspeed='+this.globalvarname+'.pausespeed" onMouseout="'
                        +this.globalvarname+'.copyspeed='+this.globalvarname+'.marqueespeed">')
                    out += ('<div id="iemarquee'+this.globalvarname+'" style="position:absolute;left:0px;top:0px"></div>')
                    out += ('</div></div>')
                }
                else if (document.layers){
                    out += ('<ilayer width='+this.marqueewidth+' height='+this.marqueeheight+' name="ns_marquee" bgColor='+this.marqueebgcolor+'>')
                    out += ('<layer name="ns_marquee2" left=0 top=0 onMouseover="'+this.globalvarname+'.copyspeed='+this.globalvarname+'.pausespeed" onMouseout="'+this.globalvarname+'.copyspeed='+this.globalvarname+'.marqueespeed"></layer>')
                    out += ('</ilayer>')
                }
                out += ('</td></table>')
                document.write(out);
    //p_r(out)
            }
        }
        return window.onload;
    }
}
