String.prototype.trim = function()
{
    return this.replace(/^\s+|\s+$/, '');
};
String.prototype.rtrim = function()
{
    return this.replace(/\s+$/, '');
};
String.prototype.ltrim = function()
{
    return this.replace(/^\s+/, '');
};

if (!TDH) var TDH = new Object;

TDH.nodeEmpty = function(node)
{
    if (typeof node.data != 'undefined') {
        return (node.data.match(/^[ \u0009\u000A\u000D\u0020]+/) ? true : false);
    } else {
        return false;
    }
};
TDH.nodeSkip = function(node)
{
    return (node.nodeType == 8) || ((node.nodeType == 3) && this.nodeEmpty(node));
};
TDH.nextSibling = function(node)
{
    while ((node = node.nextSibling)) {
        if (!this.nodeSkip(node)) return node;
    }
    return null;
};
TDH.previousSibling = function(node)
{
    while ((node = node.previousSibling)) {
        if (!this.nodeSkip(node)) return node;
    }
    return null;
};
TDH.firstChild = function(node)
{
    if (node.firstChild) {
        var child = node.firstChild;
        while (child) {
            if (!this.nodeSkip(child)) return child;
            child = child.nextSibling;
        }
    }
    return null;
};
TDH.lastChild = function(node)
{
    if (node.lastChild) {
        var child = node.lastChild;
        while (child) {
            if (!this.nodeSkip(child)) return child;
            child = child.previousSibling;
        }
    }
    return null;
};
TDH.scanTreeUp = function(obj, target)
{
    target = target.toUpperCase();
    if (typeof obj == 'string' &&
        document.getElementById)
        obj = document.getElementById(obj);
    if (obj && obj.parentNode) {
        obj = obj.parentNode;
        while (obj && obj.tagName) {
            if (obj.tagName.toUpperCase() == target) return obj;
            if (obj.parentNode) obj = obj.parentNode;
        }
    }
    return null;
};
TDH.scanTreeDown = function(obj, target)
{
    target = target.toUpperCase();
    if (typeof obj == 'string' &&
        document.getElementById)
        obj = document.getElementById(obj);
    if (obj) {
        obj = this.firstChild(obj);
        while (obj && obj.tagName) {
            if (obj.tagName.toUpperCase() == target) return obj;
            obj = this.firstChild(obj);
        }
    }
    return null;
};

TDH.Event = {
    setEvent: function(obj, event, func)
    {
        var event = obj+'.'+event;
        var events = eval(event);
        if (typeof events == 'function') {
            eval(event + ' = function() { events(); func(); }');
        } else {
            eval(event + ' = func;');
        }
        return;
    },
    setEventById: function(id, event, func)
    {
        var ref = '';
        var events = null;
        ref = 'document.getElementById("'+ id +'").' + event;
        events = eval(ref);
        if (typeof events == 'function') {
            ref += ' = function(e) { events(e); func(e); }';
        } else {
            ref += ' = func;';
        }
        ref = eval(ref);
        return;
    },
    getEventTarget: function(event)
    {
        var target = {};
        event = (typeof event == 'undefined') ? window.event : event;
        target = (typeof event.target == 'undefined') ? event.srcElement : event.target;
        if (target.nodeType == 3)
            target = target.parentNode;
        return target;
    }
};

TDH.Params = {
    params: {},
    setParams: function(params)
    {
        this.params = {};
        var temp = [];
        temp = params.split(/\s*,\s*/);
        for (var t = 0, c = temp.length; t < c; t++) {
            temp[t] = temp[t].split(/\s*=\s*/);
            if (temp[t].length == 2) {
                temp[t][0] = temp[t][0].trim();
                temp[t][1] = temp[t][1].trim();
                temp[t][0] = temp[t][0].toString().toLowerCase();
                this.params[temp[t][0]] = temp[t][1];
            } else if (temp[t].length > 2) {
                var key = temp[t].shift();
                key = key.trim();
                temp[t] = temp[t].join('=');
                this.params[key] = temp[t];
            }
        }
        temp = null;
    },
    setParam: function(key, value)
    {
        this.params[key] = value;
        return;
    },
    getParams: function(format)
    {
        if (typeof format != 'undefined' && format === true) {
            var params = [];
            for (var p in this.params) {
                if (params.push) {
                    params.push(p+"="+this.params[p]);
                } else {
                    params[params.length] = p+"="+this.params[p];
                }
            }
            params = params.join(', ');
            return params;
        } else {
            return this.params;
        }
    },
    getParam: function(key)
    {
        return (typeof this.params[key] != 'undefined') ? this.params[key] : null;
    }
};

TDH.Flash = {

    setObject: function(element, params)
    {
        if (document.getElementById) {
            var flash = '';
            element = document.getElementById(element);
            TDH.Params.setParams(params);
            params = TDH.Params.getParams();
            params['movie'] = params['src'];
            flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ params['width'] +'" height="'+ params['height'] +'">';
            for ( var p in params) { if (p.match(/name|swliveconnect/i)) continue; flash += '<param name="'+ p +'" value="'+ params[p] +'" />'; }
            flash += '<embed type="application/x-shockwave-flash" src="'+ params['src'] +'" width="'+ params['width'] +'" height="'+ params['height'] +'" name="'+ params['name'] +'" wmode="'+ params['wmode'] +'"';
            flash += '></embed>';
            flash += '</object>';
            element.innerHTML = flash;
            flash = null;
        }
        return;
    }
};

TDH.Event.setEvent('window', 'onload', function()
{
    // setup suckerfish
    var nav = document.getElementById('nav');
    var nodes = nav.childNodes;
    for (var n = 0, c = nodes.length; n < c; n++) {
	   if (nodes[n].tagName &&
	       nodes[n].tagName.toUpperCase == 'LI') continue;
	       nodes[n].onmouseover = function()
	       {
	           this.className = !this.className.match(/hover$/i) ?
	                             this.className+=' hover' :
	                             this.className;
	       };
	       nodes[n].onmouseout = function()
	       {
	           this.className = this.className.replace(/\s*hover/g, '');
	       };
    }
    
 
    // external links
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName('a');
	for (var a=0, c = anchors.length; a < c; a++) {
		if (anchors[a].href && anchors[a].rel && anchors[a].rel == 'external')
		anchors[a].target = '_blank';
	}

    if (document.getElementById('news-outer')) {
        (new scroller()).scroller_load('news-inner', 'news-outer');
    }
 
});
