// JavaScript Document
function NotNull(oid)
{
	if(trim(GE(oid).value).length>0)
	{
		return true;
	}
	return false;
}
function Regx(str,type)
{
	str=trim(str);
	var pattern;
	switch(type)
	{
		case "email":
			pattern=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
			break;
		case "phone":
			pattern=/^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/;
			break;
		case "mobile":
			pattern=/^(13|15)\d{9}$/;
			break;
		case "number":
			pattern=/^\d+$/;
			break;
		case "uname":
			pattern=/^[A-Za-z0-9]{6,20}$/;
			break;
		case "username":
			pattern=/^[\w]{2,20}$/;
			break;
		case "password":
			pattern=/^[\w]{6,20}$/;
			break;
		case "upass":
			pattern=/^[A-Za-z0-9]{6,20}$/;
			break;
		case "http":
			pattern=/^http(s)?:\/\/([\w-]+\.)+[\w-]+([\w- .?%&=]*)?$/;
			break;
		case "qq":
			pattern=/^\d{6,9}$/;
			break;
		default:
			break;
	}
	if(pattern.test(str))
	{
		return true;		
	}
	else
	{
		return false;		
	}
}
function trim(val)
{
		var str = val+"";
		if ( str.length == 0 ) 
			return str;		
		var re = /^\s*/;
		str = str.replace(re,'');	
		re = /\s*$/;
		return str.replace(re,'');
}
function AlertAndRedirectSelf(msg)
{
	alert(msg);
	location.href=window.location.href;
}
function AlertAndRedirectHref(msg,val)
{
	alert(msg);
	location.href=val;
}
function GE(str)
{
	var o=document.getElementById(str);
	return o;
}

function CheckIsDel()
{
	return confirm("ÄãÕæµÄÒªÉ¾³ýÃ´£¿");}

function onDdlChange(obj,page)
{
	location.href=page+obj.options[obj.selectedIndex].value;
	}
	
function CheckId(obj,idstr)
{
	if(obj.id.indexOf(idstr)==0)
	{
		return true;
	}
	return false;
}
function SelectAllCbx(obj)
{
	for(var i=0;i<document.all.length;i++)
	{
		var o=document.all(i);
		if(o.type=="checkbox"&& CheckId(o,"cbx"))
		{
			o.checked=obj.checked;
		}									   
	}
}
function onClickDeleteMore(url)
{
	if(CheckIsDel())
	{
		var idstr="";
		for(var i=0;i<document.all.length;i++)
		{
			var o=document.all(i);
			if(o.type=="checkbox"&& CheckId(o,"cbx"))
			{
				if(o.checked)
				{
					idstr+=o.value+",";
				}
			}									   
		}
		if(idstr.length>0)
		{
			location.href=url+idstr.substring(0,idstr.length-1);
		}
	}
}
function onClickDeleteMore2(url)
{
	var idstr="";
		for(var i=0;i<document.all.length;i++)
		{
			var o=document.all(i);
			if(o.type=="checkbox"&& CheckId(o,"cbx"))
			{
				if(o.checked)
				{
					idstr+=o.value+",";
				}
			}									   
		}
		if(idstr.length>0)
		{
			location.href=url+idstr.substring(0,idstr.length-1);
		}
}
function CheckDDLOnLoad(obj,val)
{
	var o=GE(obj);
	for(var i=0;i<o.length;i++)
	{
		if(o.options[i].value==val)
		{
			o.options[i].selected=true;
		}
	}
}
function PlsProSelect(obj)
{
	var eto=GE("PlsPla");
	var vall=GE("PlsAll").value;
	eto.length=0;
	if(vall.length>0)
	{
		var vallstr=vall.split(';');
		for(var i=0;i<vallstr.length;i++)
		{
			var vallstring=vallstr[i].split(',');
			var valindex=vallstring[0];
			var valplace=vallstring[1];
			
			if(valindex.substring(0,2)==obj.value.substring(0,2)&&valindex.substring(2,4)!="00")
			{
				eto.options.add(new Option(valplace,valindex));
			}
		}
	}
}
function onProjectSelect(obj)
{
	var eto=GE("TC_Id");
	var vall=GE("ClassAll").value;
	eto.length=0;
	if(vall.length>0)
	{
		var vallstr=vall.split(';');
		for(var i=0;i<vallstr.length;i++)
		{
			var vallstring=vallstr[i].split(':');
			var tpid=vallstring[0];
			var tc=vallstring[1];
			if(tpid==obj.value)
			{
				eto.options.add(new Option(tc.split(',')[1],tc.split(',')[0]));
			}
		}
	}
	onClassSelect(eto);
}
function onClassSelect(obj)
{
	if(obj.value.length>0)
	{
		location.href="T_csuser.asp?tid="+GE("TP_Id").value+"&cid="+obj.value;
	}
	else
	{
		location.href="T_csuser.asp?tid="+GE("TP_Id").value;
	}
}

function HiddenTable(obj)
{
	GE(obj).style.display="none";
}
function ShowTable(obj)
{
	GE(obj).style.display="";
}

function WinShowModalDialog(url,mark,height,width)
{
	window.showModalDialog('"+url+"','"+mark+"', 'height="+height+"px, width="+width+"px, top=0, left=0, toolbar=no, menubar=no, scrollbars=auto, resizable=yes,location=no, status=no');
}


function onddltypeSelect(obj,url)
{
	var eto=GE("ddl_small");
	var vall=GE("smallall").value;
	eto.length=0;
	eto.options.add(new Option("",""));
	if(vall.length>0)
	{
		var vallstr=vall.split(';')
		for(var i=0;i<vallstr.length;i++)
		{
			var vallstring=vallstr[i].split(':');
			var tpid=vallstring[0];
			var tc=vallstring[1];
			if(tpid==obj.value)
			{
				eto.options.add(new Option(tc.split(',')[1],tc.split(',')[0]));
			}
		}
	}
	onddlsmallSelect(eto,url);
}
function onddlsmallSelect(obj,url)
{
	location.href=url+"&ntid="+GE("ddl_type").value+"&nsid="+obj.value;
}
function onddl_typeSelect(obj)
{
	var eto=GE("ddl_small");
	var vall=GE("smallall").value;
	eto.length=0;
	if(vall.length>0)
	{
		var vallstr=vall.split(';')
		for(var i=0;i<vallstr.length;i++)
		{
			var vallstring=vallstr[i].split(':');
			var tpid=vallstring[0];
			var tc=vallstring[1];
			if(tpid==obj.value)
			{
				eto.options.add(new Option(tc.split(',')[1],tc.split(',')[0]));
			}
		}
	}
}

function Guide_Over(obj,i)
{
	GE("gt_"+i+"_l").className="span_over_l";
	GE("gt_"+i+"_r").className="span_over_r";
	
	obj.className="span_over";
}
function Guide_Out(obj,i)
{
	GE("gt_"+i+"_l").className="span_out_l";
	GE("gt_"+i+"_r").className="span_out_r";
	obj.className="span_out";
}
function OnJsClear(gpid,totnum)
{
	for(var i=0;i<totnum;i++)
	{
		var ott=GE("NewsTitle"+gpid+"_"+i);
		var otb=GE("NewsTable"+gpid+"_"+i);
		
		ott.className="span_out";
		otb.style.display="none";
	}
}
function OnJsTable(gpid,onid,totnum)
{	
	OnJsClear(gpid,totnum);
	
	var ott=GE("NewsTitle"+gpid+"_"+onid);
	var otb=GE("NewsTable"+gpid+"_"+onid);
	
	ott.className="span_on";
	otb.style.display="";
}

function GetPostfix(str)
{
	return str.substring(str.lastIndexOf("."),str.length).toUpperCase();
	}
function IsPic(url)
{
	var tt=GetPostfix(url);
	if(tt==".GIF"||tt==".JPG"||tt==".PNG"||tt==".BMP"||tt==".JPEG")
	{
		return true;
	}
	return false;
}
function IsSwf(url)
{
	var tt=GetPostfix(url);
	if(tt==".SWF")
	{
		return true;
	}
	return false;
}
function IsMV(url)
{
	var tt=GetPostfix(url);
	if(tt==".RM"||tt==".WMV"||tt==".WMA"||tt==".MP3")
	{
		return true;
	}
	return false;
}
function IsHtmlPage(url)
{
	var tt=GetPostfix(url);
	if(tt==".ASPX"||tt==".ASP"||tt==".HTML"||tt==".HTM"||tt==".JSP"||tt==".PHP")
	{
		return true;
	}
	return false;
}
function IsExcel(url)
{
	var tt=GetPostfix(url);
	if(tt==".XLS")
	{
		return true;
	}
	return false;
}
function onProjectSelect2(obj)
{
	var eto=GE("TC_Id");
	var vall=GE("ClassAll").value;
	eto.length=0;
	if(vall.length>0)
	{
		var vallstr=vall.split(';');
		for(var i=0;i<vallstr.length;i++)
		{
			var vallstring=vallstr[i].split(':');
			var tpid=vallstring[0];
			var tc=vallstring[1];
			if(tpid==obj.value)
			{
				eto.options.add(new Option(tc.split(',')[1],tc.split(',')[0]));
			}
		}
	}
}