﻿function openWin(url,width,height,name){
	if(width==null)width=window.screen.width;
	if(height==null)height=window.screen.height;
	if(name==null||name=="")name= new Date().getTime();
	var left=(window.screen.width-width)/2;
	var top=(window.screen.height-height)/2;
	var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,scrollbars,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
 	return window.open(url,name,windowFeatures);
} 

function selectAllck(obj,checkName){
	var isChecked = obj.checked; 
	frm = obj.form;
	len = frm.elements.length;
    for ( idx=0 ; idx<len ; idx++ ) {
      ele = frm.elements[idx]; 
      if ((ele.name == checkName) && ele.type == "checkbox" && ele.style.display != "none" ){
    	  ele.checked= isChecked;
      }
    }
}


function   inputIsInt(obj){  
    if(!/^[+|-]?\d+$/.test(obj.value)&&obj.value!=''){  
        alert('please enter a numberic!');  
        obj.value="";
        obj.select();  
    }  
} 

String.prototype.trim=function(){
   return this.replace(/(^(\s|\u3000)*)|((\s|\u3000)*$)/g, '');
}

//判斷是否是整數(正整數or負整數)
function isIntNum(intStr, maxLength, require){ 
	if (!require && intStr.trim() == "") {
		return true;
	}	
	regex = "^-?[0-9]";
	if (maxLength){
		if(require){
			regex += ("{1," + maxLength + "}");
		}else{
			regex += ("{0," + maxLength + "}");
		}
	}else{
		regex += "*";
	}
	 
	regex += "$"; 
	var reg = new RegExp(regex);
  	return reg.test(intStr);
}
