﻿
//(部分函数依赖于 base.string)


//=============================================================================================
//	********************* 功能函数 ************************************************************
//=============================================================================================
///设置首页<a style="behavior:url(#default#homepage)" href="JavaScript:sh.sethomepage(location.href)" id="sh">设为首页</a>
///添加收藏夹<a href="#" onclick=window.external.AddFavorite("Http://www.Sina.com.cn",document.title)>


//=============================================================================================
//	比较两个时间，传入的是xxxx-xx-xx  
//  add by zzj 08.8.21      比较是否相同
//=============================================================================================
function CompareDate(dtstart,dtend,flag)
{
		var arys= new Array();   
		    
		if(dtstart != null && dtend != null)
        {   
		    if ( flag == "0")
		    {
		        if(dtstart == dtend)
	            {   
    		        return true;
    	        }
    	        else
    	        {
    	            return false;
    	        }
		    }
		    else
		    {
		        arys=dtstart.split('-');   
		        var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);    
		        arys=dtend.split('-');   
		        var checkEndDate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);  		    
		        if(startdate > checkEndDate)
	            {   
    		        return false;
    	        }
    	        else
    	        {
    	            return true;
    	        }
		    }
    	}
}


//=============================================================================================
//	格式化时间，显示的是 xxxx-xx-xx  
//  add by zzj 08.8.21
//=============================================================================================
Date.prototype.format = function(format)   
{   
   var o = {   
     "M+" : this.getMonth()+1,  
     "d+" : this.getDate(),    
     "h+" : this.getHours(),   
     "m+" : this.getMinutes(), 
     "s+" : this.getSeconds(), 
     "q+" : Math.floor((this.getMonth()+3)/3), 
     "S" : this.getMilliseconds() 
   }   
   if(/(y+)/.test(format))
     format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));   
   for(var k in o)
     if(new RegExp("("+ k +")").test(format))   
        format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length));   
   return format;   
} 


//=============================================================================================
//	取格式化日期字符串(sTsep:分隔符, 例如sTsep="-",返回 "2005-05-05")
//=============================================================================================
function getFormatDateString(oDate, sTsep)
{
	var sDate = oDate.getYear().toString();
		sDate += sTsep + (oDate.getMonth()+1).toString().padLeft(2 ,'0');
		sDate += sTsep + oDate.getDate().toString().padLeft(2 ,'0');
	return sDate;
}

//=============================================================================================
//	取格式化时间字符串

//=============================================================================================
function getFormatTimeString(oDate, sTsep)
{
	var sTime = oDate.getHours().toString();
		sTime += sTsep + oDate.getMinutes().toString().padLeft(2, '0');
		sTime += sTsep + oDate.getSeconds().toString().padLeft(2, '0');
	return sTime;
}

//=============================================================================================
//	返回中文格式的星期

//=============================================================================================
function getWeekDay()
{
	return ('星期'+'日一二三四五六'.charAt(new Date().getDay()));
}

//=============================================================================================
//	随机定长数字代码串(<16位)
//=============================================================================================
function getRndNumCode(iLen)
{
	var s = Math.random().toString();
	return s.substr(2,iLen);
}

function g_OpenWindow(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=no, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no')
}

function g_OpenWindowNo(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ',location=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,resizable=no')
}
//=============================================================================================
//	********************* 与DHTmL页面相关的功能函数 *******************************************
//=============================================================================================




//=============================================================================================
//	datalist(select)之间的移动,删除,追加选项等操作

//=============================================================================================

function dataList_AdjustRows(dataList, cmd)									//向上调整,向下调整,置顶,置底(支持多选项)
{
		if(dataList.options.length == 0){return;}
		
		cmd = cmd.toUpperCase();
		
		var temp ;
		
		if(cmd == "UP"){
		
			if(dataList.options[0].selected ){return;}
			
			temp = document.createElement("OPTION");
			
			for(var i=0; i<dataList.options.length; i++)
			{
				if(!dataList.options[i].selected){continue;}
				temp.text = dataList.options[i-1].text;
				temp.value = dataList.options[i-1].value;
				dataList.options[i-1].text = dataList.options[i].text;
				dataList.options[i-1].value = dataList.options[i].value;
				dataList.options[i].text = temp.text;
				dataList.options[i].value = temp.value;
				dataList.options[i].selected = false;
				dataList.options[i-1].selected = true;
			}
		}
		else if(cmd == "DOWN"){
		
			var lastIndex = dataList.options.length - 1;
			
			if(dataList.options[lastIndex].selected){return;}
						
			temp = document.createElement("OPTION");
			
			for(var i=lastIndex; i>=0; i--)
			{
				if(!dataList.options[i].selected){continue;}
				
				temp.text = dataList.options[i+1].text;
				temp.value = dataList.options[i+1].value;
				dataList.options[i+1].text = dataList.options[i].text;
				dataList.options[i+1].value = dataList.options[i].value;
				dataList.options[i].text = temp.text;
				dataList.options[i].value = temp.value;
				dataList.options[i].selected = false;
				dataList.options[i+1].selected = true;
			}
		}
		else if(cmd == "TOP"){
		
			if(dataList.options.length < 2){return;}
			
			var lastIndex = dataList.options.length - 1;
			var firstMovedNodeIndex = -1;
			
			for(var i=lastIndex; i>=0; i--){
			
				if(!dataList.options[i].selected){continue;}
				if(firstMovedNodeIndex == i){return;}
				
				temp = dataList.options[i];
				dataList.removeChild(temp);
				dataList.insertBefore(temp, dataList.options[0]);
				i++;
				firstMovedNodeIndex ++;
			}
			
		}
		else if(cmd == "BOTTOM"){
		
			if(dataList.options.length < 2){return;}
			
			var firstMovedNodeIndex = dataList.options.length;
			
			for(var i=0; i<dataList.options.length; i++){
			
				if(!dataList.options[i].selected){continue;}
				if(firstMovedNodeIndex == i){return;}
				
				temp = dataList.options[i];
				dataList.removeChild(temp);
				dataList.appendChild(temp);
				i--;
				firstMovedNodeIndex --;	
			}
		}
}

function dataList_DeleteRows(dataList)						//删除选项(支持多选项)
{	
	var iLen = dataList.options.length;
	for(var i=0;i< iLen ;i++)
	{
		var currOption = dataList.options[i];
		if(currOption.selected)
		{
			dataList.removeChild(currOption);
			iLen = dataList.options.length;
			i--;
		}
	}
}

function dataList_InsertRows(src, target)					//添加到另一个列表(支持多选项, 不重复)
{
	var isExist = false;
	
	for( var i=0; i< src.options.length ;i++ )
	{
		var currOption = src.options[i];
		if( currOption.selected )
		{
			for( var j=0; j<target.options.length; j++ )
			{
				var targetOption = target.options[j];
				if( targetOption.value.toLowerCase() == currOption.value.toLowerCase() 
					&& targetOption.text.toLowerCase() == currOption.text.toLowerCase() )
				{
					isExist = true;	
				}
			}
			if( !isExist )
			{
				var oOption = document.createElement("OPTION");
					oOption.text = currOption.text;
					oOption.value = currOption.value;
					target.options.add(oOption);
			}
			isExist = false;
		}
	}
}

function dataList_SelectAllRows(dataList)					//将列表的选项全选

{
	for(var i=0;i<dataList.options.length;i++)
	{
		dataList.options[i].selected = true;
	}
}

function dataList_DeleteAllRows(dataList)					//全部删除
{
	dataList.length = 0;
}


//=============================================================================================
//	列表常用的CheckBox函数
//=============================================================================================

//是否有选择一条以上的记录,返回是否有选择记录的布尔值, 有返回true, 否返回 false
function checkBoxIsChecked1(oForm, sName)
{
	//		oForm:		当前表单
	//		sName:		CheckBox的name,局限于某一部分的CheckBox,不至于影响到其他的CheckBox
	
	var items = oForm.elements;
    
	if(sName == null){
		for(var i=0; i<items.length; i++){
			if (items[i].type=="checkbox" && items[i].checked){
				return true;
			}
		}	
	}else{
		for(var i=0; i<items.length; i++){
			if (items[i].type=="checkbox" && items[i].name.toUpperCase() == sName.toUpperCase() && items[i].checked){
				return true;
			}
		}
	}

	return false;

}

//全选-取消函数,返回当前全选/取消状态的布尔值, 全选返回true, 未全选返回 false
function checkboxToggleCheck(oForm, bState, sName)
{
	//		oForm:		当前表单
	//		bState:		当前的选择状态(已全选true|未全先false)
	//		sName:		CheckBox的name  局限于某一部分的CheckBox,不至于影响到其他的CheckBox

	var items = oForm.elements;

	if(sName == null){
		for(var i=0; i<items.length; i++){
			if(items[i].type=="checkbox"){
				items[i].checked = !bState;
			}
		}
	}
	else{
		for(var i=0; i<items.length; i++){
			if(items[i].type=="checkbox" && items[i].name.toUpperCase() == sName.toUpperCase()){
				items[i].checked = !bState;
			}
		}	
	}

	return !bState;
}

//=============================================================================================
//	检测表单是否有空的输入框, 有空的输入框 返回true, 没有空的输入框 返回false
//=============================================================================================
function checkFormEmpty(oForm)
{
	var items = oForm.elements;

	for (i=0; i<items.length; i++){
		if((items[i].type=="text" || items[i].type=="password" || items[i].type=="textarea") && (items[i].value=="" || items[i].value.length==0))
		{
			return true;
		}
	}
	return false;
}

//=============================================================================================
//	URL参数获取,返回Object对象,采用object["参数"]引用Url参数值

//=============================================================================================
function getURLParams()
{
	var urlParams = new Object();
	var tempParams = window.location.search.substr(1).split("&");
	
	var param;
	var pos;
	
	for(i=0; i<tempParams.length; i++)
	{
		param	= tempParams[i];
		pos		= param.indexOf('=');

		if(pos == -1){
			urlParams[param] = null;
		}
		else{
			urlParams[param.substr(0, pos)] = param.substr(pos+1);
		}
	}
	return urlParams;
}

//=============================================================================================
//	得到元素位置及高宽绝对值, 返回一个对象

//=============================================================================================
function getElementSize(el)
{
	var size = {
		top: 0,
		left: 0,
		width: 0,	
		height: 0
	}

	while(el != null && el.tagName != "BODY")
	{
		size.top		+= el["offsetTop"];
		size.left		+= el["offsetLeft"];
		size.width		+= el["offsetWidth"];
		size.height		+= el["offsetHeight"];
		el = el.offsetParent;
	}

	return size;
}

//=============================================================================================
//	取窗体的高

//=============================================================================================
function getWindowHeight()
{
	if(window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.body.clientHeight;
	}
}
//=============================================================================================
//	取窗体的宽

//=============================================================================================
function getWindowWidth()
{
	var strWindowWidth;
	if(window.innerWidth)
	{
		strWindowWidth = window.innerWidth ;
		if(arguments.length == 0)
		{
			strWindowWidth = strWindowWidth - 15;
		}
	}
	else{
		strWindowWidth = document.body.clientWidth;
	}
	
	return strWindowWidth;
}

//=============================================================================================
//	提示信息并页面返回

//=============================================================================================
function showMessage( iMsgType, sMsgBody, sUrl, sMsgArg )
{
	switch( iMsgType )
	{
		case 1:
					if(sMsgBody)alert(sMsgBody);
					break;
		case 2:
					if(sMsgBody)alert(sMsgBody);
					if(!sMsgArg)sMsgArg = -1;
					history.back( sMsgArg );
					break;	
		case 3:	
					if(sMsgBody)alert(sMsgBody);
					if(sUrl)window.location.href = sUrl;
					if(sMsgArg)OpenWindow(1, sUrl, null, null, null, null, sMsgArg, null);
					break;
		case 4:
					if(sMsgBody)alert(sMsgBody);
					window.opener = null;
					window.close();
	}
}

//showMessage( 1, "OK", null, "http://www.sohu.com" )

//=============================================================================================
// Open窗体, 有三种模式

// 采用默认窗体坐标时,请将iLeft,iTop设置为: null 或 空字符, 
// winArg不设置时, 请将winArg设置为null 或 空字符,
// iMode: 打开窗体的模式

// iMode = 1 : window模式, winArg默认值为"_blank"(字符);
// iMode = 2 : modal模式, winArg默认值为window(对象);
// iMode = 3 : modeless模式, winArg默认值为window(对象);
//=============================================================================================
function OpenWindow( iMode, sUrl, iHeight, iWidth, iLeft, iTop, winArg, sFeatures )
{
	var defautFeatures1 = "status=yes,toolbar=no,menubar=no,location=no,resizable=no,titlebar=yes,scrollbars=false";
	//var defautFeatures1 = "status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,titlebar=yes,scrollbars=yes";
	var defautFeatures2 = "center:yes;status:no;resizable:no;help:no;scroll:no;";
	var defautFeatures3 = "center:yes;status:no;resizable:yes;help:no;scroll:no;";

	var newFeatures;
	var innerMode;

	
	if( !iMode ){ iMode = 2 };

	if( iMode == 1 )
	{
		if(!sFeatures)sFeatures = defautFeatures1;
		
		if(iLeft != null && iTop != null && iHeight != null && iWidth != null)
		{
			newFeatures = "height=" + iHeight + ",width=" + iWidth + ",left=" + iLeft + ",top=" + iTop + "," ;
		}
		else if(iTop != null && iTop != 0 && iHeight != null && iWidth != null)
		{
			newFeatures = "height=" + iHeight + ",width=" + iWidth + ",left=" + iLeft + "," ;
		}
		else if(iLeft != null && iLeft != 0 && iHeight != null && iWidth != null)
		{
			newFeatures = "height=" + iHeight + ",width=" + iWidth + ",top=" + iTop + "," ;	
		}
		else if(iHeight != null && iWidth != null)
		{
			newFeatures = "height=" + iHeight + ",width=" + iWidth + "," ;
		}
		
		if(!winArg)winArg = "_blank";
		
		newFeatures += sFeatures;
	}
	else if( iMode == 2 || iMode == 3 )
 	{
 		if(!sFeatures && iMode == 2)sFeatures = defautFeatures2;
		if(!sFeatures && iMode == 3)sFeatures = defautFeatures3;
		
		if(iLeft != null && iTop != null && iHeight != null && iWidth != null)
		{
			newFeatures	= "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;dialogLeft:" + iLeft + "px;dialogTop:" + iTop + "px;" ;
		}
		else if(iTop != null && iTop != 0 && iHeight != null && iWidth != null)
		{
			newFeatures	= "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;dialogLeft:" + iLeft + "px;" ;
		}
		else if(iLeft != null && iLeft != 0 && iHeight != null && iWidth != null)
		{
			newFeatures	= "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;dialogTop:" + iTop + "px;" ;
		}
		else if(iHeight != null && iWidth != null)
		{
			newFeatures	= "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;" ;
		}
		
		if(!winArg)winArg	= window;
		
		newFeatures += sFeatures;
	}
	
	innerMode = iMode;
	
	return innerOpenWindow(innerMode, sUrl, winArg, newFeatures);
}

function innerOpenWindow(innerMode, sUrl, winArg, sFeatures)
{
	switch( innerMode )
	{
		case 1:
			return window.open( sUrl, winArg, sFeatures );
			break;
		case 2:
			return window.showModalDialog( sUrl, winArg, sFeatures );
			break;
		case 3:
			return window.showModelessDialog( sUrl, winArg, sFeatures );
			break;
	}
}

//=============================================================================================
//	根据浏览器的不同获取对象的style
//=============================================================================================
function getStyleObject(objectId) {
  if(document.getElementById && document.getElementById(objectId)) 
  {
		// W3C DOM
		return document.getElementById(objectId).style;
  }
  else if (document.all && document.all(objectId)) 
  {
		// MSIE 4 DOM
		return document.all(objectId).style;
  }
  else if (document.layers && document.layers[objectId]) 
  {
		// NN 4 DOM
		return document.layers[objectId];
  } 
  else 
  {
		return false;
  }
}

//=============================================================================================
//	将HTML页面的样式加载到另一个HTML页面
//=============================================================================================
function addStyles(sourceDoc, targetDoc)
{
	for (var i = 0; i < sourceDoc.styleSheets.length; i++)
	{
		var href = sourceDoc.styleSheets[i].href;
		if (href)
		{
			targetDoc.write("<link rel='stylesheet' href='" + href + "'/>");
		}
	}
}

//=============================================================================================
//	浏览器是否支持AutoScroll
//=============================================================================================
function isSupportedAutoScroll()
{
	if (((navigator.appVersion.indexOf('MSIE 5') != -1) && (navigator.platform.indexOf('Mac') != -1)) || navigator.userAgent.indexOf('Netscape6') != -1 )
	{
		return false;
	}
	return true;
}

//=============================================================================================
//	 控制输入的字符是否为数字包括有小数点 zzj 08.9.16
//=============================================================================================
function isDigit()
{
    if ( event.keyCode == 46)
    {
        var isource = event.srcElement.value;
        if (isource.indexOf('.') >= 0 )
         {
            return false;
         }
    }
    else
    {
        return ((event.keyCode >= 48) && (event.keyCode <= 57));
    }
}

//=============================================================================================
//	 粘贴控制   zzj 08.9.16
//=============================================================================================
function limitPaste()
{
    var strsorcue = window.clipboardData.getData("Text");
    if ( strsorcue.isufloat())
    {
        window.event.returnValue=true;
    }
    else
    {
        window.event.returnValue=false;
    }
    
}



//=============================================================================================
//	显示或隐藏元素

//=============================================================================================
function showHideElement(el)
{			
	el.style.display = (el.style.display == "none") ? "block" : "none";	
}

//=============================================================================================
//	保存页面
//=============================================================================================
function savePage(title)
{
	document.execCommand("SaveAs", true, title);
}


//=============================================================================================
//		dd 增加原先选择的	06.2.20
//=============================================================================================

function CheckBoxDeleteCheck(oForm, sID)
{

	if( checkBoxIsChecked1(oForm, sID) )
	{
		if( confirm("确定要删除吗?") )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		alert("请选择要删除的项!");
		return false;
	}
}

//全选-取消函数,返回当前全选/取消状态的布尔值, 全选返回true, 未全选返回 false
function selectAllCheckbox(oForm, bState, sName)
{
	//		oForm:		当前表单
	//		bState:		当前的改变的状态(tru|false)
	//		sName:		CheckBox的name  局限于某一部分的CheckBox,不至于影响到其他的CheckBox
	
	var items = oForm.elements;

	for(var i=0; i<items.length; i++)
	{
		if(items[i].type=="checkbox" && items[i].name.toUpperCase()==sName.toUpperCase())
		{
			items[i].checked = bState;
		}
	}
	
	return bState;
	
}


//=============================================================================================
//	不根据名字判断是否有CHECKBOX选中		dd	06.8.31
//=============================================================================================

//是否有选择一条以上的记录,返回是否有选择记录的布尔值, 有返回true, 否返回 false
function checkBoxIsChecked(oForm)
{
	var items = oForm.elements;

	for(var i=0; i<items.length; i++)
	{
		if (items[i].type=="checkbox" && items[i].checked)
		{
			return true;
		}
	}
	
	return false;
}

//=============================================================================================
//	传入FORM 及名称,判断选中了几个 zcy  
//=============================================================================================
function CheckCount(Form, sName)
{
	var i;
	var editid;
	i=0;
	editid=0;
	
	var items = Form.elements;
	for (i = 0;i< items.length ; i++)
	{
	   if(items[i].type=="checkbox" && items[i].name==sName)
		{
			if (items [i].checked)
			{
			    editid = editid+1;
			    objYN = true;
			}
		}
	}
	return editid;
}

//=============================================================================================
//	获取页面名字为sName的check选中的值
//=============================================================================================
function SelectedValue(Form, sName)
{
	var i;
	var editid;
	i=0;
	editid = 0;
	
	var items = Form.elements;
	for (i = 0;i< items.length ; i++)
	{
	   if(items[i].type=="checkbox" && items[i].name==sName)
		{
			if (items [i].checked)
			{
			    editid = items[i].value;
			}
		}
	}
	return editid;
}


//=============================================================================================
//	是否为数字			zzj		07.11.30
//=============================================================================================
String.prototype.isNumber = function()
{
	var re = /^([0-9]+)$/ig;
	return re.test(this);
}


//=============================================================================================
//	是否为正数字			zzj		08.2.26  
//=============================================================================================
String.prototype.isUnsignedNumeric = function()
{	
	var re = /^\d+(\.\d+)?$/ig;
	return re.test(this);
}

//=============================================================================================
//	是否为正浮点数			zzj		08.3.28
//=============================================================================================
String.prototype.isUnsignDouble = function()
{	
	var re=/^\+?\d+(\.\d+)?$/;
	return re.test(this);
}

//=============================================================================================
//	是否为大于0的数字			zzj		08.2.26  
//=============================================================================================
String.prototype.isZero = function()
{
	var re = this * 1;
	if ( re == 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}
//=============================================================================================
//	是否为正负浮点的数字，包括0			zzj		08.4.30
//=============================================================================================
String.prototype.isufloat = function()
{
	var re =/^[-+]?\d+(\.\d+)?$/; 
	return re.test(this);
}


//=============================================================================================
//	是否为乘法表达式			zzj		08.7.3
//=============================================================================================
String.prototype.ismultiplication = function()
{
	var re = /^([0-9]+)+\*([0-9]+)$/ig;
	if (re.test(this))
	{
	    return true;
	}
	else
	{
	    re = /^([0-9]+)$/ig;
	    return re.test(this);
	}
}


//=============================================================================================
//	获得页面上的对象		zzj		08.7.4
//=============================================================================================
function $(s)
 {
     return document.getElementById(s);
 }

 function $1(s) {
     return document.getElementById(s);
 }    
  
//=============================================================================================
//	是否为空		zzj		08.7.4
//=============================================================================================     
function isNull(_sVal)
{
    return (_sVal == "" || _sVal == null || _sVal == "undefined");
}
//=============================================================================================
//	是否日期时间格式		zcy		08-07-10
//============================================================================================= 
String.prototype.isDateAndTime =function()
{
        var re =/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/; 
        return re.test(this);
}
//=============================================================================================
//	是否日期格式		zcy		08-07-10
//============================================================================================= 
String.prototype.isDateTime =function()
{
        var re =/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
        return re.test(this);
}
//=============================================================================================
//	是否电话号码		zcy		08-07-16
//============================================================================================= 
String.prototype.isDateTime =function()
{
        var re =/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
        return re.test(this);
}

String.prototype.isTelephone =function()
{
        var re =/(\(\d{3}\)|\d{3}-)?\d{8}/;
        return re.test(this);
}


//=============================================================================================
//	设置输入框，下拉框可用不可用        zzj 08.8.4
//============================================================================================= 
function SetEdit(objvalue)
{

   var dtlist = document.getElementsByTagName("input");
   
   for( var i=0;i<dtlist.length;i++)
   {
        if ((dtlist[i].type.toLowerCase()=="checkbox")||(dtlist[i].type.toLowerCase()=="text"))
        {
            
            if (dtlist[i].id.indexOf("_txtifhad") > 0)
            {
                continue;
            }
            
            if (dtlist[i].id.indexOf("ANNUL_REASON") == 0)
            {
               continue;
            }
            dtlist[i].disabled = objvalue;
        }
   }
   
   dtlist = document.getElementsByTagName("select");
   for( var i=0;i<dtlist.length;i++)
   {
        if (dtlist[i].id.indexOf("_DPTache") > 0)
        {
            continue;
        }
        else
        {
            dtlist[i].disabled = objvalue;
         }
   }
   
   dtlist = document.getElementsByTagName("img");
   for( var i=0;i<dtlist.length;i++)
   {
       dtlist[i].onclick = function (){};
   }
}

//=============================================================================================
//	设置输入框，下拉框可用不可用        zzj 面板点击 
//============================================================================================= 
function ViewClick( objView, objlb )				
{
    if ( document.getElementById(objlb).className	== "TabStrip_BtnDown")
      return;
      
    for( var i =1 ;i < 5; i++)
    {
        if (document.getElementById('lbInfo'+i) != null)
        {
            document.getElementById('lbInfo'+i).className = "TabStrip_BtnUp";
        }
    }
    
    
    document.getElementById(objlb).className		= "TabStrip_BtnDown";
    document.getElementById(FirtView).style.display = "none";
    document.getElementById(objView).style.display  = "";
    FirtView = objView;
}

//=============================================================================================
//	脚本控制获取今年的后10年的年份 并赋值给下拉框select  zzj 091210
//=============================================================================================
function GetYearOfDate(objView)
{
    today = new Date();
    var iYear = today.getYear() * 1;
    var control = $(objView);
    if (control == null) 
    {
        return;
    }
    control.options.length = 0;
    
    for (var i = 0; i <=10; i++) 
    {
        control.options.add(new Option(iYear + i));
    }
}




// 
function insertRow(obj, index, objvalue) {
    if (obj != null) {
        var tmpindex = getrownumer(obj);
        var objRow = obj.insertRow(tmpindex);
        var objCel = objRow.insertCell(0);
        objCel.innerHTML = objvalue;
    }
}

function deleteRow1(obj, index) {
    if (obj != null) {
        obj.deleteRow(index);
        var icount = obj.rows.length;
        for (var i = 0; i <= icount - 1; i++) {
            // debugger
            objtmp1 = obj.rows[i].innerHTML;

//            objtmp2 = objtmp1.substring(0, objtmp1.lastIndexOf('第') + 1);
//            objtmp3 = objtmp1.substring(objtmp1.lastIndexOf('注'));
//            objtmp4 = i * 1 + 1;
//            objtmp1 = objtmp2 + objtmp4 + objtmp3;
            obj.rows[i].cells[0].innerHTML = objtmp1;
        }
    }
}

function deleteRow(obj, index) {
    if ($1("tab1") != null) {
        $1("tab1").deleteRow(index);
    }
}

function deleteAllRow(obj) {
    if (obj != null) {
        var rows = obj.rows.length;
        for (var i = rows - 1; i >= 0; i--) {
            obj.deleteRow(i);
        }
    }
}

function getrownumer(obj) {
    if (obj != null) {
        return obj.rows.length;
    }
}

function getcellnumber(obj) {
    if (obj != null) {
        var rows = obj.rows.length;
        if (rows > 0) {
            cells = obj.rows[0].cells.length;
            for (var i = 0; i < rows; i++) {
                tmpcells = obj.rows[i].cells.length;
                if (cells < tmpcells) {
                    cells = tmpcells;
                }
                return cells;
            }
        }
        else {
            return 0;
        }
    }
}

function getIndex() {
    intRowIndex = event.srcElement.parentElement.parentElement.parentElement.rowIndex;
    return intRowIndex;
}


function IsURL(str_url) {
    var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
	+ "?(([0-9a-z_!~*'().&amp;=+$%-]+: )?[0-9a-z_!~*'().&amp;=+$%-]+@)?" //ftp的user@
	+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
	+ "|" // 允许IP和DOMAIN（域名）
	+ "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
	+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
	+ "[a-z]{2,6})" // first level domain- .com or .museum
	+ "(:[0-9]{1,4})?" // 端口- :80
	+ "((/?)|" // a slash isn't required if there is no file name
	+ "(/[0-9a-z_!~*'().;?:@&amp;=+$,%#-]+)+/?)$";
    var re = new RegExp(strRegex);
    //re.test()
    if (re.test(str_url)) {
        return true;
    } else {
        return false;
    }
}

// 验证手机
function checkMobile(src) {
    var mobile = src;
    var reg0 = /^13\d{5,9}$/;   //130--139。至少7位
    var reg1 = /^153\d{8}$/;  //联通153。至少7位
    var reg2 = /^159\d{8}$/;  //移动159。至少7位
    var reg3 = /^158\d{8}$/;
    var reg4 = /^150\d{8}$/;
    var my = false;
    if (reg0.test(mobile)) my = true;
    if (reg1.test(mobile)) my = true;
    if (reg2.test(mobile)) my = true;
    if (reg3.test(mobile)) my = true;
    if (reg4.test(mobile)) my = true;
    if (!my) {        
        return false;
    } else {
        return true;
    }
}
