﻿//--------------------------------------給圖時的fun(start)

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



function toggleNav(id) {
	var o = document.getElementById("nav-s"+id);
	if(o==undefined) return;
	if(o.style.display == "block")
		o.style.display = "none";
	else
		o.style.display = "block";
}
function toggleSidemenu(id,xact) {
    //alert('id='+id +',xact='+xact)
	var o = document.getElementById("side-menu-s"+id);
	
	if(o==undefined) return;
    if(o.style.display == "block")
	    o.style.display = "none";
    else
	    o.style.display = "block";
	
//	if(xact=='allnone'){
//	    //$('side-menu').innerHTML=$('side-menu').innerHTML.replace('block','none');
//	    o.style.display = "block";
//	}
//	else{
//	
//	    if(o==undefined) return;
//	    if(o.style.display == "block")
//		    o.style.display = "none";
//	    else
//		    o.style.display = "block";
//    }
}


function clickDL(id) {
    var o = document.getElementById(id);
    if (o == undefined) return;


    if (id == "myData") {
        if (o.className == "dl") {
            o.className = "dl current-dl";
            $('div2ES').style.display = 'block';

        }
        else {
            o.className = "dl";
            $('div2ES').style.display = 'none';
        }
    }


    if (id == "myRecord") {
        if (o.className == "dl") {
            o.className = "dl current-dl";
        }
        else {
            o.className = "dl";
        }
    }


    if (id == "myHistory") {
        if (o.className == "dl") {
            o.className = "dl current-dl";
        }
        else {
            o.className = "dl";
        }
    }

}


window.document .writeln ("<div id=divTracking style=display:none>divTracking</div>");
window.document .writeln ("<div id=divFlashPlayer style=display:none>divFlashPlayer</div>");
//--------------------------------------給圖時的fun(end)


function goIndex(x){
    if (x=='index'){
        window.location.href="index.aspx";
    }
    else{
        window.location.href="../index.aspx";
    }
}


//--------------------------------------IE, Firefox,Chrome, Opera, Safari
var BrowserVer = {}; 
var ua = navigator.userAgent.toLowerCase(); 
var s; 
(s = ua.match(/msie ([\d.]+)/)) ? BrowserVer.ie = s[1] : 
(s = ua.match(/firefox\/([\d.]+)/)) ? BrowserVer.firefox = s[1] : 
(s = ua.match(/chrome\/([\d.]+)/)) ? BrowserVer.chrome = s[1] : 
(s = ua.match(/opera.([\d.]+)/)) ? BrowserVer.opera = s[1] : 
(s = ua.match(/version\/([\d.]+).*safari/)) ? BrowserVer.safari = s[1] : 0; 


//alert('BrowserVer.ie='+BrowserVer.ie);



//--------------------------------------writeFlash8
function writeFlash8(tag, file, w, h, color) {
    var params = window.location.search.substr(1); // extract GET string without '?'
    var flashStr = "";
    flashStr += '<object id="flashMovie" width="' + w + '" height="' + h + '"  ';
    flashStr += 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  ';
    flashStr += 'codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">  ';
    flashStr += '<param name="allowScriptAccess" value="always"> ';
    flashStr += '<param name="movie" value="' + file + '">  ';
    flashStr += '<param name="flashvars" value="' + params + '">  ';
    flashStr += '<param name="quality" value="high">  ';
    flashStr += '<param name="menu" value="false">  ';
    flashStr += '<param name="scale" value="noscale">  ';
    flashStr += '<param name="bgcolor" value="' + color + '">  ';
    flashStr += '<param name="wmode" value="opaque">';
    flashStr += '<embed src="' + file + '"  ';
    flashStr += '  swLiveConnect=true ';
    flashStr += '  flashvars="' + params + '"  ';
    flashStr += '  name="flashMovie"  ';
    flashStr += '  quality="high"  ';
    flashStr += '  allowScriptAccess="always" ';
    flashStr += '  menu="false"  ';
    flashStr += '  type="application/x-shockwave-flash"  ';
    flashStr += '  width="' + w + '"  ';
    flashStr += '  height="' + h + '"  ';
    flashStr += '  bgcolor="' + color + '"  ';
    flashStr += '  align="middle"  ';
    flashStr += '  scale="noscale"  ';
    flashStr += '  pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">  ';
    flashStr += '</embed>  ';
    flashStr += '</object>';
    //document.write(flashStr);
    $(tag).innerHTML = flashStr;
}




//................................................................讀取XML
if (!BrowserVer.ie) {
    //alert('FF')

    var _xmlDom = null;
    if (!window.DOMParser && window.ActiveXObject) {
        var arrXmlDomTypes = ['MSXML2.DOMDocument.6.0', 'MSXML2.DOMDocument.3.0', 'Microsoft.XMLDOM'];
        for (var i = 0; i < arrXmlDomTypes.length; i++) {
            try {
                _xmlDom = new ActiveXObject(arrXmlDomTypes[i]);
            } catch (ex) { } //不支持MSXML.XMLDOM对象的IE
        }
    } else {// Mozilla browsers have a DOMParser
        try {
            if (_xmlDom == null && document.implementation && document.implementation.createDocument) {
                _xmlDom = document.implementation.createDocument("", "", null);
            }
            isIE = false;
        } catch (ex) { }
    }


    Document.prototype.loadXML = function(sXml) {
        var oParser = new DOMParser();
        var _xmlDom = oParser.parseFromString(sXml, "text/xml");

        while (this.firstChild) {
            this.removeChild(this.firstChild);
        }

        for (var i = 0; i < _xmlDom.childNodes.length; i++) {
            var oNewNode = this.importNode(_xmlDo.childNodes[i], true);
            this.appendChild(oNewNode);
        }
    }

    Element.prototype.__defineGetter__("text", function() { return this.textContent; });


    if (document.implementation.hasFeature("XPath", "3.0")) {
        Document.prototype.selectNodes = function(cXPathString, xNode) {
            if (!xNode) { xNode = this; }
            var oNSResolver = this.createNSResolver(this.documentElement)
            var aItems = this.evaluate(cXPathString, xNode, oNSResolver,
                        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
            var aResult = [];
            for (var i = 0; i < aItems.snapshotLength; i++) {
                aResult[i] = aItems.snapshotItem(i);
            }
            return aResult;
        }

        Element.prototype.selectNodes = function(cXPathString) {
            if (this.ownerDocument.selectNodes) {
                return this.ownerDocument.selectNodes(cXPathString, this);
            }
            else { throw "For XML Elements Only"; }
        }

        Document.prototype.selectSingleNode = function(cXPathString, xNode) {
            if (!xNode) { xNode = this; }
            var xItems = this.selectNodes(cXPathString, xNode);
            if (xItems.length > 0) {
                return xItems[0];
            }
            else {
                return null;
            }
        }

        Element.prototype.selectSingleNode = function(cXPathString) {
            if (this.ownerDocument.selectSingleNode) {
                return this.ownerDocument.selectSingleNode(cXPathString, this);
            }
            else { throw "For XML Elements Only"; }
        }
    }


    Element.prototype.selectSingleNode = function(sXPath) {
        var oEvaluator = new XPathEvaluator();
        var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        if (null != oResult) {
            return oResult.singleNodeValue;
        }
        return null;
    }

    Element.prototype.selectNodes = function(sXPath) {
        var oEvaluator = new XPathEvaluator();
        var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
        var aNodes = new Array();
        if (null != oResult) {
            var oElement = oResult.iterateNext();
            while (oElement) {
                aNodes.push(oElement);
                oElement = oResult.iterateNext();
            }
        }
        return aNodes;
    }

    //................................................................讓FireFox 也支援 children
    HTMLElement.prototype.__defineGetter__("children",
		function() {
		    var returnValue = new Object();
		    var number = 0;
		    for (var i = 0; i < this.childNodes.length; i++) {
		        if (this.childNodes[i].nodeType == 1) {
		            returnValue[number] = this.childNodes[i];
		            number++;
		        }
		    }
		    returnValue.length = number;
		    return returnValue;
		}
	);

}
//................................................................讓FireFox 也支援 outerHTML
if (typeof (HTMLElement) != "undefined" && !window.opera) {
    HTMLElement.prototype.__defineGetter__("outerHTML", function() {
        var a = this.attributes, str = "<" + this.tagName, i = 0; for (; i < a.length; i++)
            if (a[i].specified)
            str += " " + a[i].name + '="' + a[i].value + '"';
        if (!this.canHaveChildren)
            return str + " />";
        return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    HTMLElement.prototype.__defineSetter__("outerHTML", function(s) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df = r.createContextualFragment(s);
        this.parentNode.replaceChild(df, this);
        return s;
    });
    HTMLElement.prototype.__defineGetter__("canHaveChildren", function() {
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
    });
}


//--------------------------------------路徑
function forURL(xServerURL, xV) {
    var reStr = "";

    if (xV.substring(0, 4).toLowerCase() == 'http') reStr = xV;
    if (xV.substring(0, 1) == "/") xV = xV.substring(1, xV.length);

    reStr = xServerURL + xV;

    return reStr;
}
//--------------------------------------setCookie
//function setCookie(c_name, value, expiredays) {
//    var exdate = new Date()
//    exdate.setTime(exdate.getTime() + (expiredays * 24 * 3600 * 1000))
//    //alert('exdate='+exdate)
//    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate)
//}


//--------------------------------------getCookie
//function getCookie(c_name) {
//    if (document.cookie.length > 0) {
//        c_start = document.cookie.indexOf(c_name + "=")
//        if (c_start != -1) {
//            c_start = c_start + c_name.length + 1
//            c_end = document.cookie.indexOf(";", c_start)
//            if (c_end == -1) c_end = document.cookie.length
//            return unescape(document.cookie.substring(c_start, c_end))
//        }
//    }
//    return ""
//}


//另開視窗大小
var OpenSize="top=0px,left=0px,width=930px,height=600px,toolbar=no,resizable=yes,scrollbars=yes"
//--------------------------------------Print、轉寄 
function goWindowOpen(xV){
    
    window.open(xV,"WinF",OpenSize) ;
}



//--------------------------------------GetQueryString
function GetQueryString(name) {
   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
   var r = window.location.search.substr(1).match(reg);
   if (r!=null) return unescape(r[2]); return '';
}




//--------------------------------------prototype.js
function $p(element){    
	return parent.document.getElementById(element);
}
function $(element){
    
	return document.getElementById(element);
}

function $N() {
    return document.getElementsByName(arguments[0]);
}
function $T() { // $T('input','box')
    if (arguments.length == 1) {
        return document.getElementsByTagName(arguments[0]);
    } else if (arguments.length == 2) {
        if (typeof (arguments[1]) == "object") {
            return arguments[1].getElementsByTagName(arguments[0]);
        }
        else {
            return $(arguments[1]).getElementsByTagName(arguments[0]);
        }
    }
}


//--------------------------------------------- 控制半形/全形的空白，也當作沒輸入
function judgeSpace(xV) {

    xV = xV.replace(/　/ig, '');

    var allS = true
    var arrS = xV.split(' ');
    for (aa = 0; aa < arrS.length; aa++) {
        aV = TrimSpace(arrS[aa])
        if (aV != "") {
            allS = false;
            break;
        }
    }
    //alert('arrS.length='+arrS.length)
    if (allS) xV = ""
    return xV;
}

//--------------------------------------------- 將傳來的string的 空格拿掉
function TrimSpace(string) {
    var temp = "";
    string = "" + string;
    splitstring = string.split(" ");
    for (i = 0; i < splitstring.length; i++)
        temp += splitstring[i];
    return temp;
}

//--------------------------------------------- 判斷是否為數值狀態 (是.傳回True  否.傳回False)
function judgeNum(xxV) {
    reV = true;
    if (!Number(xxV) & xxV != 0) reV = false;
    return reV;
}



//---------------------------------------------檢查身份證
function checkID(str){  
	var idStr="xABCDEFGHJKLMNPQRSTUVXYWZIO";
	var myid="x" + str.toUpperCase();
	var x= idStr.indexOf(myid.charAt(1)) + 9
	var j = new String(x)
	var newnum = (parseInt(j.substr(0,1))*1) + (parseInt(j.substr(1,1))*9)
	var countDown=8
	for(i=2;i<=10;i++) {
		newnum += parseInt(myid.substr(i,1)) * countDown;
		if(countDown>1)
		countDown --;
	}
	if(newnum%10==0)
		return true 
	else 
		return false
}
//--------------------------------------------- 檢查 Email 格式
function checkEmail(str){
	var err=''
	var errSTR='e-mail ERROR';
	if(str.indexOf("@")<0 || str.indexOf("@")==0)
		err += errSTR;
	if(str.indexOf(".")<0 || str.indexOf(".",str.indexOf("@")) < 0 )
		err += errSTR;
	
	if(err!='')
		return false;
	else
		return true;
}

//--------------------------------------------- 檢查日期格式
function IsDate(DateString, Dilimeter) {
    if (DateString == null) {
        return false;
    }
    if (Dilimeter == '' || Dilimeter == null) {
        Dilimeter = '-';
    }
    var tempy = '';
    var tempm = '';
    var tempd = '';
    var tempArray;
    if (DateString.length < 8 || DateString.length > 10) {
        return false;
    }

    tempArray = DateString.split(Dilimeter);
    if (tempArray.length != 3) {
        return false;
    }

    if (tempArray[0].length != 4) {
        return false;
    }
    else {
        tempy = tempArray[0];
        tempm = tempArray[1];
        tempd = tempArray[2];
    }

    if (isNaN(tempy)) {
        return false;
    }
    if (isNaN(tempm)) {
        return false;
    }
    if (isNaN(tempd)) {
        return false;
    }

    var tDateString = tempy + '/' + tempm + '/' + tempd;
    var tempDate = new Date(tDateString);

    if (tempDate.getFullYear() != tempy) {
        return false;
    }

    if (tempDate.getMonth() != tempm - 1) {
        return false;
    }

    if (tempDate.getDate() != tempd) {
        return false;
    }

    return true;
}
//---------------------------------------------SL Write 資訊
  function SSMsg(xMsg) {
      var WinSQL = window.open("", "WinSQL");
      WinSQL.focus();
      WinSQL.document.write(xMsg + '<br>');
  }




