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];}
}

function ImgShow(Output,img,w,h,type,layout,link,target,alt) {
   if (!img || img=='&nbsp;') {
      if (Output==0) return;
      else if (Output==1) document.write("目前無圖片");
      else document.write(Output);
   }
   else {
      Iw = (w && w!='&nbsp;') ? ' width="'+w+'" ' : ''; Ih = (h && h!='&nbsp;') ? ' height="'+h+'" ' : ''; type = (type && type!='&nbsp;') ? type : 'IMAGE';
      switch(type) {
         case 'IMAGE':
            if (alt && alt!='&nbsp;') Ialt = ' alt="'+alt+'" '; else Ialt = '';
            str =  '<img src="'+img+'" border="0"'+Iw+Ih+Ialt+'>';
            if (!target || target=='&nbsp;') target= ' '; else target = ' target="'+target+'" '
            if (link && link!='0' && link!='&nbsp;') str = '<a href="'+link+'"'+target+'>'+str+'</a>';

         break;
         case 'FLASH':
         	/*m here carl, 2003-12-29, 修改flash 版本無法相容的問題, 5 升級到 6*/
            /*str = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
            ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" '+
            Iw+Ih+'><PARAM NAME=movie VALUE="'+img+'"><PARAM NAME=wmode VALUE=transparent><PARAM NAME=quality VALUE=high><PARAM NAME=menu VALUE=false>'+
            '<EMBED src="'+img+'" quality=high '+Iw+Ih+' TYPE="application/x-shockwave-flash" '+
            'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'+
            '</EMBED></OBJECT>';*/
            str = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
            ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" '+
            Iw+Ih+'><PARAM NAME=movie VALUE="'+img+'"><param name=quality value=high>'+
            '<EMBED src="'+img+'" quality=high '+Iw+Ih+' TYPE="application/x-shockwave-flash" '+
            'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'+
            '</EMBED><></OBJECT>';
         break;
      }
      if (layout=='0') layout = false;
      if (!layout) document.write(str);
      else return str;
   }

}

function ImgShow2(max,img,w,h,type,link) {
   if ( isNaN(w) ) w = 0;
   if ( isNaN(h) ) h = 0;
   big = ( w >= h ) ? w : h;
   size = ( w>=h ) ? 0 : 1;
   if ( big > max ) {
      if ( size==0 ) { w=max; h=0; }
      else { h=max; w=0; }
   }
   a = '<img src="/default/tmpl-img/001/img/space.gif" width="'+max+'">';
   ImgShow(a,img,w,h,type,0,link);
}

function ImgShow3(img,w,h,type,link,max,show,color1,color2) {
   max = parseInt(max);
   if ( max==0 || max=='' || isNaN(max) ) return;
   if ( isNaN(w) ) w = 0;
   if ( isNaN(h) ) h = 0;
   size = ( w>=h ) ? 0 : 1;
   if( show==1 ) {
      document.writeln('<table height='+max+' cellspacing=0 cellpadding=1 width='+max+' bgcolor='+color1+' border=0>');
      document.writeln('<tr>');
      document.writeln('<td>');
   }
   /*{{{原來的寫法}}}*/
   /*if ( size==0 ) { w=0; h=h; }
   else { h=h; w=0; }*/
   
	if (type == "FLASH") {
		if (w > max) w = max;
	}
	else {
		if (size == 0) {
			w = 0;h = h;
		}
		else {
			h = h;w = 0;
		}
	}

   a = '<img src="/default/tmpl-img/001/img/space.gif" height="'+max+'">';
   document.writeln('<table cellspacing=0 cellpadding=0 width="'+max+'" height="'+max+'" ');
   if(isNaN(color2) ) document.writeln(' bgcolor='+color2);
   document.writeln(' border=0>');
   document.writeln('<tr>');
   document.writeln('<td align=center>');
   ImgShow(a,img,w,h,type,0,link);
   document.writeln('</td>');
   document.writeln('</tr>');
   document.writeln('</table>');
   if( show==1 ) {
      document.writeln('</td>');
      document.writeln('</tr>');
      document.writeln('</table>');
   }
}

function ItemZA(preid,preimg,nextid,nextimg,zimg,ztype,zximg) {
   document.write("<table border=0 cellpadding=3 cellspacing=0 width=100% align=center><tr>");
   document.write("<td align=center>");ItemLink(preid,preimg);document.write("</td>");
   document.write("<td align=center>");ImgZoom(zximg,zimg,ztype);document.write("</td>");
   document.write("<td align=center>");ItemLink(nextid,nextimg);document.write("</td>");
   document.write("</tr></table>");
}

function ItemLink(id,show) {
   if (!id || id=='&nbsp;') return;
   document.writeln("<a href=\"../b2c/pro_det.asp?pro_no="+id+"\">"+show+"</a>");
}

/*檢查Email格式*/
function CheckForm(eform){
	if (eform("mail").value==''){
		alert('信箱不能空白');
		eform("mail").focus();	
		return false;
	}
				
	if (eform("mail").value != '') {
	        if (IsMail(eform("mail").value)==false) {
	        alert("電子郵件格式錯誤！");
	        eform("mail").focus();
	        return false;
	        }  
	}	
		return true;
	}
	
function IsMail (InStr)  {
    if ((InStr.indexOf("@") !=-1) && (InStr.indexOf(".") != -1))
	 return true;
	else return false;
}

/*開新視窗*/
function toPopApp(file,x,y){
  TheNewWin=window.open(file,'PopApp','width='+x+',height='+y+',toolbar=no,menubars=no,scrollbars=yes,resizable=no');
  //TheNewWin.blur();
  TheNewWin.focus();
}

function OpenWindow(Url,xWidth,xHeigh,WinStarus,WinScrollbars)
{
xtop =0 ;
xleft = screen.width-xWidth-30;
if(screen.width==1024)
{ xHeigh=xHeigh+160 }
OpenWin = this.open(Url, "_blank","toolbar=0,menubar=0,location=0,resize=0,status="+WinStarus+",scrollbars="+WinScrollbars+",width="+xWidth+",height="+xHeigh+",top="+xtop+",left="+xleft)
OpenWin.focus();
}


