var m = {
    $e: function(z) {
        return typeof (z) == "object" ? z : document.getElementById(z);
    },
    $E: function(o, z) {
        return typeof (o) == "string" ? ge(o).getElementsByTagName(z) : o.getElementsByTagName(z);
    },
    tagCutover: function(tagObj, listName) {			//標籤切換	tagObj:標籤列表對象, listName:同級內容對象標籤名
        if (!this.$e(tagObj)) return;
		var t = this;
        var tg = this.$e(tagObj), tgList = this.$E(tg, "a"),
			cnList = this.$E(tg.parentNode, !listName?"ul":listName);
        tg.cnList = cnList;

        for (i = 0; i < tgList.length; i++) {
            tgList[i].no = i;
            tgList[i].href = "javascript:;"
            cnList[i].style.display = "none";
            if (tgList[i].parentNode.className == "current") {
                tg.current = tgList[i];
                cnList[i].style.display = "";
            }
            tgList[i].onclick = function() {
                var tp = this.parentNode;
                tg.current.parentNode.className = '';
                tg.cnList[tg.current.no].style.display = "none";
                tp.className = "current";
                tg.cnList[this.no].style.display = "block";
                tg.current = this;
                this.blur();
            }
        }
        //end for
    },
    selection: function(t, n) {			//下拉選擇框	t:目標對象	n:下拉框個數
        if (!this.$e(t)) return;
        var _t = this;
        var root = this.$e(t);
        var tb = this.$E(root, "div")[0],
			tl = this.$E(root, "div")[1],
			tla = this.$E(tl, "a"),
			v = this.$E(tb, "i")[0];
		
        tb.openStatus = false;
        tb.onmouseover = function() { v.className = "hover"; this.onmouseout = function() { if (!this.openStatus) v.className = ""; };}
        tb.onclick = function() { tl.style.width = this.clientWidth + "px"; adjust(!this.openStatus);}
        for (i = 0; i < tla.length; i++) {
            //tla[i].href = "javascript:;";
            tla[i].onclick = function() {
                _t.$E(tb, "em")[0].innerHTML = this.innerHTML;
				adjust(false);
            }
        }
		
		function adjust(flag){
			if (!flag){
                tl.style.display = "none";
				v.className = "";
                tb.openStatus = false;
				document.onclick = null;
            } else {
                tl.style.display = "block";
				v.className = "hover";
                tb.openStatus = true;
				setTimeout(function(){ document.onclick = function(){ adjust(gp(getEvent().srcElement||getEvent().target));}}, 10);
            }
		}
		function gp(o){var o = _t.$e(o).parentNode; while(o.nodeName != "BODY"){ if(o== tl) return true; o = o.parentNode; }; return false;}
		//dclick
    }
}
function coopScroll() {
    var cp = m.$e("coop");
    if (cp != null) {
        var p = m.$E(cp, "p")[0],
		a = m.$E(cp, "a");
        if (a[0] != null) {
            if (a[0].clientWidth * a.length > cp.clientWidth) {
                p.innerHTML = p.innerHTML + p.innerHTML;
                p.style.width = a[0].clientWidth * a.length + "px";
                var cinter = setInterval(function() { cp.scrollLeft = cp.scrollLeft < p.clientWidth / 2 ? cp.scrollLeft + 1 : 0; }, 20);
                cp.onmouseover = function() { clearInterval(cinter); }
                cp.onmouseout = function() { cinter = setInterval(function() { cp.scrollLeft = cp.scrollLeft < p.clientWidth / 2 ? cp.scrollLeft + 1 : 0; }, 20); }
            }
        }
    }
}

function getEvent(){     //同時兼容ie和ff的寫法	取得操作對象
	 if(document.all)    return window.event;        
	 func=getEvent.caller;            
	 while(func!=null){    
		 var arg0=func.arguments[0];
		 if(arg0){
			 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
				 || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
				 return arg0;
			 }
		 }
		 func=func.caller;
	 }
	 return null;
}

//Add Function
function innerSWF(obj,src,name,width,height,version,parameter){
	var so = new SWFObject(src, name, width, height, version);
	so.addParam("quality", "high");
	so.addParam("menu", "false");
	so.addParam("wmode", "transparent");
	if(parameter) so.addParam("FlashVars", parameter);		
	so.write(obj);
}

//Go to url
function gotourl(url) {
    location.replace(url);
}
