function doOnLoad() {
    externalLinks();
//    if (typeof checkStyle == 'function') {
//        checkStyle();
//    }
}

function externalLinks() {
    if (!document.getElementsByTagName) return;

    var anchors = document.getElementsByTagName("a");
    for (var i=0; i < anchors.length; i++) {
        if (anchors[i].getAttribute("href") &&
               (anchors[i].getAttribute("rel") == "external" ||
                anchors[i].getAttribute("rel") == "nofollow")) {
            anchors[i].target = "_blank";
        }
    }
}
window.onload = doOnLoad;

function getImages(id, path1, path2) {
    var imgObj = document.getElementById(id);

// alert("src: " + imgObj.src);

    if (imgObj.src.endsWith(path1)) {
        imgObj.src = path2;
    } else {
        imgObj.src = path1;
    }
}

String.prototype.endsWith = function(str) {
    return ( this.match(str+"$") == str )
}

function modalWin(url, width, height) {
    if (window.showModalDialog) {
        window.showModalDialog(url, '_blank', 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px');
    } else {
        window.open(url, '_blank', 'width=' + width + ',height=' + height +
            ',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
    }
}

function runScript(url) {
    var uagent = navigator.userAgent.toLowerCase();
    var is_ie = uagent.indexOf('mozilla/4.0 (compatible; msie') != -1;
    if (is_ie) {
        document.write('<script type=\"text/javascript\" src=\"' + url + '\"></sc'+'ript>');
    } else {
        var sc = document.createElement("script");
        sc.setAttribute("type", "text/javascript");
        sc.setAttribute("src", url);
        document.body.appendChild(sc);
    }
}

function getXmlHttpObject() {
    if (window.XMLHttpRequest) {
        try {
            return new XMLHttpRequest();
        } catch (e) { }
    } else if (window.ActiveXObject) {
        try {
            return new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e) {
            try {
                return new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e) { }
        }
    }
//    alert("Your browser does not support XMLHTTP!");
    return null;
}

function showMsgAuthorMenu(obj) {
    var objPos = $(obj).position();
    var objX = objPos.left;
    var objY = objPos.top;
    var objH = $(obj).height();
    var menu = $(obj).next('div.msg_author_menu');
    var menuW = menu.width();
    var dX = $(document).width() - (objX + menuW);
    if (dX < 0) menu.css('left', objX + dX - 20);
    menu.css('top', objY + objH);
    if (menu.css('display') == 'none') {
        menu.slideDown();
    } else {
        menu.slideUp();
    }
}

function closeMsgAuthorMenu(obj) {
    $(obj).parents('div.msg_author_menu').animate({ opacity: 'hide' }, 'slow');
}