var sPop = null;
var postSubmited = false;

document.write("<style type='text/css' id='defaultPopStyle'>");
document.write(".cPopText { font: 12px/1.6em Tahoma, Verdana; background-color: #fff; border: 1px #555 dashed; color: #555; padding: 2px 4px; line-height: 18px; text-align:left; visibility: hidden; filter: Alpha(Opacity=80); opacity: 0.8;}");
document.write("</style>");
document.write("<div id='popLayer' style='position: absolute; z-index: 1;' class='cPopText'></div>");

function showPopupText(event) {
        if(event.srcElement) o = event.srcElement; else o = event.target;
        if(!o) {
                return;
        }
        MouseX = event.clientX;
        MouseY = event.clientY;
        if(o.alt != null && o.alt != '') {
                o.pop = o.alt;
                o.alt = '';
        }
        if(o.title != null && o.title != '') {
                o.pop = o.title;
                o.title = '';
        }
        if(o.pop != sPop) {
                sPop = o.pop;
                if(sPop == null || sPop == '') {
                        $('popLayer').style.visibility = "hidden";
                } else {
                        popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
                        $('popLayer').style.visibility = "visible";
                        showIt();
                }
        }
}

function showIt() {
        $('popLayer').className = popStyle;
        $('popLayer').innerHTML = sPop.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>");
                
        var bodySL, bodyST;
        if(window.pageXOffset){
                bodySL=window.pageXOffset;
        }else if(document.documentElement&&document.documentElement.scrollLeft){
                bodySL=document.documentElement.scrollLeft;
        }else if(document.body){
                bodySL=document.body.scrollLeft; //author: meizz
        }
        
        if(window.pageYOffset){
                bodyST=window.pageYOffset;
        }else if(document.documentElement&&document.documentElement.scrollTop){
                bodyST=document.documentElement.scrollTop;
        }else if(document.body){
                bodyST=document.body.scrollTop;
        }
        
        var bodyCW, bodyCH; 
        if(window.innerWidth){
                bodyCW=window.innerWidth;
        }else if(document.documentElement&&document.documentElement.clientWidth){ 
                bodyCW=document.documentElement.clientWidth;
        }else if(document.body){
                bodyCW=document.body.clientWidth; //author: meizz
        }
        
        if(window.innerHeight){
                bodyCH=window.innerHeight;
        }else if(document.documentElement&&document.documentElement.clientHeight){ 
                bodyCH=document.documentElement.clientHeight; 
        }else if(document.body){
                bodyCH=document.body.clientHeight;
        }

        if($('popLayer').clientWidth>300){
                var popWidth = 300;
        }else{
                var popWidth = $('popLayer').clientWidth;
        }
        
        var popWidth = $('popLayer').clientWidth;
        var popHeight = $('popLayer').clientHeight;
        var popLeftAdjust = MouseX + 12 + popWidth > bodyCW ? -popWidth - 24 : 0;
        var popTopAdjust = MouseY + 12 + popHeight > bodyCH ? -popHeight - 24 : 0;
        $('popLayer').style.left = (MouseX + 12 + bodySL + popLeftAdjust) + 'px';
        $('popLayer').style.top = (MouseY + 12 + bodyST + popTopAdjust) + 'px';
}

if(!document.onmouseover) {
        document.onmouseover = function(e) {
                var event = e ? e : window.event;
                showPopupText(event);
        };
}