//得到页面控件的值
function GetCtrlValue(obj,type)
{
	if(type == "select")
	{
		return obj.options[obj.selectedIndex].value;
	}
	else if(type == "radio")
	{
		if(obj.length > 1)
		{
			for(var i = 0 ; i < obj.length ; i++)
			{
				if(obj[i].checked)
				{
					return obj[i].value;
				}
			}
		}
		else
		{
			return obj.value;
		}
	}
}
//得到页面控件的文字
function GetCtrlText(arrObj,arrayList,index)
{
	if(arrObj == null || arrObj == "")
		return "";
	else
	{
		var str = "";
		for(var i=0;i<arrayList.length;i++)
		{
			var flag = true;
			for(var k = 0 ; k < arrObj.length ; k++)
			{
				if(arrObj[k].replace(" ","") != arrayList[i][k].replace(" ",""))
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				if(index == null || index == "")
					str = arrayList[i][k];
				else
					str = arrayList[i][index];
			}
		}
		return str;
	}
}
//给select控件赋值
function SetSelectCtrlValue(selectName,ArrayList)
{
	selectName.options.length = 0;
	//添加 请选择
	var oOption = document.createElement("OPTION");
	selectName.options.add(oOption);
	oOption.value = "";
	oOption.innerText = "请选择";

	//添加 正式条目
	
	for(var i=0;i<ArrayList.length;i++)
	{
		var oOption = document.createElement("OPTION");
		selectName.options.add(oOption);
		oOption.value = ArrayList[i][0];
		oOption.innerText = ArrayList[i][1];
	}
	//如果只有二个选项（其中一个是"请选择"），那么就让第二个选项为默认，不用用户选了
//	if(selectName.options.length == 2)
//	{
//		selectName.options[1].selected = true;
//	}
}
//给Radio控件赋值
function SetRadioCtrlValue(RadioName,ArrayList)
{
	if(RadioName.length > 1)
	{
		for(var i = 0 ; i < RadioName.length ; i++)
		{
			RadioName[i].disabled = true;
			for(var j = 0 ; j < ArrayList.length ; j++)
			{
				if(ArrayList[j][0] == RadioName[i].value)
				{
					RadioName[i].disabled = false;
				}
			}
		}
		//是第一个不为灰的radio是选中的
		for(var i = 0 ; i < RadioName.length ; i++)
		{
			if(!RadioName[i].isDisabled)
			{
				RadioName[i].checked = true;
				break;
			}
		}
	}
	else
	{
		RadioName.checked = true;
	}
}
//设置页面控件的赋值
function SetCtrlValue(obj,type,arraylist)
{
	if(type == "select")
	{
		SetSelectCtrlValue(obj,arraylist);
	}
	else if(type == "radio")
	{
		SetRadioCtrlValue(obj,arraylist);
	}
}
//控件改变事件
function CtrlChange(arrObj,ctrlName,type,arrayList)
{
	var arrayListTemp = new Array();
	var j = 0;
	for(var i=0;i<arrayList.length;i++)
	{
		var flag = true;
		for(var k = 0 ; k < arrObj.length ; k++)
		{
			if(arrObj[k].replace(" ","") != arrayList[i][k].replace(" ",""))
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			arrayListTemp[j] = new Array(arrayList[i][k],arrayList[i][k + 1]);
			j++;
		}
	}
	SetCtrlValue(ctrlName,type,arrayListTemp);
}

function SetValue(selectName,selectList,selectValue)
{
	selectName.options.length = 0;
	//添加 请选择
	var oOption = document.createElement("OPTION");
	selectName.options.add(oOption);
	oOption.value = "";
	oOption.innerText = "请选择";

	//添加 正式条目
	for(var i=0;i<selectList.length;i++)
	{
		var oOption = document.createElement("OPTION");
		selectName.options.add(oOption);
		oOption.value = selectList[i][0];
		oOption.innerText = selectList[i][1];
		if(selectList[i][0].replace(" ","") == selectValue)
		{
			oOption.selected = true;
		}		
	}
//	if(selectName.options.length == 2)
//	{
//		selectName.options[1].selected = true;
//	}
}
function Select_Change(selectName1,selectName,selectList,selectValue)
{
	
	var selectListTemp = new Array();
	var j = 0;

	for(var i=0;i<selectList.length;i++)
	{
		if(selectName1.value.replace(" ","")==selectList[i][0].replace(" ",""))
		{
			selectListTemp[j] = new Array(selectList[i][1],selectList[i][2]);
			j++;
		}
	}
	SetValue(selectName,selectListTemp,selectValue);
}
function Select_ChangeByTwoColumn(selectName1,selectName2,selectName,selectList,selectValue)
{
	var selectListTemp = new Array();
	var j = 0;
	for(var i=0;i<selectList.length;i++)
	{
		if(selectName1.value.replace(" ","")==selectList[i][0].replace(" ","") && selectName2.value.replace(" ","")==selectList[i][1].replace(" ",""))
		{
			selectListTemp[j] = new Array(selectList[i][2],selectList[i][3]);
			j++;
		}
	}
	SetValue(selectName,selectListTemp,selectValue);
}
function Select_ChangeByThreeColumn(selectName1,selectName2,selectName3,selectName,selectList,selectValue)
{
	var selectListTemp = new Array();
	var j = 0;
	for(var i=0;i<selectList.length;i++)
	{
		if(selectName1.value.replace(" ","")==selectList[i][0].replace(" ","") && selectName2.value.replace(" ","")==selectList[i][1].replace(" ","") && selectName3.value.replace(" ","")==selectList[i][2].replace(" ",""))
		{
			selectListTemp[j] = new Array(selectList[i][3],selectList[i][4]);
			j++;
		}
	}
	SetValue(selectName,selectListTemp,selectValue);
}

function OpenPopWin(url,name,width,height)
{
	window.open(url,name,"width=" + width + ",height=" + height + ",scrollbar=yes");
}
//点击图片，执行linkbutton事件，实现使按钮变灰功能
function MakeButtonGray(button,grayImageName,LinkButtonName)
{
	if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate())
	{
		button.disabled=true;
		button.src = grayImageName;
		__doPostBack(LinkButtonName,''); 
	}
}

function popchange(path)
{		window.open(path,"","top=2000,left=2000,height=1,width=1,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
}
function popwin(path)
{		
	//popFull(path);
	window.open(path,"","top=10,left=100,height=450,width=580,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no");
}
function popDS(path)
{		
	//popFull(path);
	window.open(path,"","top=10,left=100,height=600,width=800,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function popwin2(path)
{		
	//popFull(path);
	window.open(path,"","top=10,left=100,height=400,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no");
}
function popSmall(path)
{	
	//popFull(path);
	window.open(path,"","top=10,left=150,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=500,width=580");
}
function popDel(path)
{		window.open(path,"","top=100,left=200,height=230,width=400,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function popBuyCard(path)
{		window.open(path,"","top=100,left=300,height=260,width=525,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
}
function popScroll(path)
{		window.open(path,"","top=100,left=300,height=260,width=525,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function popReport(path)
{		window.open(path,"","top=10,left=100,height=550,width=750,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function popMax(path)
{		window.open(path,"","top=10,left=100,height=600,width=800,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function pops(path)
{		window.open(path,"","top=200,left=200,height=150,width=500,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
}
function popPreview(path)		
{
	window.open(path,"","top=<%=10+((rnd()*1000) mod 20)%>,left=<%=50+((rnd()*1000) mod 50)%>,height=600,width=800,resizable=no,scrollbars=yes,status=no,toolbar=yes,menubar=no,location=no");
}
function pops1(path)
{		window.open(path,"","top=200,left=200,height=350,width=700,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function ongotopage(linkfile)
{	
		window.location.href=linkfile+window.gotopagenoid.value;
}	
function getdate()
{                          
	today=new Date();                      
	function initArray(){                      
	this.length=initArray.arguments.length                      
	for(var i=0;i<this.length;i++)                      
	this[i+1]=initArray.arguments[i]  }                      
	var d=new initArray(                      
	"星期日",                      
	"星期一",                      
	"星期二",                      
	"星期三",                      
	"星期四",                      
	"星期五",                      
	"星期六");                      
	document.write(                    
	"<font color=#666666 style='font-size:9pt;font-family: 宋体'> ",                      
	today.getYear(),"年",                      
	today.getMonth()+1,"月",                      
	today.getDate(),"日",                      
	d[today.getDay()+1],                      
	"</font>");                
}


