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];}
}
//JavaScript分項新聞跑馬燈 START
var toScroll=new Array()
var ie=document.all
var dom=document.getElementById
var firstNews_obj;
var secondNews_obj;

function newsScroll(name){
  var c=this; c.name=name; c.mc=0; c.i=2;
  return this;
}

newsScroll.prototype.addItem = function(text,link,font,fontSize,fontStyle){
  var c = this;
  if (link !=''){
    if (font != '')
      toScroll[c.mc]="<a href='"+link+"'><font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font></a>";
    else
      toScroll[c.mc]="<a href='"+link+"'><font Class='"+fontStyle+"'>"+text+"</font></a>";
  }
  else { 
    if (font != '')
      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";
    else
      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";
  }
  c.mc++;
}

newsScroll.prototype.construct = function(){
  var c = this; theWidth = c.scrollerwidth; theHeight=c.scrollerheight; thebgColor = c.scrollerbgcolor; theBackground =c.scrollerbackground; theDelay=c.scrollerdelay;
  scroll_obj=eval(c.name);        
  if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+theWidth+';height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')
    document.writeln('<div style="position:absolute;width:'+theWidth+';height:'+theHeight+';clip:rect(0 '+theWidth+' '+theHeight+' 0);left:0;top:0">')
    document.writeln('<div id="firstNews" style="position:absolute;width:'+theWidth+';left:0;top:1">')
    document.write(toScroll[0])
    document.writeln('</div>')
    document.writeln('<div id="secondNews" style="position:absolute;width:'+theWidth+';left:0;top:0;visibility:hidden">')
    document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
  }
}

newsScroll.prototype.move = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight = c.scrollerheight; 
  scroll_obj=eval(c.name);
  tdiv=eval(whichdiv)

  if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
    tdiv.style.top=0+"px"
    setTimeout("scroll_obj.move(tdiv)",theDelay)
    setTimeout("scroll_obj.move2(secondNews_obj)",theDelay)
    //document.write('Got Milk?')
  return
  }
  if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
    tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
    setTimeout("scroll_obj.move(tdiv)",50)
  }
  else {
    tdiv.style.top=parseInt(theHeight)+"px"
    tdiv.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.move2 = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight= c.scrollerheight;
  scroll_obj=eval(c.name);
  tdiv2=eval(whichdiv)

  if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
    tdiv2.style.top=0+"px"
    setTimeout("scroll_obj.move2(tdiv2)",theDelay)
    setTimeout("scroll_obj.move(firstNews_obj)",theDelay)
    return
  }
  if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
    tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
    setTimeout("scroll_obj.move2(secondNews_obj)",50)
  }
  else {
    tdiv2.style.top=parseInt(theHeight)+"px"
    tdiv2.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.startScroll = function(){
  var c = this;
  scroll_obj=eval(c.name);        
  
  if (toScroll.length >2)
    c.i = 2;
  else
    c.i = 0;
  
  firstNews_obj=ie? firstNews : document.getElementById("firstNews")
  secondNews_obj=ie? secondNews : document.getElementById("secondNews")
  setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);
  secondNews_obj.style.top=theHeight;
  secondNews_obj.style.visibility='visible'
}
function Open(url)
{  
   window.open(url,null,"menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no,height=300,width=500");
}
function OpenMenu(url)
{  
   window.open(url,null,"menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no,height=800,width=500");
}
function changeSize(){
   ImgTotal=document.getElementById("WiHi");
     if(ImgTotal.width >= ImgTotal.height){
       if (ImgTotal.width>=450){
          ImgTotal.width=450;
       }
     }
     else{
       if (ImgTotal.height>=450){
          ImgTotal.height=450;
       }
     }
   }

function confirmDelete() {
	var truthBeTold = window.confirm("確定刪除此筆圖檔?");
	
	if (truthBeTold)
		return true;
	else  
		return false;
}

function openmyphoto(javampicture,windowparameters){ 
newwindow=window.open("","_blank", windowparameters); 
newwindow.document.write ("<html><head>"); 
newwindow.document.write ("<title>Picture</title>"); 
/*newwindow.document.write ("<script>");
newwindow.document.write ("function changePhotoSize(){");
newwindow.document.write ("ImgTotal=document.getElementById('WiHi');");
newwindow.document.write ("if(ImgTotal.width >= ImgTotal.height){");
newwindow.document.write ("if (ImgTotal.width>=800){");
newwindow.document.write ("ImgTotal.width=800;");
newwindow.document.write ("}");
newwindow.document.write ("}");
newwindow.document.write ("else{");
newwindow.document.write ("if (ImgTotal.height>=800){");
newwindow.document.write ("ImgTotal.height=800;");
newwindow.document.write ("}");
newwindow.document.write ("}}");
newwindow.document.write ("</script>");*/
newwindow.document.write ("</head><body onLoad='changePhotoSize();window.resizeTo(document.images[0].width+50,document.images[0].height+200);'>"); 
newwindow.document.write ("<a href='javascript:this.close()'><img src="); 
newwindow.document.write (javampicture); 
newwindow.document.write (" border='0' alt='CLOSE' id='WiHi'"); 
newwindow.document.write ("></a>"); 
newwindow.document.write ("</body></html>"); 
newwindow.document.close(); 
return false; 
} 
function opennewwindow(javampicture,memo,windowparameters){ 
newwindow=window.open("","_blank", windowparameters); 
newwindow.document.write ("<html><head>"); 
newwindow.document.write ("<title>Picture</title>"); 
newwindow.document.write ("</head><body onLoad='window.resizeTo(document.images[0].width+50,document.images[0].height+200);'>"); 
newwindow.document.write ("<a href='javascript:this.close()'><img src="); 
newwindow.document.write (javampicture); 
newwindow.document.write (" border='0' alt='CLOSE'"); 
newwindow.document.write ("></a>"); 
if(memo != ""){
newwindow.document.write ("<table><tr><td><font style='font-size:12px'>");
newwindow.document.write (memo); 
newwindow.document.write ("</font></td></tr></table>");
}
newwindow.document.write ("</body></html>"); 
newwindow.document.close(); 
return false; 
} 

function opennewwindowUMB(windowparameters){ 
newwindow=window.open("","_blank", windowparameters); 
newwindow.document.write ("<html><head>"); 
newwindow.document.write ("<title>傘把簡介</title>"); 
newwindow.document.write ("<link href='../includefile/afar.css' rel='stylesheet' type='text/css'>");
newwindow.document.write ("</head><body onLoad='window.resizeTo(800,300);'>"); 
newwindow.document.write ("<table border='0' width='100%' id='table1'>"); 
newwindow.document.write ("<tr>"); 
newwindow.document.write ("<td align='center'><font class='p_table'><img src='../images/UMB01.jpg'  width='150'></font></td>"); 
newwindow.document.write ("<td align='center'><font class='p_table'><img src='../images/UMB02.jpg' width='150'></font></td>"); 
//newwindow.document.write ("<td align='center'><font class='p_table'><img src='../images/UMB03.jpg' width='150'></font></td>"); 
newwindow.document.write ("<td align='center'><font class='p_table'><img src='../images/UMB04.jpg' width='150'></font></td>"); 
newwindow.document.write ("</tr>"); 
newwindow.document.write ("<tr>"); 
newwindow.document.write ("<td align='center'><font class='word3'>木製傘把</font></td>"); 
newwindow.document.write ("<td align='center'><font class='word3'>藤製傘把</font></td>"); 
//newwindow.document.write ("<td align='center'><font class='word3'>鋁製傘把</font></td>"); 
newwindow.document.write ("<td align='center'><font class='word3'>皮製傘把</font></td>"); 
newwindow.document.write ("</tr>"); 
newwindow.document.write ("</table>"); 
newwindow.document.write ("</body></html>"); 
newwindow.document.close(); 
return false; 
} 

function opennewwindowBigUMB(javampicture,windowparameters){ 
newwindow=window.open("","_blank", windowparameters); 
newwindow.document.write ("<html><head>"); 
newwindow.document.write ("<title>Picture</title>"); 
newwindow.document.write ("</head><body onLoad='window.resizeTo(document.images[0].width+50,document.images[0].height+200);'>"); 
newwindow.document.write ("<a href='javascript:this.close()'><img src="); 
newwindow.document.write (javampicture); 
newwindow.document.write (" border='0' alt='CLOSE'"); 
newwindow.document.write ("></a>"); 
newwindow.document.write ("</body></html>"); 
newwindow.document.close(); 
return false; 
} 

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function displayStatusMsg(msgStr) { 

status=msgStr;

document.returnValue = true;

}

