/*
	[Discuz!] (C)2001-2007 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$RCSfile: common.js,v $
	$Revision: 1.103 $
	$Date: 2007/07/30 09:16:52 $
*/

var sPop = null;
var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $(id) {
	return document.getElementById(id);
}

function doane(event) {
	e = event ? event : window.event;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else if(e) {
		e.stopPropagation();
		e.preventDefault();
	}
}

function bookmarksite(title, url)
{
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

function chkDowdload(strCde) {
	if (confirm("您現在所要下載的程式未經過掃毒,所以我們無法保證程式是否安全!\n\n如果您要繼續下載,請按下\"確定\"\n\n或者按下\"取消\"以中止下載!"))
		return true;
	else
	{
		return false;
	}
}

document.write("<style type='text/css'>");
document.write(".cPopText { font-family: 微軟正黑體, Verdana; background-color: #ffffcc; border: 1px #666 dotted; font-size: 11pt; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80); opacity: 0.8;}");
document.write("</style>");
document.write("<div id='popLayer' style='text-align: left; position: absolute; z-index: 1000' 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);
        };
}