﻿// JScript 檔


function showFlash(objID, objSource, objWidth, objHeight, objQuality, objWmode, objBgcolor) {

	var pageUrl = self.window.location.href;
	if(pageUrl.substring(0,5) == 'https') {
		swfUrl = "https";
	} else {
		swfUrl = "http";
	}
	if (objID == "") objID = 'ShockwaveFlash1';
	if (objWidth == "") objWidth = '0';
	if (objHeight == "") objHeight = '0';
	if (objQuality == "") objQuality = 'best';
	if (objWmode == "") {
		objWmode = 'transparent';
	} else {
		objWmode = '';
	}
	document.write('<object id="' + objID + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="' + objSource + '" codebase="' + swfUrl +'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="' + objWidth + '" height="' + objHeight + '">');
	document.write('<param name=menu value=false>');
	document.write('<param name=allowScriptAccess value=always>');
	document.write('<param name=wmode value="'+ objWmode +'">');
	document.write('<param name=movie VALUE="'+ objSource +'">');
	document.write('<param name=quality VALUE="'+ objQuality +'">');
	document.write('<param name=bgcolor VALUE="'+ objBgcolor +'">');
	document.write('<embed allowScriptAccess="always" swLiveConnect="true" src="' + objSource + '" menu="false" quality="' + objQuality + '" wmode="' + objWmode + '" bgcolor="' + objBgcolor + '" width="' + objWidth + '" height="' + objHeight + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}

function openWindow(theURL,winName,width,height,scrollbars) {
	var screenW = (screen.width - width) / 2
	var screenH = (screen.height - height) / 3
	features = 'width=' + width + ',height=' + height + ',left=' + screenW + ',top=' + screenH + ',scrollbars=' + scrollbars + ',resizable=yes',
	window.open(theURL,winName,features);
}

function gotoNextForm(tabName, objID) {
	obj = document.getElementById(tabName).getElementsByTagName("input")
	if ( obj[objID - 1].value.length == 4 ) {
		obj[objID].focus()
	}
}



function ResizePageIMG(imgObj,iImgSrcWidth,iImgSrcHeight)
{
   //依各網站修改最大寬高即可
    var iMaxWidth = 620 ;
    var iMaxHeight = 600 ;
   
    ImageReSizeMax(imgObj,iMaxWidth,iMaxHeight,iImgSrcWidth,iImgSrcHeight)
    
}

 function ImageReSizeMax( sImgurl, iMaxWidth , iMaxHeight , iImgSrcWidth, iImgSrcHeight)
{
    var oImageOriginal ;
    
    srcWidth = iImgSrcWidth;
    srcHeight = iImgSrcHeight;
    
    if ((srcWidth > iMaxWidth) || (srcHeight > iMaxHeight))
        {
            

            if(srcHeight > iMaxHeight)
                {
                    srcWidth = iMaxHeight * srcWidth / srcHeight;
                    srcHeight = iMaxHeight;
                }
                
            if(srcWidth > iMaxWidth)
                {
                    srcHeight = iMaxWidth * srcHeight / srcWidth;
                    srcWidth = iMaxWidth;
                }
        }
    

    //if(srcWidth == 0) srcWidth = iMaxWidth;
    //if(srcHeight == 0) srcHeight = iMaxHeight;

    srcHeight = Math.round(srcHeight);
    srcWidth = Math.round(srcWidth);
    vSpac = Math.round((iMaxHeight - srcHeight) / 2)
    hSpac = Math.round((iMaxWidth - srcWidth) / 2)


    sImgurl.width = srcWidth;
    sImgurl.height = srcHeight;
    //sImgurl.vspace = vSpac;
    //sImgurl.hspace = hSpac;
	
    //alert(srcWidth + ',' + srcHeight);
	
    return 0;
}	


function DrawImage(ImgD,iwidth,iheight){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= iwidth/iheight){ 
			if(image.width>=iwidth){   
				ImgD.width=iwidth; 
				ImgD.height=(image.height*iwidth)/image.width; 
			}else{ 
				if(image.height>=iheight){   
				  ImgD.width=(image.width*iheight)/image.height; 
				  ImgD.height=iheight; 
			 	}else{ 
			  	ImgD.width=image.width;   
			  	ImgD.height=image.height; 
			  }
		  }
		}else{
			if(image.height>=iheight){   
				ImgD.height=iheight; 
				ImgD.width=(image.width*iheight)/image.height;   
			}else{ 
				if(image.height>=iheight){   
				  ImgD.width=iwidth; 
					ImgD.height=(image.height*iwidth)/image.width; 
				}else{
				  ImgD.width=image.width;   
				  ImgD.height=image.height; 
				}
			} 
		} 
	} 
} 

