
ns4=false; ns6=false; ie4=false; ie5=false;
if(document.layers) { ns4=true }
else if(document.getElementById && !(document.all)) { ns6=true }
else if(document.all) {
    if(navigator.userAgent.indexOf('MSIE 4')>0) {
        ie4=true;
    } else {
        ie5=true;
    }
}
var open_win=0;
function substitute(string, match, replacement) {
    // Within STRING, replace any MATCHing string with the REPLACEMENT.
    var result = '';
    var index = 0;
    var lastIndex = index;
    while (string.length > lastIndex) {
        index = string.indexOf(match, lastIndex);
        if (index == -1) { break }
        result += string.substring(lastIndex, index) + replacement;
        lastIndex = index + match.length;
    }
    result += string.substring(lastIndex, string.length);
    return result;
}
function getRealLeft() {
    // browser independent real coords
    if(ns4) {
        if(this.x) { return this.x; }
        if(this.pageX) { return this.pageX; }
        return 0;
    } else {
        xPos = this.offsetLeft;
        tempEl = this.offsetParent;
        while (tempEl != null) {
            xPos += tempEl.offsetLeft;
            tempEl = tempEl.offsetParent;
        }
        return xPos;
    }
}
function getRealTop() {
    //browser independent real coords
    if(ns4) {
        if(this.y) { return this.y; }
        if(this.pageY) { return this.pageY; }
        return 0;
    } else {
        yPos = this.offsetTop;
        tempEl = this.offsetParent;
        while (tempEl != null) {
            yPos += tempEl.offsetTop;
            tempEl = tempEl.offsetParent;
        }
        return yPos;
    }
}

function check_homepage(isURL, visiElement) {
    if(!document.all) { return; }
    sQueryHome = oHomePage.isHomePage(isURL);
    if (!sQueryHome){
        document.getElementById(visiElement).style.display="block";
    }
}
function set_homepage(URL, visiElement) {
    oHomePage.setHomePage(URL);
    document.getElementById(visiElement).style.display="none";
}

function launch(form) {
    var now = new Date();
    var oc_room = form.oc_room.value;
    if(form.private) { oc_room = "p_" + oc_room; }
    var url = "http://chat.optichat.com:8081/optichat.html?";
    //var url = "http://opti.optichat.com/optichat.html?";
    url += "&oc_stage=2";
    url += "&oc_room="+escape(oc_room);
    url += "&oc_dyn=1";
    url += "&oc_user="+encodeURI(form.oc_user.value);
    url += "&cachebust="+now.getTime();
    NewWin=window.open("", "optichat", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=1");
    if(NewWin){
        NewWin.location=url;
        NewWin.focus();
    } else {
        top.location=url;
    }
}

