﻿// JScript 文件

function GetAjaxValue(webURL)
{
　　var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
　　var oDoc = new ActiveXObject("MSXML2.DOMDocument");
　　xmlHttp.open("POST", webURL, false);
　　xmlHttp.send("");
　　var result = xmlHttp.responseText;　
　　oDoc.loadXML(result);
　　return result;
}

function GetAjaxXML(webURL)
{
　　var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
　　var oDoc = new ActiveXObject("MSXML2.DOMDocument");
　　xmlHttp.open("POST", webURL, false);
　　xmlHttp.send("");
　　var result = xmlHttp.responseText;　
　　oDoc.loadXML(result);
　　return oDoc;
}

//类说明:去除字符串空格
//创建人:杨学俊
//创建日期:07-1-29
String.prototype.trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

function IsEmail(Email)
{
	var patrn=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if (!patrn.exec(Email)) return false
	return true
}

function KeyPressFloat()
{
	if (event.keyCode >=45 && event.keyCode <= 57 && event.keyCode!=47)
		event.returnValue = true;
	else
		event.returnValue = false;	
}

function ShowDialogWithTitle(url,object,width,height)
{
    var style	= "dialogWidth:" + width + "px;dialogHeight:" + height + "px;resizable:no;status:no;scroll:no;help:no;unadorned:yes;";
	var strurl = url;
	window.showModalDialog(strurl, object, style);	
}

function GetServerSelected(strname)
{
	var idList = new String();
	var checkboxes = document.getElementsByTagName("input");
	for(var nPos = 0, checkbox = null; checkbox = checkboxes[nPos]; nPos++)
	{
		if(checkbox.type == "checkbox" && checkbox.checked == true  && checkbox.id.toLowerCase().indexOf(strname.toLowerCase()) > -1)
		{
			idList += checkbox.value+ ",";
		}
	}
	
	if(idList.length > 0)
	{
		idList = idList.substring(0, idList.length - 1);
	}

	return idList;
}

function SelectCheckBox(obj,strname)
{
	try
	{
		var chkboxs=document.all.tags("INPUT");   
		for(var i=0;i<chkboxs.length;i++)
		{
			if(chkboxs[i].type=="checkbox")		    	
			{
				if(chkboxs[i].id.toLowerCase().indexOf(strname.toLowerCase()) > -1)
		    		chkboxs[i].checked=obj.checked;
			}
		}
	}
	catch(e)
	{
	}
}

function GetCheckedValueByCells(gridName, cellsIndex)
{
	if (document.getElementById(gridName).rows.length == 1)
		return "";
	var returnValue = "";
	
	for (var i = 1; i < document.getElementById(gridName).rows.length; i++)
	{
		if (document.getElementById(gridName).rows[i].cells[0].childNodes[0].checked)
		{
			returnValue += document.getElementById(gridName).rows[i].cells[cellsIndex].innerHTML + ",";
		}
	}
	
	if(returnValue.length > 0)
	{
		returnValue = returnValue.substring(0, returnValue.length - 1);
	}
		
	return returnValue;
}