//主题图片切换效果，yyj 2006-5-18
function changePic(obj,pp){
obj.filters.revealTrans.Transition=12;
obj.filters.revealTrans.apply();
obj.src=pp;
obj.filters.revealTrans.play();
}
//end 

function trim_spaces(from_where,str)
{	 
  var temp_string=str
  if (from_where=="B")
     {
	   from_where="BOTH"
	 }

  if (from_where.toUpperCase()=="LEFT" || from_where == "BOTH")
     {
	  while(temp_string.substring(0,1)==" ")
	    {
		  temp_string = temp_string.substring(1)
		}
	 }
  if (from_where.toUpperCase()=="RIGHT" || from_where == "BOTH")
     {
	  while(temp_string.substring(temp_string.length-1)==" ")
	    {
		  temp_string = temp_string.substring(0,temp_string.length-1)
		}
	 }
  return temp_string
  
}
function checksub()
{
  var strErr=""
  var strs=new String(document.form2.UserName.value+document.form2.UserPwd.value)
  var vv="B"
      strs = trim_spaces(vv,strs)
  if (strs.length==0) 
    {
	   strErr="没有键入用户名或密码!";
	   return strErr;
	}
  var poisions=new Array("/","\\",":","*","?","\"","<",">","|","'","#","@","$","%","^","&","~","`")
  var x_cut
  for(var j=0 ;j<strs.length;j++)
    {  x_cut=strs.substr(j,1)
	   //alert(strs+"的第"+j+"个字符为:"+x_cut)
       for(var i=0 ;i<poisions.length;i++)
       {
	      if (x_cut==poisions[i])
		     {
				 strErr="用户名和密码中不能有如下字符:\n"+poisions;
				 return strErr;
			 }
       }
    }
	return strErr;
}

//---访客登录
function Guest_login()
{
	strDBID=document.form2.hidDBID.value;	
	if (strDBID=="")
	{
		alert("页面尚未完全载入！");
		return false;
	}
	else
	{
		JudgeInput("1","");
	}
}

function ChangeDBID0(strDBIDStr)
{
	form2.action="login0.asp";
	form2.submit();
	//window.location="login0.asp"//?DBID="+strDBIDStr;
}

function ChangeDBID1(strDBIDStr)
{
	form2.action="login1.asp";
	form2.submit();
}

function JudgeInput0(nodeid,nodepath){
	var strErr="";
	

		if (document.form2.UserName.value =="")
		{
			strErr="用户名为空！\n";
			
		}

		if (document.form2.UserPwd.value =="")
		{
			strErr=strErr +"密码为空！\n";
			
		}
			
		if (strErr!="")
		{
			alert(strErr+"请确认必填项是否已经填入！");			
			return false;
		}
		
		if (strErr=="")
		{
			//--------------检查输入是否合法
			strErr=checksub();
			if (strErr!="")
			{
				alert(strErr);	
				document.form2.UserName.focus();			
				return false;
			}
		}
		

		if (strErr=="")
		{
			
			//var UserName=form2.UserName.value;
			//var UserPwd=form2.UserPwd.value;			
			var sDBID=form2.DBID.value;
			form2.action="checkLogin0.asp?dbid="+sDBID;
			form2.submit();
			//window.location ="checkLogin0.asp?dbid="+sDBID;

		}
}

function JudgeInput1(nodeid,nodepath){
	var strErr="";
	

		if (document.form2.UserName.value =="")
		{
			strErr="用户名为空！\n";
			
		}

		if (document.form2.UserPwd.value =="")
		{
			strErr=strErr +"密码为空！\n";
			
		}
			
		if (strErr!="")
		{
			alert(strErr+"请确认必填项是否已经填入！");			
			return false;
		}
		
		if (strErr=="")
		{
			//--------------检查输入是否合法
			strErr=checksub();
			if (strErr!="")
			{
				alert(strErr);	
				document.form2.UserName.focus();			
				return false;
			}
		}
		

		if (strErr=="")
		{
			
			//var UserName=form2.UserName.value;
			//var UserPwd=form2.UserPwd.value;			
			var sDBID=form2.DBID.value;
			form2.action="checkLogin1.asp?dbid="+sDBID;
			form2.submit();
			//window.location ="checkLogin0.asp?dbid="+sDBID;

		}
}


function gotohelp()
{
	if (eval(document.form2.degreename)!=undefined)
	{
		var degreeid=document.form2.degreename.value;
	}
	
	
	var url;
	//alert(url);
	url="./common/gotoHelp.asp?DegreeID="+degreeid;
	window.open(url);
	/*
	switch(degreeid){
	case "2":
		url="./common/help1se/resmanager/help.htm";
		window.open(url);
		break;
	case "3":
		url="./common/help1se/auditing/help.htm";
		window.open(url);
		break;
	case "4":
		url="./common/help1se/teacher/help.htm";
		window.open(url);
		break;
	case "5":
		url="./common/help1se/student/help.htm";
		window.open(url);
		break;
	case "6":
		url="./common/help1se/student/help.htm";
		window.open(url);
		break;
	case "7":
		url="./common/help1se/admin/help.htm";
		window.open(url);
		break;
	default:
		url="./common/help1se/visitor/help.htm";
		window.open(url);
	}
	*/
}

function login()
{  
	strDBID=document.form2.DBID.value;	
	if (strDBID=="")
	{
		alert("页面尚未载入！");
		return false;
	}
	else
	{
		jp2index("1","",strDBID);
	}
}

function jp2index(nodeid,nodepath,Version){	

	var strDegreeID = form2.degreename.value;	
	if (strDegreeID == "")
	{
	   alert("请您选择正确的用户角色，或者联系系统管理员取得合法角色！");
	   return false;
	}

	var height1=screen.availHeight-50;
	var width1=screen.availWidth-10;
	var URL="./ResourceManage/resourcebrowse/IncludeIndex.asp?DegreeID="+strDegreeID+"&Action=InBox&Version="+Version
    window.open(URL,'','scrollbars=no,resizable=yes,status=yes,height='+height1+',width='+width1+',top=0,left=0');
}

//按学科登录
function subjectLogin(defaultSubject){
	//var UserName=form2.UserName.value;
	//var UserPwd=form2.UserPwd.value;
	var height1=screen.availHeight-50;
	var width1=screen.availWidth-10;
	var DBID=form2.DBID.value;
	var objDegreeID=eval(form2.degreename);	
	if (objDegreeID==undefined)	{
		url="http://61.142.114.240/resource/JudgeLogin_1.asp?Version="+DBID+"&DegreeID=6&UserID=guest$00000000&UserPwd=guest" ;
		url=url+"&DBID=&defaultSubject=" + defaultSubject;
		window.open(url,'','scrollbars=no,resizable=yes,status=yes,height='+height1+',width='+width1+',top=0,left=0');
		
		//var height1=screen.availHeight-50;
		//var width1=screen.availWidth-10;
		//var URL="./ResourceManage/resourcebrowse/IncludeIndex.asp?DegreeID=6&Action=InBox&Version=&defaultSubject=" + defaultSubject;
	    //window.open(URL,'','scrollbars=no,resizable=yes,status=yes,height='+height1+',width='+width1+',top=0,left=0');
	}
	else{
		objDegreeID=objDegreeID.value;
		var UserID=form2.UserID.value;
		var DBID=form2.DBID.value;
		url="http://61.142.114.240/resource/JudgeLogin_1.asp?Version="+DBID+"&UserID="+UserID+"&DegreeID="+objDegreeID ;
		url=url+"&DBID=&defaultSubject=" + defaultSubject;
		//alert(url);
		//return;
		window.open(url,'','scrollbars=no,resizable=yes,status=yes,height='+height1+',width='+width1+',top=0,left=0');
		//var height1=screen.availHeight-50;
		//var width1=screen.availWidth-10;
		//var URL="./ResourceManage/resourcebrowse/IncludeIndex.asp?DegreeID="+objDegreeID+"&Action=InBox&Version=&defaultSubject=" + defaultSubject;
		//window.open(URL,'','scrollbars=no,resizable=yes,status=yes,height='+height1+',width='+width1+',top=0,left=0');
	}

    
}

//---进入"More"页面
function More(type) 
{
	strDBID=document.form2.DBID.value;
	strUserID=document.form2.UserID.value;
	if (type=="NewUpdate")
	{
	window.open("./ResourceManage/ResourceBrowse/NewUpdate.asp?dbid="+strDBID,'more','scrollbars=no,resizable=no,status=no,width=700,height=500');
	}
	else 
	if (type=="GoodTheme")
	{
	window.open("GoodTheme_more.asp?dbid="+strDBID+"&userid="+strUserID,'more','scrollbars=no,resizable=no,status=no');
	}
	else 
	if (type=="GoodRes")
	{
	window.open("GoodRes_more.asp?dbid="+strDBID+"&userid="+strUserID,'more','scrollbars=no,resizable=no,status=no');
	}
}

////----首页搜索
function Search()
{
	strDBID=document.form2.DBID.value;
	strKeyWords=document.form2.KeyWords.value;
	PageIndex=document.form2.PageIndex.value;
    if(strKeyWords=="")
	{
		alert("请输入关键字!");
		return false;
	}
	
	window.open("ResSearchList.asp?DBID="+strDBID+"&KeyWords="+strKeyWords+"&PageIndex="+PageIndex)
}
