
function changeToBigAmount(num){  //转成人民币大写金额形式
  var str1 = '零壹贰叁肆伍陆柒捌玖';  //0-9所对应的汉字
  var str2 = '万仟佰拾亿仟佰拾万仟佰拾元角分'; //数字位所对应的汉字
  var str3;    //从原num值中取出的值
  var str4;    //数字的字符串形式
  var str5 = '';  //人民币大写金额形式
  var i;    //循环变量
  var j;    //num的值乘以100的字符串长度
  var ch1;    //数字的汉语读法
  var ch2;    //数字位的汉字读法
  var nzero = 0;  //用来计算连续的零值是几个
  
  num = Math.abs(num).toFixed(2);  //将num取绝对值并四舍五入取2位小数
  str4 = (num * 100).toFixed(0).toString();  //将num乘100并转换成字符串形式
  j = str4.length;      //找出最高位
  if (j > 15){return '溢出';}
  str2 = str2.substr(15-j);    //取出对应位数的str2的值。如：200.55,j为5所以str2=佰拾元角分
  
  //循环取出每一位需要转换的值
  for(i=0;i<j;i++){
    str3 = str4.substr(i,1);   //取出需转换的某一位的值
    if (i != (j-3) && i != (j-7) && i != (j-11) && i != (j-15)){    //当所取位数不为元、万、亿、万亿上的数字时
   if (str3 == '0'){
     ch1 = '';
     ch2 = '';
  nzero = nzero + 1;
   }
   else{
     if(str3 != '0' && nzero != 0){
       ch1 = '零' + str1.substr(str3*1,1);
          ch2 = str2.substr(i,1);
          nzero = 0;
  }
  else{
    ch1 = str1.substr(str3*1,1);
          ch2 = str2.substr(i,1);
          nzero = 0;
        }
   }
 }
 else{ //该位是万亿，亿，万，元位等关键位
      if (str3 != '0' && nzero != 0){
        ch1 = "零" + str1.substr(str3*1,1);
        ch2 = str2.substr(i,1);
        nzero = 0;
      }
      else{
     if (str3 != '0' && nzero == 0){
          ch1 = str1.substr(str3*1,1);
          ch2 = str2.substr(i,1);
          nzero = 0;
  }
        else{
    if (str3 == '0' && nzero >= 3){
            ch1 = '';
            ch2 = '';
            nzero = nzero + 1;
       }
       else{
      if (j >= 11){
              ch1 = '';
              nzero = nzero + 1;
   }
   else{
     ch1 = '';
     ch2 = str2.substr(i,1);
     nzero = nzero + 1;
   }
          }
  }
   }
 }
    if (i == (j-11) || i == (j-3)){  //如果该位是亿位或元位，则必须写上
        ch2 = str2.substr(i,1);
    }
    str5 = str5 + ch1 + ch2;
    
    if (i == j-1 && str3 == '0' ){   //最后一位（分）为0时，加上“整”
      str5 = str5 + '整';
    }
  }
  if (num == 0){
    str5 = '零元整';
  }
  return str5;
}

/*
 * select checkbox function
 */
var checkFlag = 0;
function selectAll(checkboxName) {
	var checkboxArray = document.getElementsByName(checkboxName);
	var length = checkboxArray.length;
	var checkboxStatus = false;
	if (checkFlag == 0) {
		checkFlag = 1;
		checkboxStatus = true;
	} else {
		checkFlag = 0;
		checkboxStatus = false;
	}
	for ( var i = 0; i < length; i++) {
		checkboxArray[i].checked = checkboxStatus;
	}
}

function getCheckBoxValue(para) {
	var checkboxObj;
    if (typeof(para) == 'string'){
    	checkboxObj = $(para);
    }else if (typeof(para) == "object"){
    	checkboxObj = para;
    }
	return checkboxObj.value;
}

function getCheckBoxStatus(para) {
	//alert("typeof(para)=" + typeof(para));
	var checkboxObj;
    if (typeof(para) == 'string'){
    	checkboxObj = $(para);
    }else if (typeof(para) == "object"){
    	checkboxObj = para;
    }
	//var checkboxStatus = false;
	return checkboxObj.checked;
}

function clearFormData(theFormName) {
	var theForm = document.getElementById(theFormName);
	for ( var i = 0; i < theForm.elements.length; i++) {
		if (theForm.elements[i].type == "submit"
				|| theForm.elements[i].type == "reset"
				|| theForm.elements[i].type == "button"
				|| theForm.elements[i].type == "checkbox"
				|| theForm.elements[i].name == "query") {
		} else if (theForm.elements[i].type == "select-one") {
			theForm.elements[i].value = "-1";
		} else {
			theForm.elements[i].value = "";
		}
	}
}

function closeWindow() {
	window.open('','_parent','');
	window.close();    
}  

function comfirmDelete() {
	if (confirm("确定要删除此记录吗？")) {
		return true;
	} else {
		return false;
	}
}

function CheckAllDel() {
	if (confirm("确定要删除您所选择的记录吗？")) {
		return true;
	} else {
		return false;
	}
}

function autoSetImgSize(originalImages) {
	var maxWidth = 500;
	var maxHeight = 600;
	var imageArray = document.getElementsByName(originalImages);
	for ( var i = 0; i < imageArray.length; i++) {
		var img = imageArray[i];
		if (img.readyState != "complete") {
			//return false;
		} else {
			setImgSize(img, maxWidth, maxHeight);
		}
	}
}

function setImgSize(img, maxWidth, maxHeight) {
	var message = "";
	if (img.offsetHeight > maxHeight)
		message += "\r height:" + img.offsetHeight;
	if (img.offsetWidth > maxWidth)
		message += "\r width:" + img.offsetWidth;
	if (message != "")
		//alert(message);

	var heightWidth = img.offsetHeight / img.offsetWidth;
	var widthHeight = img.offsetWidth / img.offsetHeight;
	if (img.offsetWidth > maxWidth) {
		img.width = maxWidth;
		img.height = maxWidth * heightWidth;
	}
	if (img.offsetHeight > maxHeight) {
		img.height = maxHeight;
		img.width = maxHeight * widthHeight;
	}
}

/**	把页面变灰，同时弹出小窗口的效果js实现	*/
function alertWin(title, msgBoxInnerHTML, w, h){ 
	var titleheight = "22px"; 		//提示窗口标题高度
	var bordercolor = "#00205b"; 	//提示窗口的边框颜色
	var titlecolor = "#FFFFFF"; 	//提示窗口的标题颜色
	var titlebgcolor = "#00205b"; 	//提示窗口的标题背景色
	var bgcolor = "#FFFFFF"; 		//提示内容的背景色
	
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight; 
	var bgObj = document.createElement("div"); 
	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
	document.body.appendChild(bgObj); 
	
	var msgObj=document.createElement("div");
	msgObj.style.cssText = "position:absolute;font:11px '??';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	document.body.appendChild(msgObj);
	
	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;
	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "width:100%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:12px '??';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
	titleBar.style.padding = "5px 0 0 35px";
	titleBar.style.background = "#00205b url(/images/title_logo.jpg) no-repeat 5px 0";
	titleBar.innerHTML =  title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer; height:24px; line-height:24px; padding:2px;background-color:" + titlebgcolor;
	closeBtn.innerHTML = "<span style='font-size:11pt; font-weight:bold; margin-right:5px; color:"+titlecolor+";'><img src='/images/base/close_bg.gif' alt='关闭' /></span>";
	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	} 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt '??';";
	msgBox.colSpan  = 2;
	msgBox.innerHTML = msgBoxInnerHTML;
	var nexttime = document.getElementsByName("nexttime");
	for (var i = 0; i < nexttime.length; i++) {
		var item = nexttime[i];
		item.onclick = function(){ 
			document.body.removeChild(bgObj); 
			document.body.removeChild(msgObj); 
		} 
	}
	
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
} 

/**	获得一个对象，即调用document.getElementById()方法	*/
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string'){
    	element = document.getElementById(element);
      	//alert("element=" + element);
    }

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }
  return elements;
}
/**	显示一个对象，即把该对象的display属性设置为block	*/
function s(s){
	if (!$(s)) return;
	$(s).style.display = "block";
}
/**	隐藏一个对象，即把该对象的display属性设置为none	*/
function h(s){
	if (!$(s)) return;
	$(s).style.display = "none";
}