	
/* 
------------ Last Modify:2008/7/14
*/

// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is.nav5up and is.ie5up (see below).
// Revised 21 Nov 00 to add is.gecko and is.ie5_5 Also Changed is.nav5 and is.nav5up to is.nav6 and is.nav6up
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask ... "Is" is the constructor function for "is" object,
// which has properties indicating:
// (1) browser vendor:
//     is.nav, is.ie, is.opera, is.hotjava, is.webtv, is.TVNavigator, is.AOLTV
// (2) browser version number:
//     is.major (integer indicating major version number: 2, 3, 4 ...)
//     is.minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is.nav2, is.nav3, is.nav4, is.nav4up, is.nav6, is.nav6up, is.gecko, is.ie3, 
//     is.ie4, is.ie4up, is.ie5, is.ie5up, is.ie5_5, is.ie5_5up, is.ie6, is.ie6up, is.hotjava3, is.hotjava3up
// (4) JavaScript version number:
//     is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98, is.winme, is.win2k
//     is.os2
//     is.mac, is.mac68k, is.macppc
//     is.unix
//     is.sun, is.sun4, is.sun5, is.suni86
//     is.irix, is.irix5, is.irix6
//     is.hpux, is.hpux9, is.hpux10
//     is.aix, is.aix1, is.aix2, is.aix3, is.aix4
//     is.linux, is.sco, is.unixware, is.mpras, is.reliant
//     is.dec, is.sinix, is.freebsd, is.bsd
//     is.vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when Nav5 and IE5 (or later) are released, so
// in conditional code forks, use is.nav4up ("Nav4 or greater")
// and is.ie4up ("IE4 or greater") instead of is.nav4 or is.ie4
// to check version in code which you want to work on future
// versions.


function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);


    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);

    this.webtv = (agt.indexOf("webtv") != -1); 

    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    this.AOLTV = this.TVNavigator;

    this.hotjava = (agt.indexOf("hotjava") != -1);
    this.hotjava3 = (this.hotjava && (this.major == 3));
    this.hotjava3up = (this.hotjava && (this.major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    if (this.nav2 || this.ie3) this.js = 1.0;
    else if (this.nav3) this.js = 1.1;
    else if (this.opera5up) this.js = 1.3;
    else if (this.opera) this.js = 1.1;
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2;
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3;
    else if (this.hotjava3up) this.js = 1.4;
    else if (this.nav6 || this.gecko) this.js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (this.nav6up) this.js = 1.5;
    // note ie5up on mac is 1.4
    else if (this.ie5up) this.js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else this.js = 0.0;

    // *** PLATFORM ***
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    this.win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    this.win32 = (this.win95 || this.winnt || this.win98 || 
                    ((this.major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    this.winme = ((agt.indexOf("win 9x 4.90")!=-1));
    this.win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    this.os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    this.mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (this.mac && this.ie5up) this.js = 1.4;
    this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1)));
    this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    this.sun   = (agt.indexOf("sunos")!=-1);
    this.sun4  = (agt.indexOf("sunos 4")!=-1);
    this.sun5  = (agt.indexOf("sunos 5")!=-1);
    this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
    this.irix  = (agt.indexOf("irix") !=-1);    // SGI
    this.irix5 = (agt.indexOf("irix 5") !=-1);
    this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    this.hpux  = (agt.indexOf("hp-ux")!=-1);
    this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
    this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
    this.aix   = (agt.indexOf("aix") !=-1);      // IBM
    this.aix1  = (agt.indexOf("aix 1") !=-1);    
    this.aix2  = (agt.indexOf("aix 2") !=-1);    
    this.aix3  = (agt.indexOf("aix 3") !=-1);    
    this.aix4  = (agt.indexOf("aix 4") !=-1);    
    this.linux = (agt.indexOf("inux")!=-1);
    this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    this.unixware = (agt.indexOf("unix_system_v")!=-1); 
    this.mpras    = (agt.indexOf("ncr")!=-1); 
    this.reliant  = (agt.indexOf("reliantunix")!=-1);
    this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
                  (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
                  (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    this.sinix = (agt.indexOf("sinix")!=-1);
    this.freebsd = (agt.indexOf("freebsd")!=-1);
    this.bsd = (agt.indexOf("bsd")!=-1);
    this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
                 this.sco ||this.unixware || this.mpras || this.reliant || 
                 this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);

    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
}

var is;
var isIE3Mac = false;
// this section is designed specifically for IE3 for the Mac

if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && 
(parseInt(navigator.appVersion)==3))
       isIE3Mac = true;
else   is = new Is(); 


function msg_box(strURL,strName,strScrollBar,strReSizable,intHeight,intWidth,intX,intY,intToolbar){
	var properity="scrollbars="+strScrollBar+",resizable="+strReSizable+",directories=no,location=no,menubar=no,status=no,statusbar=no,height="+intHeight+",width="+intWidth;
	if (intToolbar > 0)
		properity=properity+",toolbar=1";
	else
		properity=properity+",toolbar=0";
	var NewWin=window.open('',strName,properity);
	NewWin.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=big5">');
	NewWin.document.write('<title>DATA LOADING...</title><link rel="stylesheet" href="/vegeworld.css"><script>self.focus();</script></head><body class=f11>');
	NewWin.document.write('<center><br>DATA LOADING...</center></body></html>');
	if (intX >0 && intY >=0){
		NewWin.moveTo (intX,intY);
	}
	else {
		var w = screen.availWidth;
		var h = screen.availHeight;
		NewWin.moveTo (((w - intWidth - 10) * .5),((h - intHeight - 30) * .5));
	}
	NewWin.location=strURL;
}

function msg_box2(strURL,strName,intHeight,intWidth){
	var properity="scrollbars=1,resizable=1,toolbar=1,directories=no,location=1,menubar=1,status=1o,statusbar=1,height="+intHeight+",width="+intWidth;
	var NewWin=window.open('',strName,properity);
	NewWin.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=big5">');
	NewWin.document.write('<title>DATA LOADING...</title><link rel="stylesheet" href="/vegeworld.css"><script>self.focus();</script></head><body class=f11>');
	NewWin.document.write('<center><br>DATA LOADING...</center></body></html>');
	var w = screen.availWidth;
	var h = screen.availHeight;
	NewWin.moveTo (((w - intWidth - 10) * .5),((h - intHeight - 30) * .5));
	NewWin.location=strURL;
}

function modal_box(strURL,objArg,intScrollBar,intReSizable,intHeight,intWidth)
{
    if (is.ie) {
        var properity="scroll:"+intScrollBar+";resizable:"+intReSizable+";status:0;help:no;dialogHeight:"+intHeight+"px;dialogWidth:"+intWidth+"px";
        var NewWin=window.showModalDialog("/Dialog.asp?p="+strURL,objArg,properity);
    } else
        msg_box("/Dialog.asp?p="+strURL,objArg,intScrollBar,intReSizable,intHeight,intWidth);
}

function modeless_box(strURL,objArg,intScrollBar,intReSizable,intHeight,intWidth)
{
    if (is.ie) {
        var properity="scroll:"+intScrollBar+";resizable:"+intReSizable+";status:0;help:no;dialogHeight:"+intHeight+"px;dialogWidth:"+intWidth+"px";
        var NewWin=window.showModelessDialog("/Dialog.asp?p="+strURL,objArg,properity);
    } else
        msg_box("/Dialog.asp?p="+strURL,objArg,intScrollBar,intReSizable,intHeight,intWidth);
}
function vProfile(id){
	var URL="/Member/ProfileW.asp?id="+id;
	var mWin=modeless_box(URL,window,1,1,530,550);
}

//===================================================================
// 設定 select 預定選項
// ex: InitOption(window.form1.xSelect, "1");
//===================================================================
function InitOption(sCtl, str)
{
   for(i=0; i < sCtl.options.length; i++)
    {
        if( sCtl.options[i].value == str )
        {
           sCtl.options[i].selected=true;
            break ;
        }
    }
}

//===================================================================
//	將視窗由 sW,sH 放大至 eW, eH
// win_resizel(sW, sH, eW, eH );
//===================================================================
function win_resize1(sW, sH, eW, eH)
{
    var sW, sH, win_x, win_y, XStep, YStep ;
    win_x = (screen.width - eW)/2;
    win_y = (screen.height - eH)/2 - 20;

    XStep = (eW - sW)/90;
    YStep = (eH - sH)/90;
    window.resizeTo(sW,sH) ;
    window.moveTo(win_x,win_y);
    for ( w=sW,h=sH ; h<eH ; h+=YStep,w+=XStep)
    {
        window.resizeTo(w,h) ;
    }
}
//===================================================================
//	將視窗放大至 W x H
// win_resize(W, H [, row, rowH , maxH ] );
//===================================================================
function win_resize(W,H,row,rowH,maxH)
{
    MaxY = window.screen.availHeight;
    MaxX = window.screen.availWidth;

    WinWidth = W;
    if (!row)
        WinHeight = H ;
    else
        WinHeight = H + rowH*row ;

    // WinHeight 不可大於 maxH
    if ( ( maxH ) && ( WinHeight > maxH ) )
        WinHeight = maxH ;

    From_W = 160 ;
    From_H = 50 ;
    XStep = (WinWidth - From_W)/20;
    YStep = (WinHeight - From_H)/20;

    for ( j=From_W,i=From_H ; i<WinHeight ; i+=YStep,j+=XStep)
    {
        window.resizeTo(j,i);
        window.moveTo((MaxX-j)/2,(MaxY-i)/2);
    }
}
//===================================================================
//	將視窗縮至最小
//===================================================================
function win_close()
{
    MaxY = window.screen.availHeight;
    MaxX = window.screen.availWidth;
    WinWidth = document.body.offsetWidth;
    WinHeight = document.body.offsetHeight ;

    XStep=WinWidth/30;
    YStep=WinHeight/30;
    for (j=WinWidth,i=WinHeight;i>0;i-=YStep,j-=XStep)
    {
       window.resizeTo(j,i);
       window.moveTo((MaxX-j)/2,(MaxY-i)/2);
    }
	Window.close();
}
//===================================================================
//
//
//===================================================================
function show_span(spanobj)
{
    document.getElementById(spanobj).style.display   = "block" ;
}

//===================================================================
//
//
//===================================================================

function hidden_span(spanobj)
{
    document.getElementById(spanobj).style.display   = "none" ;
}

//===================================================================
//	檢查物件的型態                            2K.11
//===================================================================
function objecttype(obj)
{
    var objtype = "", var_undefined;
    if (obj == var_undefined)
    {
        alert("object undefined");
        return;
    }
    if (obj.type == var_undefined)
    {
        if (obj[0].type != var_undefined)
            objtype = obj[0].type;
        else
        {
            alert("object:["+obj+"] error");
            return;
        }
    }
    else
    {
        objtype = obj.type;
    }
    return objtype;
}
//===================================================================
//	求取物件的值(目前支援:hidden,text,radio,checkbox,select-one,select-multiple)
//                                             2K01.04
//===================================================================
function value(obj)
{
    var i;
    var retvalue = '' ;
    var objtype = objecttype(obj);
    switch (objtype)
    {
        case "textarea":
            retvalue = obj.value;
            break;
    	case "password":
            retvalue = obj.value;
            break;
        case "hidden":
            retvalue = obj.value;
            break;
        case "text"  :
            retvalue = obj.value;
            break;
        case "checkbox" :
            var idx = 0 ;
            retvalue = new Array();
            if ( !obj.length )
            {
                if (obj.checked)
                    retvalue[0] = obj.value ;
                else
                    retvalue[0] = '' ;
            }
            else
            {
                for (z=0;z<obj.length;z++)
                {
                    if ( obj[z].checked )
                    {
                        retvalue[idx] = obj[z].value ;
                        idx++ ;
                    }
                }
            }
            //alert("my checkbox["+retvalue+"]");
            break;
        case "select-one" :
            retvalue = obj.options[obj.selectedIndex].value;
            //alert("my select-one["+retvalue+"]");
            break;
        case "select-multiple" :
            var inx=0;
            retvalue = new Array();
            for (i=0; i<obj.length; i++)
            {
                if (obj.options[i].selected == true)
                {
                    retvalue[inx] = obj.options[i].value;
                    inx++;
                }
            }
            //alert("my select-multiple["+retvalue.toString()+"]");
            break;
        case "radio" : //radio
            for (i=0; i<obj.length; i++)
                if (obj[i].checked == true)
                    retvalue = obj[i].value;
            //alert("my radio["+retvalue+"]");
            break;
        default :
            alert("function value(obj) obj:["+obj+"] error...");
            return;

    }
    return retvalue;
}
//===================================================================
//	去到str頭尾的separator, separator 未指定時為" "
//                                             2K01.04
//===================================================================
function trim(str, separator)
{
    var strlen = str.length;
    if (separator == null)
        separator = " ";
    // 去頭尾的多餘分隔符號

    if (strlen == 0)
        return "" ;

    do
    {
        if (str.substring(0, 1) == separator)
        {
            str = str.substring(1);
            strlen--;
        }
        if (str.substring(strlen-1) == separator)
        {
            str = str.substring(0, strlen-1);
            strlen--;
        }
    }while(str.substring(0, 1) == separator || str.substring(strlen-1) == separator)
    return (str);
}
//========================================================================
//= 檢查欄位值 ( 空值 , 整數 , 數字 , E-MAIL )
//= vege_chk_val( form_name , input_name , message [ , mode ] [, no_focus])
//========================================================================
function vege_chk_val( f_name , input_name , msg ,mode ,no_focus )
{
    form_obj = eval ( 'window.document.' + f_name ) ;
    if ( ! form_obj )   // L form object
    {
        alert('L : '+ f_name) ;
        return false ;
    }

    input_obj = eval ( 'window.document.' + f_name + '.' + input_name ) ;
    if ( ! input_obj )  // L input object
    {
        alert('L : '+ input_name) ;
        return false ;
    }
     val =  trim(value( input_obj ));
    flag = true ;
    if ( ! mode )   // L Ѽ
        mode = '' ;

    if ( ( val == '' ) || ( val == null ) )
        flag = false ;
    switch(mode)
    {
        case '' :
        {
            break ;
        }
        case 'int' :
        {
            if ( parseInt(val).toString(10) != val.toString(10)  )
               flag = false ;

            break ;
        }
        case 'num' :
        {
            if ( isNaN(val) )
               flag = false ;
            break ;
        }
        case 'str' :
        {
            break ;
        }
        case 'email' :
        {
            pos1 = parseInt( val.indexOf('@') ) ;
            pos2 = parseInt( val.indexOf('.') ) ;
            len =  parseInt( val.length ) ;
            if ( ( pos1 == -1 ) || ( pos2 == -1 ) || ( pos1*pos2 == 0) ||
                 ( pos1+1 == len ) || ( pos2+1 == len ) || ( Math.abs(pos1-pos2) == 1 )  )
                flag = false ;

            break ;
        }
        case 'date' :
        {
           // Create a variable to hold the correct format.
           var CorrectFormat = /[0-9][0-9][0-9][0-9]\/[0-9]\d{0,1}\/[0-9]\d{0,1}/;
           // If the field has value, validate the date.
           // Test to see if the format of the date is correct.
          if (CorrectFormat.test(val))
          {
             // Split out the month, day and year variables.
             strDate = val.split("/");
             var Year = strDate[0];
             var Month = strDate[1];
             var Day = strDate[2];

             // Ensure all the values are greater than 0
             if (Month > 0 && Day > 0 && Year > 0)
             {
                // Find the max day for the month
                // The default max day is 31
                var maxDays = 31;
                // If the month is April, June, September or November the max day is 30
                if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
                   maxDays = 30;
                }
                if (Month == 2){
                   if (Year % 4 > 0)
                      maxDays =28;
                   else
                   if (Year % 100 == 0 && Year % 400 > 0)
                      maxDays = 28;
                   else
                      maxDays = 29;
                }
                // Determine if the day entered is less than the max days for that month.
                if (Day <= maxDays)
                    flag = true;
                else
                    flag = false;
             }
          }
          else
            flag = false;

            break;
        }
        default :
        {
            alert('L : ' + mode ) ;
            return false ;
            break ;
        }
    }

    if ( flag )
        return true ;
    else
    {
    	if(no_focus != "1")
        	input_obj.focus() ;
        if ( trim(msg) != '' )
            alert(msg) ;
        return false ;
    }
}

function DisplayPhoto(filename){
	document.getElementById('DisplayPhotoTag').innerHTML="<img src='"+filename+"'>";
	location.href="#photo";
}

//===================================================================
// 設定 Radio 預定選項
// ex: InitRadio(window.form1.xRadio, "1");
//===================================================================
function InitRadio(sCtl, str)
{
   for(i=0; i < sCtl.length; i++)
    {
        if( sCtl[i].value == str )
        {
           sCtl[i].checked=true;
            break ;
        }
    }
}


//===================================================================
// 設定 CheckBox 預定選項
// ex: InitCheckBox(window.form1.xCheckBox, "1");
//===================================================================
function InitCheckBox(sCtl, str)
{
        if( sCtl.value == str )
        	sCtl.checked=true;
}


// 將控制項初始值設為str(用於 radio, checkbox)
function setRadio(optCtl)
{
	optCtl.checked=true;
}

//===================================================================
// 設定 Checkbox 全部選取或全部取消
// ex: SetCheckBoxAll(window.form1.xCheckbox, true|flase);
//===================================================================
function SetCheckBoxAll(obj, str)
{
	if ( !obj.length )  // 只有一個checkbox
		obj.checked=str;
	else
	{
		for (z=0;z<obj.length;z++)
			obj[z].checked=str;
	}
}


//===================================================================
// 統計字數
// ex: jsCountTxt(window.form1.object, max,show count ID,left ID);
//===================================================================
function jsCountTxt(obj,intMax,str,str2){
if (obj!= null) {
	var data=obj.value;
	var datalen=data.length;
	var times=0;
	if(datalen > intMax){
		obj.value=data.substr(0,intMax);
		datalen=obj.value.length;
	}
	times = intMax-datalen;
	if (str.length>0)
		document.getElementById(str).innerHTML = datalen;
	if (str2.length>0)
		document.getElementById(str2).innerHTML = times;
}
}

function opener_url(strURL){
	if (is.ie){
		var sData = window.dialogArguments;
		sData.location.href = strURL;}
	else{
		opener.location.href = strURL;}
        window.close();
}

function ChangePic(id,pic){
	document.getElementById(id).src=pic;
}

function PushMBlog(type,url,title,lead)
{
	var sel='';
	if (window.getSelection) { sel = window.getSelection();}
	else if (document.getSelection) {sel = document.getSelection();}
	else if (document.selection) {sel = document.selection.createRange().text;}
	if (sel != "")
		{lead = sel;}
	if (type=="twitter") 
		{javascript: void(window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(title+' '+lead+'...')) .concat(' ') .concat(encodeURIComponent(url))));}
	else if (type=="plurk")
		{javascript: void(window.open('http://www.plurk.com/?qualifier=shares&amp;status=' .concat(encodeURIComponent(url)) .concat(' ') .concat('(') .concat(encodeURIComponent(title)) .concat(') ') .concat(encodeURIComponent('...')),"plurk"));
		}
	else if (type=="facebook")
		{javascript: void(window.open('http://www.facebook.com/share.php?u=' + encodeURIComponent(url) ,"facebook"));
		}
}


// Use this function to retrieve a cookie.
    function getCookie(name)
    {
        var cname = name + "=";
        var dc = document.cookie;
        if (dc.length > 0)
        {
            begin = dc.indexOf(cname);
            if (begin != -1)
            {
                begin += cname.length;
                end = dc.indexOf(";", begin);
                if (end == -1) end = dc.length;
                return unescape(dc.substring(begin, end));
            }
        }
        return null;
    }

// Use this function to save a cookie.
    function setCookie(name, value, expires)
    {
        var exp = new Date();
        exp.setTime(exp.getTime()+(31*86400*1000));
        if(expires>"")
		document.cookie = name + "=" + escape(value) + "; path=/" + "; expires=" + expires;
	else
		document.cookie = name + "=" + escape(value) + "; path=/" + "; expires=" + exp.toGMTString();
    }

// Use this function to delete a cookie.
    function delCookie(name)
    {
        var exp = new Date();
        exp.setTime(exp.getTime()-30);
        document.cookie = name + "=" + "; path=/" + "; expires=" + exp.toGMTString();
    }

// MM_swapImgRestore v3.0
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//get bless
function getBless(){var xmlhttp=false;try{xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{xmlhttp=new
ActiveXObject('Microsoft.XMLHTTP');}catch(E){xmlhttp=false;}}
if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){xmlhttp=new XMLHttpRequest();}
var file='/func/getbless.asp?id=';xmlhttp.open('GET',file+id,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var content=xmlhttp.responseText;if(content){var temp=content.split("<br>");for(loop=0;loop<(temp.length-1);loop++){var loopid=loop+id-10;pausecontent2[loopid]=temp[loop]+"<br>";}}}}
xmlhttp.send(null);if(id<maxChannelNum){id=id+10;var callChannel=setTimeout("getBless()",40000)}else{id=0;clearTimeout(callChannel);}}


//bless push
function pausescroller(content,divId,divClass,delay){this.content=content
this.tickerid=divId
this.delay=delay
this.mouseoverBol=0
this.hiddendivpointer=1
//document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div><div align=right>i<a class=f9 href="/member/bless.asp">ְU</a>j</div></div>')
var scrollerinstance=this
if(window.addEventListener)
window.addEventListener("load",function(){scrollerinstance.initialize()},false)
else if(window.attachEvent)
window.attachEvent("onload",function(){scrollerinstance.initialize()})
else if(document.getElementById)
setTimeout(function(){scrollerinstance.initialize()},500)}
pausescroller.prototype.initialize=function(){this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv,this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if(window.attachEvent)
window.attachEvent("onunload",function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()},this.delay)}
pausescroller.prototype.animateup=function(){var scrollerinstance=this
if(parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()},50)}
else{this.getinline(this.hiddendiv,this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()},this.delay)}}
pausescroller.prototype.swapdivs=function(){var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer}
pausescroller.prototype.getinline=function(div1,div2){div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight,div1.offsetHeight)+"px"}
pausescroller.prototype.setmessage=function(){var scrollerinstance=this
if(this.mouseoverBol==1)
setTimeout(function(){scrollerinstance.setmessage()},100)
else{var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)?0:i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()}}
pausescroller.getCSSpadding=function(tickerobj){if(tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if(window.getComputedStyle)
return window.getComputedStyle(tickerobj,"").getPropertyValue("padding-top")
else
return 0}

// confirm
document.write("<div id=\'modal-confirm\' style=\'display:none;\'><div class=\'modal-header\'><span>`NI</span></div><p class=\'message\'></p><div class=\'buttons\'><div class=\'simplemodal-close\'>_</div><div class=\'simplemodal-yes\'>O</div></div></div>");
function ModalConfirm(message, callback, yesname, noname, header) {
	$('.modal-header').html(header);
	$('.simplemodal-yes').html(yesname);
	$('.simplemodal-close').html(noname);
	$('#modal-confirm').modal({
		closeHTML:"<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["20%",],
		overlayId:'modal-confirm-overlay',
		containerId:'modal-confirm-container', 
		onShow: function (dialog) {
			$('.message', dialog.data[0]).append(message);

			// if the user clicks "yes"
			$('.simplemodal-yes', dialog.data[0]).click(function () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
		}
	});
}
function ModalAlert(message, callback, btnname, header) {
	ModalConfirm(message, callback, btnname, '', header);
	$('.simplemodal-close').hide();
}

// ajax-loading msg
document.write("<div id=\'ajax-loading\' style=\'display:none;\'><span>еy...</span><p><img src=\'/image/ajax-loader.gif\'></p></div>");

function AjaxLoadingPanel(act){
	if (act=="0")
		$('#ajax-loading').hide();
	if (act=="1")
		$('#ajax-loading').show().css("top",($(window).height()-$('#ajax-loading').outerHeight())/2).css("left",($(window).width()-$('#ajax-loading').outerWidth())/2);
}