window.dialogWidth="470px";

//设置图片控件的src属性。
function SetImageControl(imageControl,url)
{
	if(url==null)
	{
		url=event.srcElement.value;
	}
	
	var imgObj=document.getElementById(imageControl);
	if(imgObj==null)
	{
		return;
	}
	else
	{
		if(imgObj.tagName=="IMG")
		{
			imgObj.src=url;
		}
		else
		{
			alert("图片显示控件错误。");
		}
	}
}
//清空全部文本框控件内容
function ClearText(){
for(var i=0;i<document.all.length;i++)
	{
		var box=document.all[i];
		if(box.tagName=="INPUT"&&box.getAttribute("type")=="text")
		{
			box.value="";
		}
		if(box.nodeName=="textarea"){
		box.innerText="";
		
		
		}
	}
	return false;
}

//--------------------------------------------------数字判断
function isNum(s)
{

var re=/^-?(\d+)\.?(\d*)$/g;
if(!re.test(s)){
return false;
}
else
{
return true;
}
}

//--------------------------------------------------整数判断
function isInteger(s)
{

var re=/^(\d+)$/g;
if(!re.test(s)){
return false;
}
else
{
return true;
}
}


//---------------------------------------------------字符是否在S中
function isCharsInBag (s, bag)
{ 
var i;
// Search through string's characters one by one.
// If character is in bag, append to returnString.

for (i = 0; i < s.length; i++)
{ 
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) return false;
}
return true;
}

function isEmpty(s)
{ 
return ((s == null)||(s.length == 0)); 
}

//---------------------------------------------隐藏控件
function hiddenControl(srcCon){

var aa=document.getElementById(srcCon)
if(aa!=null){

		aa.style.visibility="hidden";
		aa.style.display="none";
	}
}
//________________________________显示控件
function showControl(srcCon){
var aa=document.getElementById(srcCon)
if(aa!=null){
		//aa.style.display='block';
		aa.style.display='inline';
		aa.style.visibility="visible";

	}
	return true;
}
//----------------------------------------显示层对话框
function showDialogLayer(showContent,left,top){

var showText=document.getElementById("showText");
showText.innerText=showContent;
var showFrame=document.getElementById("DialogLayer");
showFrame.style.left=left;
showFrame.style.top=top;
showFrame.style.visibility="visible";
//showFrame.style.left = getposOffset(sendToFriendButton, "left") - (showFrame.offsetWidth / 2) + (sendToFriendButton.offsetWidth / 2);
 //-   15     showFrame.style.top = getposOffset(sendToFriendButton, "top") + sendToFriendButton.offsetHeight;

}
//----------------------------------------------------
function moveto(){

var aa=document.getElementById('DialogLayer');
aa.style.left+=event.offsetX;
aa.style.top+=event.offsetY;

}
///------------------------检查页面中全部的TextBox控件的值全为数字
function CheckTextBoxValue()
{
	document.all.lbResultInfo.innerHTML="&nbsp;";
	var allNull=true;
	for(var i=0;i<document.all.length;i++)
	{
		var box=document.all[i];
		if(box.tagName=="INPUT"&&box.getAttribute("type")=="text")
		{
			if(box.value!="")
			{	
				allNull=false;
				if(!isNum(box.value))
				{
					document.all.lbResultInfo.innerHTML+="所有项必须为数字或空";
					window.navigate("#tip");
					//showDialogLayer('所有项必须为数字或空',150,100);
					window.navigate("#tip");
					return false;
				}
			}
		}
	}
	if(allNull==true){
		//document.all.lbResultInfo.innerHTML+="所有项均为空,无数据输入!!";
		window.navigate("#tip");
		showDialogLayer('所有项均为空,无数据输入!!',150,100);
		
		return false;
	
	}
	return true;

}
//-----------------使文本框的值只能为数字
function onlyInt(){

if(window.event.keyCode<48||window.event.keyCode>57)
{

window.event.keyCode=0;
}
}
//-----------------------------使文本框的值只能为数字或小数点
function onlyFloat(){

if((window.event.keyCode<48||window.event.keyCode>57))
{
if(window.event.keyCode==46||window.event.keyCode==45){

return;
}
window.event.keyCode=0;
}
}
//---------------------检查所有的文本框均不为空
function NotNullAllTextBox()
{

	
	for(var i=0;i<document.all.length;i++)
	{
		var box=document.all[i];
		if(box.tagName=="INPUT"&&box.getAttribute("type")=="text")
		{
			if(box.value==null||box.value=="")
			{	
				
					document.all.lbResultInfo.innerHTML+="所有项必须填写，没有内容填写0！";
					window.navigate("#tip");
					//showDialogLayer('所有项必须为数字或空',150,100);
					//window.navigate("#tip");
					return false;
				
			}
		}
	}
	return true;
	
	

}var moveobj;function Moveonmousedown(id){				var moveobj=document.getElementById(id);		moveobj.setCapture();		}function Moveonmousemove(){		//alert("a");		//var panel=document.getElementById(id);		//alert("b");		//panel.style.position="absolute";		//panel.style.left+=window.event.clientX;		//alert("c");		//panel.style.top+=window.event.clientY;		//var aaa=event.clientX;				if(moveobj!=null){				moveobj.style.top+=event.offsetY;		moveobj.style.left+=event.offsetX;		}		}		function Moveonmouseup(id){     if(moveobj!=null){	moveobj.releaseCapture();	moveobj=null;	}	} 
function initSelect(src,value){
	var select=document.getElementById(src);
	select.options.length=0;
	for(var i in value)
	{
	var oOption = document.createElement("OPTION");
		select.options.add(oOption);
		oOption.innerText = value[i][0];
		oOption.innerValue=value[i][1];
	}
}
//跟隋鼠标的文字
function ShowTextWithMouse(text){
		
		var x=event.x;
		var y=event.y;
		//document.write("<Div id='MouseText' name='MouseText' style='position:absolute' ></Div>");
		
		var divtext=document.getElementById('MouseText');
		if(divtext==null)			
			{
				
				alert("为空");
				return ;
			}
		divtext.innerHTML="<font size='10000' color='green' ><b>"+text+"<b></font>";
		divtext.style.top=y-20;
		//alert(y);
		//alert(x);
		divtext.style.left=x+20;
		
		}
//防止保存按钮的多次提交。
function SingleSubmit(){
if(typeof(Page_ClientValidate) == 'function')
{
if(!Page_ClientValidate())
{return false;}
}
this.visibility='hidden';
this.style.display='none';
return true;
}

//使鼠标变忙的状态

function MouseBusy(id)
{
var mouse=document.getElementById(id);
		 mouse.style.cursor="wait";
}

//使鼠标不忙的状态

function MouseBusy(id)
{
var mouse=document.getElementById(id);
		 mouse.style.cursor="default";
}

//判断上传文件的类型
//extArray传值为new Array(".gif",".jpg"," .png",".bmp");
//fileCnt为this
function LimitAttach(fileCnt,extArray) {
var allowSubmit = false;
var file=fileCnt.value;

if(file==null||file.length<=0) return;
while(file.indexOf("\\")!=-1)
file = file.slice(file.indexOf("\\")+1);
var ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++)
{
	if (extArray[i]==ext) 
		{ allowSubmit = true; break; }
}
if (allowSubmit)
{
return true;
}
else
{
alert("对不起，只能上传以下格式的文件:  "+extArray.join()+"\n请重新选择的文件");
fileCnt.focus();
fileCnt.select();
fileCnt.value="";
fileCnt.outerHTML=fileCnt.outerHTML;
//document.execCommand('Delete');
		return false;
	}
}


