﻿<!-- //全選功能
function ToggleAll(checked,theform,thename) {
 var p =0;
	while (p < theform.elements.length) {
		if (theform.elements[p].name== thename){
		  	theform.elements[p].checked=checked;}
				p++;
	}
}
//-->

<!-- //Lock Form
function LockForm(mybtn,myform)
{
  myform.elements[mybtn].disabled = true;
}
//-->

<!-- //Make Sure
function cfirm(CfirmMsg,myform,btn)
{
 if (confirm( CfirmMsg ))	
   {
    LockForm(btn,myform);
    myform.submit();
   } 
 else 
 { return false; } 
}
//-->

<!-- //列印功能
function FriendPrint(ClickO) {
 mmsq = document.getElementsByName("removeprint");
 for (I=0;I<mmsq.length;I++) mmsq[I].style.display = "none";
 mmst = document.getElementsByName("friendprint");
 nHTML = "";
 for (I=0;I<mmst.length;I++) nHTML = nHTML + mmst[I].innerHTML;
 document.body.innerHTML = nHTML;
}

function printing() {
  if(isNN4 || isDOM) {
    window.print();
  }
}
// -->

<!-- //表格縮放
function doOpen(num)
{
obj1=document.getElementsByName("sh"+num)
		if(obj1[0].style.display=="")	{
    	     for (var i=0;i<obj1.length;i++){
        	     obj1[i].style.display="none";  }
	      }
		else {
         	for (var i=0;i<obj1.length;i++){
            	 obj1[i].style.display="";  }
      }
} 
// -->

<!-- //選項menu
function FTMenu(theL,theR,theLEN)
{

if(document.all[theR].style.display=='')
 {
	document.all[theR].style.display='none';
 }
else
 {
	ShowR = theR.substr(0,3);  //FR_
    ShowL = theL.substr(0,3);  //FL_
	
	//hide other
	for(i=1;i<=theLEN;++i)
	{
		document.all[ShowR + i].style.display='none';
        document.all[ShowL + i].style.display='';
	}
	
	document.all[theR].style.display='';
	
 }
}
// -->

<!-- //新開視窗
function nOpen(myURL,winName, mywidth, myheight)
 {
  window.open(myURL,winName,'menubar=no,status=yes,scrollbars=1,toolbar=no,left='+(screen.availWidth/2-mywidth/2-250)+',top='+(50)+',width='+mywidth+',height='+myheight+'');
  //screen.availHeight/2-myheight/2
 }
// -->

<!--
function RESize(){

window.resizeTo(document.all["WINREZ"].width+80,document.all["WINREZ"].height+80);
}
//-->

function selectWord( input ) {
  if ( document.selection ) {
	var range = document.selection.createRange();
	range.moveStart( 'word', -1 );
	range.moveEnd( 'word', 1 );
	range.select();
  }
}

<!-- //日期popup
var gdCtrl = new Object();
var goSelectTag = new Array();
var gcGray = "#999999";    //Not in this month field
var gcToggle = "#D9FFFF";  //other field mouseover bg
var gcBG = "#FFFFFF";     //other field mouseout bg
var gcOver = "#990000";  //today onMouseOver
var gcOut = "#333333";  //today onMouseOut

var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();
var myyear,mymonth;

//****************************************************************************
// Param: popCtrl 欲顯示的欄位;
// dateCtrl 欲填入的欄位;
// i.e.: <input type="text" name="date" style="text-align:center" readonly><input type="button" value="PressMe" onclick="fPopCalendar(date,date);return false">
//****************************************************************************
function fPopCalendar(popCtrl, dateCtrl){
event.cancelBubble=true;
gdCtrl = dateCtrl;
fSetYearMon(giYear, giMonth);
var point = fGetXY(popCtrl);
mymonth = tbSelMonth.value;
myyear = tbSelYear.value;
with (VicPopCal.style) {
 left = point.x;
 top = point.y+popCtrl.offsetHeight+1;
 width = 180; //VicPopCal.offsetWidth;
 height = VicPopCal.offsetHeight;
 fToggleTags(point);
 visibility = 'visible';
}
VicPopCal.focus();
}

function fSetDate(iYear, iMonth, iDay){
var thidate=iYear+"/"+iMonth+"/"+iDay; //Here, you could modify the locale as you need !!!!
//var mydate = new Date();
//var myyear = mydate.getFullYear();
//var mymonth = parseInt(mydate.getMonth())+1;
var myv = parseInt(myyear)*100+parseInt(mymonth);
var thisv = parseInt(iYear)*100+parseInt(iMonth);

//alert('myv='+myv+'thisv='+thisv);

if(thisv>myv && parseInt(iDay) >14){
	if(parseInt(iMonth)>=3)
		gdCtrl.value = iYear+"/"+(parseInt(iMonth)-2)+"/"+iDay; //Here, you could modify the locale as you need !!!!
	else if(parseInt(iMonth)==1)
		gdCtrl.value = (parseInt(iYear)-1)+"/11/"+iDay; //Here, you could modify the locale as you need !!!!
	else if(parseInt(iMonth)==2)
		gdCtrl.value = (parseInt(iYear)-1)+"/12/"+iDay; //Here, you could modify the locale as you need !!!!
	}
else
	gdCtrl.value = iYear+"/"+iMonth+"/"+iDay; //Here, you could modify the locale as you need !!!!
fHideCalendar();
}

function fHideCalendar(){
VicPopCal.style.visibility = "hidden";
for (i in goSelectTag)
 goSelectTag[i].style.visibility = "visible";
goSelectTag.length = 0;
}

function fSetSelected(aCell){
var iOffset = 0;
var iYear = parseInt(tbSelYear.value);
var iMonth = parseInt(tbSelMonth.value);

aCell.bgColor = gcBG;
with (aCell.children["cellText"]){
 var iDay = parseInt(innerText);
 if (color==gcGray)
  iOffset = (Victor<10)?-1:1;
 iMonth += iOffset;
 if (iMonth<1) {
  iYear--;
  iMonth = 12;
 }else if (iMonth>12){
  iYear++;
  iMonth = 1;
 }
}
fSetDate(iYear, iMonth, iDay);
}

function Point(iX, iY){
 this.x = iX;
 this.y = iY;
}

function fBuildCal(iYear, iMonth) {
var aMonth=new Array();
for(i=1;i<7;i++)
 aMonth[i]=new Array(i);

var dCalDate=new Date(iYear, iMonth-1, 1);
var iDayOfFirst=dCalDate.getDay();
var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
var iDate = 1;
var iNext = 1;

for (d = 0; d < 7; d++)
 aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
for (w = 2; w < 7; w++)
 for (d = 0; d < 7; d++)
  aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
return aMonth;
}

function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {
var WeekDay = new Array("日","一","二","三","四","五","六");
var styleTD = " bgcolor='"+gcBG+"' bordercolor='#CCCCCC' valign='middle' align='center' height='"+iCellHeight+"' style='cursor:hand' width='"+iDateTextSize+"' ";

with (document) {
 write("<tr align='center'>");
 for(i=0; i<7; i++)
  write("<td height='20' class='style08s' bgcolor='#ffffff'>" + WeekDay[i] + "</td>");
 write("</tr>");

 for (w = 1; w < 7; w++) {
  write("<tr align='center'>");
  for (d = 0; d < 7; d++) {
   write("<td id=calCell "+styleTD+"' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
   write("<font id=cellText> </font>");
   write("</td>")
  }
  write("</tr>");
 }
}
}

function fUpdateCal(iYear, iMonth) {
mymonth = tbSelMonth.value;
myyear = tbSelYear.value;
myMonth = fBuildCal(iYear, iMonth);
var i = 0;
for (w = 0; w < 6; w++)
 for (d = 0; d < 7; d++)
  with (cellText[(7*w)+d]) {
   //Victor = i++;
   if (myMonth[w+1][d]<0) {
      //alert(myMonth[w+1][d]);
	   Victor = i++;
	color = gcGray;
    innerText = -myMonth[w+1][d];
   }
   else if (d==6) {
    color = "#3366FF";
    innerText = myMonth[w+1][d];
   }
   else if (d==0) {
    color = "#990033";
    innerText = myMonth[w+1][d];
   }
   else {
    color = "#333333";
    innerText = myMonth[w+1][d];
   }
  }
}

function fSetYearMon(iYear, iMon){
tbSelMonth.options[iMon-1].selected = true;
for (i = 0; i < tbSelYear.length; i++)
 if (tbSelYear.options[i].value == iYear)
  tbSelYear.options[i].selected = true;
  fUpdateCal(iYear, iMon);
}

function fPrevMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (--iMon<1) {
  iMon = 12;
  iYear--;
}

fSetYearMon(iYear, iMon);
}

function fNextMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (++iMon>12) {
  iMon = 1;
  iYear++;
}

fSetYearMon(iYear, iMon);
}

function fToggleTags(){
with (document.all.tags("Select")){
 for (i=0; i<length; i++)
  if ((item(i).Victor!="ORED")&&fTagInBound(item(i))){
   item(i).style.visibility = "hidden";
   goSelectTag[goSelectTag.length] = item(i);
  }
}
}

function fTagInBound(aTag){
with (VicPopCal.style){
 var l = parseInt(left);
 var t = parseInt(top);
 var r = l+parseInt(width);
 var b = t+parseInt(height);
 var ptLT = fGetXY(aTag);
 return !((ptLT.x>r)||(ptLT.x+aTag.offsetWidth<l)||(ptLT.y>b)||(ptLT.y+aTag.offsetHeight<t));
}
}

function fGetXY(aTag){
var oTmp = aTag;
var pt = new Point(0,0);
do {
 pt.x += oTmp.offsetLeft;
 pt.y += oTmp.offsetTop;
 oTmp = oTmp.offsetParent;
} while(oTmp.tagName!="BODY");
return pt;
}

var gMonths = new Array("1","2","3","4","5","6","7","8","9","10","11","12");

with (document) {
write("<Div id='VicPopCal' onclick='event.cancelBubble=true' style='POSITION:absolute;visibility:hidden;border:1px solid #CCCCCC;width:10;z-index:100;'>");
write("<table width='100%' border='1' cellpadding='0' cellspacing='1' bordercolor='#CCCCCC' bgcolor='#FFFFFF'>");
write("<tr>");
write("<td valign='middle' align='center' class='style06s'>");

write(" <img src='../images/point_gray_l.gif' name='PrevMonth' onClick='fPrevMonth();' style='cursor:hand;'> ");

write(" <Select name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='ORED' class='inputblue'>");
for(i=1911;i<2020;i++)
 write("<option value='"+i+"'>"+i+"</option>");
write("</Select>年");
write(" <select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='ORED' class='inputblue'>");
for (i=0; i<12; i++)
 write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
write("</Select>月");

write(" <img src='../images/point_gray_r.gif' name='NextMonth' onClick='fNextMonth();' style='cursor:hand;'> ");

write("</td>");
write("</tr><tr>");
write("<td align='center'>");
write("<DIV style='background-color:#99CCCC'><table width='100%' border='1' cellpadding='0' cellspacing='0' bordercolor='#CCCCCC' class='style01s'>");
fDrawCal(giYear, giMonth, 18, 20);
write("</table></div>");
write("</td>");
write("</tr><tr><td align='center' height='20'>");
write("<B style='cursor:hand;font:bold 12;color:#333333 ' onclick='fSetDate(giYear,giMonth,giDay)' onMouseOver='this.style.color=gcOver' onMouseOut='this.style.color=gcOut'>Today: "+giYear+"/"+giMonth+"/"+giDay+"</B>");
write("</td></tr>");
write("</table></div>");
}
//-->


<!-- //mouseover 小視窗
var bV=parseInt(navigator.appVersion);
var NN4u=(document.layers) ? true : false;
var IE4u=((document.all)&&(bV>=4))?true:false;
var moveFlag=false;
var BorderColour="CCCCCC"; //外框
var tipfntSize=10; //內容文字大小
var tipBgColor="FFFFFF"; //內容文字底色
var tipTextColor="333333"; //內容文字
var tipBorderColor = "CCCCCC"
var fntSize = 10;

function setReload(){
window.location.reload()
}
function showTip(msg){
var obj = 'TipBox';
moveFlag=true;
if(NN4u){
with (document[obj].document){
open();
write('<layer ID=TipBox bgColor=#'+tipBgColor+' style="border:1px solid #'+tipBorderColor+'; font-size:'+fntSize+'px;"><font color=#'+tipTextColor+' lang="big5" face="Verdana">'+msg+'</font></layer>');
close();
}
document.layers[obj].visibility = 'visible';
}else if(IE4u){
IE_MouseMove();
document.all[obj].innerHTML = "<table STYLE=\"FILTER:ALPHA(OPACITY=100)\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" ><tr><td height='20' width='20' bgcolor="+tipBgColor+"><span style=\"font-size: "+tipfntSize+"px; color: #"+tipTextColor+"\">"+msg+"</span></td></tr></table>";
;
document.all[obj].style.visibility = 'visible';
}
//window.status=msg;
}
function hideTip(){
var obj = 'TipBox';
moveFlag=false;
if(NN4u){
if(document.layers[obj] != null) document.layers[obj].visibility = 'hidden';
}else if(IE4u)
document.all[obj].style.visibility = 'hidden';
window.status="";
}
function IE_MouseMove(){
if(moveFlag){
var x = event.x;
var y = event.y;
var objp = document.all.TipBox.style;
var xx = (document.body.scrollLeft+x);
var yy = (document.body.scrollTop+y);
objp.pixelLeft = xx+20;
objp.pixelTop = yy+10;
//if (document.body.scrollWidth - xx-12 > 84){
//objp.pixelWidth =150; //寬度
//}
//else{
//objp.pixelWidth=document.body.scrollWidth - xx-12;
//}
}
}
function NN_MouseMove(e){
if(moveFlag){
var objp = document.layers.TipBox;
objp.moveTo(e.x+10, e.y+20);
}
}
if(IE4u){
document.write("<DIV ID=TipBox STYLE='position:absolute; visibility: hidden; padding: 0em 0em 0em 0em; border:1px solid #"+BorderColour+";'></DIV>");
document.onmousemove = IE_MouseMove;
}else{
document.write("<DIV ID=TipBox STYLE='position:absolute; visibility: hidden; background-color: #"+tipBgColor+"; border:1px solid #"+tipBorderColor+"; font-size: "+fntSize+"px'></DIV>");
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = NN_MouseMove;
setTimeout("window.onresize=setReload",500)
}
//-->
