<!--
//圖片淡入
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}

function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=70
}

function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}

//是否為合法數字(0~9 & .)
function legalnumber(thisone){
    if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46){    	
        alert("請輸入正確的數值!!");
        thisone.focus();
        return (false);
       }      
}

//光棒效果
//亮
function High_light(theTr,theColor){
  theTr.bgColor=theColor;
}

//暗	
function No_light(theTr,theColor){
  theTr.bgColor=theColor;
}

//檢查身份證字號是否正確
function sID_onblur(thefield)
{ //heaven
	thefield.value = thefield.value.toUpperCase();

	var indexstring = "ABCDEFGHJKLMNPQRSTUVXYWZIO";
	var firstcharacter = thefield.value.substring(0,1);
	var secondcharacter = thefield.value.substring(1,2);
	var alphanumber = 0;
	var checknumber,sum,firstnumber,secondnumber;
	var i;
	
	if(thefield.value.length != 10)
	{
		alert("身份証號碼長度不符 !");
		thefield.value = "";
		thefield.focus();
		return false;
	}
	
	checknumber = thefield.value.substring(9,10);
	alphanumber = indexstring.indexOf(firstcharacter)+10;
	firstnumber = parseInt(alphanumber/10);
 	secondnumber = alphanumber % 10;

	sum = 0;

	for(i=1 ; i<thefield.value.length ; i++)
		sum += thefield.value.substring(i,i+1)*(9-i);
	
	sum += parseInt((firstnumber*1)) + parseInt((secondnumber*9)) + parseInt(checknumber);

	if((sum % 10) == 0)
		return true;
	else
	{
		alert("身份証號碼錯誤 !");
		thefield.value = "";
		thefield.focus();
		return false;
	}
}

//檢查帳號、密碼是否為-「英文字母」、「數字」或「_」
function isValid(val){
  var i;
  for (i=0; i<val.length; i++){
    var c = val.charAt(i);
    if (!(  (c.toLowerCase() >= 'a' && c.toLowerCase() <= 'z') || (c >='0' && c <='9') || c =='_'  ))
       return false;
  }
  return true;
}

//檢查電話號碼格式
function isNumDup(val){
   var i,DupFlag;
   var firstchar=val.charAt(0);
   for(i=0; i<val.length; i++){
      if(val.charAt(i) == firstchar)
     	DupFlag = true;
      else
     	DupFlag = false;
      if (!DupFlag)
        break;
   }
   return DupFlag;
}

//檢查姓名字數
function isCh(val){//recognize chinese char:4E00~FA2D
  var i,ChFlag;
  for(i=0; i<val.length; i++){
    if (val.charCodeAt(i)>=19968 && val.charCodeAt(i)<=64045)
       ChFlag = true;
    else
       ChFlag = false;
    if (!ChFlag)
       break;
  }
  return ChFlag;
}

//檢查帳號
function checkuserid(theForm){
  if(theForm.userid.value.length < 5 || theForm.userid.value.length > 15){
     alert("會員帳號 長度需介於(5-15)個字之間!!");
     theForm.userid.focus();
     theForm.userid.select();
     return;
  }  
  if (!isValid(theForm.userid.value)){
     alert("會員帳號只能是「英文字母」、「數字」或「_」,並區分大小寫，例：ABCDE 或 abcde 或 ABC_123");
     theForm.userid.focus();
     theForm.userid.select();
     return;
  }  
    
    userid = theForm.userid.value;
    window.open("member_center_save.php?state=checkuserid&userid=" + userid , "userid_check", "menubar=no,toolbar=no, width=300, height=120");
}

//檢查Email
function EmailConfirm(theForm){
  if(theForm.email.value.indexOf('@')==-1 || theForm.email.value.indexOf('.')==-1){
     alert("eMail的格式不對喔!!");
     theForm.email.focus();
     theForm.email.select();
     return ;
  }
    email = theForm.email.value;
    window.open("member_center_save.php?state=checkemail&email=" + email, "email_check", "menubar=no,toolbar=no, width=300, height=120");
}


//輸入格式提示(加入會員－會員資料)
function Write_Form_check(theForm) {
  if(theForm.userid.value.length < 5 || theForm.userid.value.length > 15){
     alert("會員帳號 長度需介於(5-15)個字之間!!");
     theForm.userid.focus();
     theForm.userid.select();
     return false;
  }  
  if (!isValid(theForm.userid.value)){
     alert("會員帳號只能是「英文字母」、「數字」或「_」,並區分大小寫，例：ABCDE 或 abcde 或 ABC_123");
     theForm.userid.focus();
     theForm.userid.select();
     return false;
  }  
  if(theForm.password.value.length < 5 || theForm.password.value.length > 15){
     alert("會員密碼 長度需介於(5-15)個字之間!!");
     theForm.password.focus();
     theForm.password.select();
     return false;
  }
  if (!isValid(theForm.password.value)){
     alert("會員密碼只能是「英文字母」、「數字」或「_」,並區分大小寫，例：ABCDE 或 abcde 或 ABC_123");
     theForm.password.focus();
     theForm.password.select();
     return false;
  }
  if(theForm.password_confirm.value == ""){
     alert("您尚未輸入密碼確認!!");
     theForm.password_confirm.focus();
     theForm.password_confirm.select();
     return false;
  }
  if(theForm.password.value != theForm.password_confirm.value){
     alert("密碼確認不符!!!!");
     theForm.password_confirm.focus();
     theForm.password_confirm.select();
     return false;
  }
  if(theForm.email.value == ""){
     alert("您尚未輸入eMail!!");
     theForm.email.focus();
     theForm.email.select();
     return false;
  }
  if(theForm.email.value.indexOf('@')==-1 || theForm.email.value.indexOf('.')==-1){
     alert("eMail的格式不對喔!!");
     theForm.email.focus();
     theForm.email.select();
     return false;
  }
  if(theForm.name.value.length < 2 || theForm.name.value.length > 5){
     alert("會員姓名 長度需介於(2-5)個中文字之間!!");
     theForm.name.focus();
     theForm.name.select();
     return false;
  }
  /***
  if (!isCh(theForm.name.value)){
     alert("請填入正確的中文姓名!");
     theForm.name.focus();
     theForm.name.select();
     return false;
  }
  ***/
  /***
  if(theForm.idno.value == ""){
     alert("您尚未輸入身分證字號或護照號碼!!");
     theForm.idno.focus();
     theForm.idno.select();
     return false;
  }
  if (!sID_onblur(theForm.idno)){
     theForm.idno.focus();
     theForm.idno.select();
     return false;
  }
  ***/
  
  if(theForm.year.value == "" || theForm.month.value == "" || theForm.day.value == ""){
     alert("您尚未輸出生日期!!");
     theForm.year.focus();
     theForm.year.select();
     return false;
  }
  
  /***
  if(theForm.tel_office.value == ""){
     alert("您尚未輸入聯絡電話!!");
     theForm.tel_office.focus();
     theForm.tel_office.select();
     return false;
  }
  ***/
  
   //聯絡電話的格式
  if (theForm.mobile.value != "" && (isNumDup(theForm.tel_office.value) || theForm.tel_office.value.length < 5 )){
     alert("公司聯絡電話的格式不對喔");
     theForm.tel_office.focus();
     theForm.tel_office.select();
     return false;
  }
  if (theForm.mobile.value != "" && (isNumDup(theForm.mobile.value) || theForm.mobile.value.length < 9)){
     alert("行動電話的格式不對喔");
     theForm.mobile.focus();
     theForm.mobile.select();
     return false;
  }
  
  return true;
}
  
//輸入格式提示(修改資料－會員資料)
function Edit_Form_check(theForm) {
  if(theForm.password.value.length < 5 || theForm.password.value.length > 15){
     alert("會員密碼 長度需介於(5-15)個字之間!!");
     theForm.password.focus();
     theForm.password.select();
     return false;
  }
  if (!isValid(theForm.password.value)){
     alert("會員密碼只能是「英文字母」、「數字」或「_」,並區分大小寫，例：ABCDE 或 abcde 或 ABC_123");
     theForm.password.focus();
     theForm.password.select();
     return false;
  }
  if(theForm.email.value == ""){
     alert("您尚未輸入eMail!!");
     theForm.email.focus();
     theForm.email.select();
     return false;
  }
  if(theForm.email.value.indexOf('@')==-1 || theForm.email.value.indexOf('.')==-1){
     alert("eMail的格式不對喔!!");
     theForm.email.focus();
     theForm.email.select();
     return false;
  }
  if(theForm.name.value.length < 2 || theForm.name.value.length > 5){
     alert("會員姓名 長度需介於(2-5)個中文字之間!!");
     theForm.name.focus();
     theForm.name.select();
     return false;
  } 
  if(theForm.year.value == "" || theForm.month.value == "" || theForm.day.value == ""){
     alert("您尚未輸出生日期!!");
     theForm.year.focus();
     theForm.year.select();
     return false;
  }    
   //聯絡電話的格式
  if (theForm.mobile.value != "" && (isNumDup(theForm.tel_office.value) || theForm.tel_office.value.length < 5 )){
     alert("公司聯絡電話的格式不對喔");
     theForm.tel_office.focus();
     theForm.tel_office.select();
     return false;
  }
  if (theForm.mobile.value != "" && (isNumDup(theForm.mobile.value) || theForm.mobile.value.length < 9)){
     alert("行動電話的格式不對喔");
     theForm.mobile.focus();
     theForm.mobile.select();
     return false;
  }
  
  return true;
}

//輸入格式提示(加入會員－選擇所在學校)
function School_Form_check(theForm)
{
  if (theForm.schno.value == "")
  {
    alert("請務必選擇「 所在學校 」!!");
    theForm.schno.focus();
    return (false);
  }
}

//輸入格式提示(會員服務－查詢密碼)
function Email_Form_check(theForm)
{
  if (theForm.userid.value == "")
  {
    alert("請務必填寫「 帳號 」!!");
    theForm.userid.focus();
    return (false);
  }
  if (theForm.email.value == "")
  {
    alert("請務必填寫「 電子郵件 」!!");
    theForm.email.focus();
    return (false);
  }
}

//輸入格式提示(會員登入)
function Login_Form_check(theForm)
{
  if (theForm.Account.value == "")
  {
    alert("請務必填寫「 帳號 」!!");
    theForm.Account.focus();
    return (false);
  }
  if (theForm.Password.value == "")
  {
    alert("請務必填寫「 密碼 」!!");
    theForm.Password.focus();
    return (false);
  }
}
//開新視窗(一般)
function windows_open(thisurl,thisframe,thiswidth,thisheight,thisfeture){
var screen_width  = window.screen.width;
var screen_height = window.screen.height
var win_left;
var win_top;

  win_left = (screen_width - thiswidth)/2;
  win_top  = (screen_height - thisheight)/2 - 30;

  window.open(thisurl, thisframe, "toolbar=no,width="+thiswidth+",height="+thisheight+",top="+win_top+",left="+win_left+" "+thisfeture);
}

//開新視窗(一般)
function windows_down_open(thisurl,thisframe,thiswidth,thisheight,thisfeture){
var screen_width  = window.screen.width;
var screen_height = window.screen.height
var win_left;
var win_top;

  win_left = (screen_width - thiswidth)/2;
  win_top  = (screen_height - thisheight)/2 + 200;

  window.open(thisurl, thisframe, "toolbar=no,width="+thiswidth+",height="+thisheight+",top="+win_top+",left="+win_left+" "+thisfeture);
}

//開新視窗(靠右)
function windows_right_open(thisurl,thisframe,thiswidth,thisheight,thisfeture){
var screen_width  = window.screen.width;
var screen_height = window.screen.height
var win_left;
var win_top;
var win_height;

  win_left = (screen_width - thiswidth) - 10;  
  win_top  = 120;
  win_height = thisheight;
  
  window.open(thisurl, thisframe, "toolbar=no,width="+thiswidth+",height="+win_height+",top="+win_top+",left="+win_left+" "+thisfeture);
}

//開新視窗(大視窗)
function windows_big_open(thisurl,thisframe,thisfeture){
var screen_width  = window.screen.width - 10;
var screen_height = window.screen.height - 130;

  window.open(thisurl, thisframe, "toolbar=no,width="+screen_width+",height="+screen_height+",top=0,left=0 "+thisfeture);
}

function over_effect(e,state){
if (document.all)
    source4=event.srcElement
else if (document.getElementById)
    source4=e.target
if (source4.className=="menulines")
    source4.style.borderStyle=state
else{
    while(source4.tagName!="TABLE"){
          source4=document.getElementById? source4.parentNode : source4.parentElement
          if (source4.className=="menulines")
          source4.style.borderStyle=state
    }
}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v3.0
  //Copyright 1998 Macromedia, Inc. All rights reserved.
  var i,j,aLayer,retVal,curDrag=null,NS=(navigator.appName=='Netscape'), curLeft, curTop;
  if (!document.all && !document.layers) return false;
  retVal = true; if(!NS && event) event.returnValue = true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = MM_findObj(objName); if (!curDrag) return false;
    if (!document.allLayers) { document.allLayers = new Array();
      with (document) if (NS) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
        for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
          with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
      } else for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];}
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
    curDrag.MM_oldZ = (NS)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS)?curDrag.left:curDrag.style.pixelLeft; curDrag.MM_startL = curLeft;
    curTop = (NS)?curDrag.top:curDrag.style.pixelTop; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop -cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop +cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent = ((NS)?objName.type:event.type);
    if (theEvent == 'mousedown') {
      var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
      var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
      var maxDragZ=null; document.MM_maxZ = 0;
      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
        var aLayerZ = (NS)?aLayer.zIndex:aLayer.style.zIndex;
        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
        var isVisible = (((NS)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (!NS) { parentLayer = aLayer.parentElement;
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
              parentLayer = parentLayer.parentElement; } }
          var tmpX=mouseX-(((NS)?pageX:style.pixelLeft+parentL)+MM_hLeft);
          var tmpY=mouseY-(((NS)?pageY:style.pixelTop +parentT)+MM_hTop);
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS)?clip.width :offsetWidth);
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS)?clip.height:offsetHeight);
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        document.onmousemove = MM_dragLayer; if (NS) document.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS)?curDrag.left:curDrag.style.pixelLeft;
        curTop = (NS)?curDrag.top:curDrag.style.pixelTop;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          eval('curDrag.'+((NS)?'':'style.')+'zIndex=document.MM_maxZ+1');
          if (!curDrag.MM_dropBack) document.MM_maxZ++; }
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS) {left = newLeft; top = newTop;}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        if (MM_dragJS) eval(MM_dragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-((NS)?left:style.pixelLeft),2)+
             Math.pow(MM_targT-((NS)?top:style.pixelTop),2))<=MM_tol) {
          if (NS) {left = MM_targL; top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {if (NS) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      document.MM_curDrag = null;
    }
    if (NS) document.routeEvent(objName);
  } return retVal;
}

//-->
