function EnterToTab() {    
	if(window.event)    
		if(event.keyCode == 13) event.keyCode = 9; 
}
function autotab(x, next) {
	var a = document.getElementById(x);
	var b = document.getElementById(next);
	
	if (a.value.length==a.maxLength){
		b.focus();
	}
}
function setFocus(x) {
	var a = document.getElementById(x);
	
	a.select();
	a.focus();
}
function strChkNull(x){
	var a = document.getElementById(x);

	if(a.value.length == 0){
		alert("請填入年月");
		event.returnValue = false;
		a.select();
		a.focus();
	}
}

function DrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();
	image.src=ImgD.src;

	if(image.width>0 && image.height>0){
		if((image.width/image.height) >= (FitWidth/FitHeight)){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				tmpHeight = Math.round((image.height*FitWidth)/image.width);
				ImgD.height = tmpHeight;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		} else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function MM_goToURL() { //v3.0

	var i, args=MM_goToURL.arguments; 
	document.MM_returnValue = false;

	for (i=0; i<(args.length-1); i+=2) 
		eval(args[i]+".location='"+args[i+1]+"'");
}

function JM_cc(ob){

	var obj=MM_findObj(ob); 
	
	if (obj) { 
		obj.select();
		js=obj.createTextRange();
		js.execCommand("Copy");
	}
}
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;
}