
// JavaScript Document
//*******************
// 表单检测 
//*******************
//判断提交是否为空

function notEmpty(inputID,inputName){
	if(document.getElementById(inputID).value==""){
		alert(inputName+'不能为空！');
		return false;
	}else{
		return true;
	}
}
//提交只能输入数字
function checkNumber(obj){
	 if(event.keyCode == 13)
	  return true;
	 if(event.keyCode <48 || event.keyCode >57)
	  return false;
	 else
	  return true;
}
// input 输入 值长度
function inputLong(inputID,inputName,strLong){
	if(document.getElementById(inputID).value.length>strLong){
		alert(inputName+'限制长度为'+strLong+',请检查后重新输入！');
		return false;
	}else{
		return true;
	}
}

/***************************
	checkbox 多选框处理
	适用于 IDList Select 的表格
****************************/
//全选
function checkAll(str){
	a=document.getElementsByName(str)
	for (var i=0;i<a.length;i++) {
		var temp=a[i];
		temp.checked=true;
	}
}
//取消 选择
function checkNot(str){
	a=document.getElementsByName(str)
	for (var i=0;i<a.length;i++) {
		var temp=a[i];
		temp.checked=false;
	}
}
//反选
function checkElse(str){
	a=document.getElementsByName(str)
	for (var i=0;i<a.length;i++) {
		var temp=a[i];
		temp.checked=!temp.checked;
	}
}
//根据选择获取List值
function getListValue(str) { 
		var strchoice="";
		a=document.getElementsByName(str) 
		for(var i=0;i<a.length;i++) 
		{ 
			if (a[i].checked) 
			{ 
				strchoice=strchoice+a[i].value+","; 
			} 
		} 
		if (!a.length) 
		{ 
			if (a.checked) 
			{ 
				strchoice=a.value+","; 
			} 
		} 
		strchoice=strchoice.substring(0,strchoice.length-1); 
		//alert(strchoice);
		//document.form1.IDList.value=strchoice; 
		//alert(document.form1.ID.value=strchoice); 
		return strchoice;
}

function getAllCheckbox(){
	var str='';
	var inputs=document.getElementsByTagName("INPUT"); 
	for (var i=0;i<inputs.length;i++){
		inp=inputs[i];
		if(inp.type=="checkbox"){
			if(inp.checked==true){
				if(str!='')str+=",";
				str+=inp.name+':'+inp.value;
			}
		}
	}
	return str;
}
//判断 是否有选中
function checkCheckbox(str){
	a=document.getElementsByName(str)
	c=false;
	for (var i=0;i<a.length;i++) {
		if (a[i].checked){
			c=true;
		}
	}
	return c;
}

/*****************

******************/
// 选择跳转
function selectPageTo(selObj,page){
	eval("location='"+page+selObj.options[selObj.selectedIndex].value+"'");
}

// 页面加载完毕后执行
function addLoadEvent(func){
	var oldonload=window.onload;
	if (typeof window.onload != 'function'){
		window.onload =func;
	}else{
		window.onload=function(){
			if(oldonload){
				oldonload();
			}
			func();
		}
	}
}

//获取当前页的页面名称 不含后缀
function getThisPageName(){
	var fname=window.location.href.match(/.+\/([^?]*)/)[1];
	return fname.substring(0,fname.indexOf("."));
}
//适用于 语种切换 返回 "_"之前的字母
function getThisPageName_(){
	var fname=window.location.href.match(/.+\/([^?]*)/)[1];
	return fname.substring(0,fname.indexOf("_"));
}

//获取单个参数的值
function getOneParameter(){
	var str=document.location.href; 
	if (str.indexOf("=")>0){
		return str.substring(str.indexOf("=")+1);
	}else{
		return "";
	}
}