var browser = 0;

if (navigator.appName.indexOf("Netscape") != -1)
    browser = 0;
if (navigator.appName.indexOf("Explorer") != -1)
    browser = 1;
else
    browser = 0;

function htmlSpecialChars(str)
{
    return(String(str).replace(/&/, '&amp;').replace(/"/, '&quot;').replace(/'/, '&#039;').replace(/</, '&lt;').replace(/>/, '&gt;').replace(/ä/, '&auml;').replace(/ö/, '&ouml;').replace(/ü/, '&uuml;').replace(/Ä/, '&Auml;').replace(/Ö/, '&Ouml;').replace(/Ü/, '&Uuml;'));
}

function createAttrib(doc, attr_name, attr_value, elem)
{
    var attrib = doc.createAttribute(attr_name);
    attrib.nodeValue = attr_value;
    if ((elem != undefined) && (elem != null))
        elem.setAttributeNode(attrib);
}

function changeAttribute(node, attr_name, attr_value)
{
    var attr = node.getAttributeNode(attr_name);
    attr.nodeValue = attr_value;
    node.setAttributeNode(attr, attr_name);
}

function getProperties(obj)
{
    var pos = self.location.href.lastIndexOf('/');
    var hr = self.location.href.substr(0, (pos + 1));
    var win = window.open((hr + 'qbulletin/clientscripting/js/_common/getProperties.html'), '', 'dependent=yes,location=no,menubar=no,resizable=yes,status=yes,toolbar=no,scrollbars=yes');
    win.title = 'getProperties';
    if (browser == 1) // Explorer
    {
        while (win.isLoaded != true) {}
        win.getProperties(obj);
    }
    else
        win.onload = function() { win.getProperties(obj); }
}

function getStyle(stylesheet, stylename, doc)
{
    if (doc == null)
        doc = document;
    
    for (var i = 0; i < doc.styleSheets.length; i++)
    {
        if (doc.styleSheets[i].href.substr(doc.styleSheets[i].href.length - stylesheet.length) == stylesheet)
        {
            for (var j = 0; j < doc.styleSheets[i].cssRules.length; j++)
            {
                if (doc.styleSheets[i].cssRules[j].selectorText == stylename)
                    return(doc.styleSheets[i].cssRules[j].style);
            }
        }
    }
    
    return(null);
}

function wait(msecs)
{
    var now0 = new Date().getTime();
    var now1;
    do
    {
        now1 = new Date().getTime();
    }
    while ((now1 - now0) < msecs);
}

