function doPopup(win, bookmark) {
    if (bookmark) window.open(win + "#" + bookmark, "popup", "width=600, height=400, top=" + ((screen.height - 400) / 2) + ", left=" + ((screen.width - 600) / 2) + ", scrollbars=1, location=0");
    else window.open(win, "popup", "width=600, height=400, top=" + ((screen.height - 400) / 2) + ", left=" + ((screen.width - 600) / 2) + ", scrollbars=1, location=0");
}

function writeMiniPlayer(strLocElemId, strVidFile, strStartup, strHoldingImg) {
    var elem = document.getElementById(strLocElemId);
    var startup = (strStartup) ? "&startup=" + strStartup : "";
    var holdImg = (strHoldingImg) ? "&tn=" + strHoldingImg : "";
    elem.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="160" height="160">' +
        '<param name="movie" value="mcmp180x180_player.swf">' +
        '<param name="quality" value="high">' +
        '<param name="Flashvars" value="vidfile=' + strVidFile + startup + holdImg + '">' +
        '<embed src="mcmp180x180_player.swf" width="160" height="160" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" Flashvars="vidfile=' + strVidFile + startup + holdImg + '"></embed>' +
        '</object>';
}

function writeClock(strLocElemId) {
    var elem = document.getElementById(strLocElemId);
    elem.innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
           'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=6,0,0,0"' +
           'ID=lw_clock WIDTH=100% HEIGHT=100%>' +
           '<PARAM NAME=movie VALUE="lw_clock.swf">' +
           '<PARAM NAME=quality VALUE=high>' +
           '<PARAM NAME=bgcolor VALUE=#cccccc>' +

           '<EMBED SRC="lw_clock.swf"' +
           'swLiveConnect=FALSE WIDTH=100% HEIGHT=100%' +
           'QUALITY=high bgcolor=#cccccc' +
           'TYPE="application/x-shockwave-flash"' +
           'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
           '</EMBED></OBJECT>';
}


function setCookie(cName, cValue, expireDays) {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() + expireDays);
    document.cookie = cName + "=" + escape(cValue) + ";path=/" + ((expireDays == null) ? "" : ";expires=" + expireDate.toGMTString());
}

function getCookie(cName) {
    if (document.cookie.length > 0) {
        cStart = document.cookie.indexOf(cName + "=");
        if (cStart != -1) { 
            cStart = cStart + cName.length + 1; 
            cEnd = document.cookie.indexOf(";", cStart);
            if (cEnd == -1) cEnd = document.cookie.length;

            return unescape(document.cookie.substring(cStart, cEnd));
        } 
    }

    return "";
}

function deleteCookie(cName) {
    if (getCookie(cName) != "") {
        alert("deleting cookie");
        document.cookie = cName + "=;path=/" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }
}

function rememberMe(who) {
    setCookie("login_email", who, 365);
}

function dontRememberMe() {
    deleteCookie("login_email");
}

function getRememberMe() {
    return getCookie("login_email");
}

function setRememberMe() {
    if (document.getElementById('Remember').checked) rememberMe(document.getElementById('login_name').value);
    else dontRememberMe();
}

String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}
