//========================================
//登录
//========================================

function userLogon()
{
    var a=window.open(location.pathname+"?WP=PZ01","","resizable=no,width=400,height=260");
}

function userLogout()
{
    var a=window.open(location.pathname+"?WP=PZ07","","resizable=no,width=400,height=260");
}

function changePassword()
{
    var a=window.open(location.pathname+"?WP=PZ03","","resizable=no,width=400,height=300");
}

function setCurrUser()
{
	g_visitor_name=xml5.selectSingleNode("/eschool/basic/visitorname").text;
	g_session_id=xml5.selectSingleNode("/eschool/basic/sessionid").text;
	if(g_visitor_name=='')
		alert("非法用户名或口令!");
	else //if(g_t_id==CONST_MYROOM)
	{
		location.reload();
	}
}
function openwindow(param)
{
    var a=window.open(location.pathname+"?"+param);
}
function gotoPage(page)
{
	var str1;
	var str2;
	var str3;
	var i;
	var j;
	var k;
	str1=location.href;

	i=str1.indexOf("PARA=[[");
	if(i==-1)
	{
		if (str1.indexOf("?")==-1)
			str2=str1 + "?PARA=[[Page:" + page + "]]";
		else
			str2=str1 + "&PARA=[[Page:" + page + "]]";

	}
	else
	{
		j=str1.indexOf("[Page:");

		if(j==-1)
		{
			str2=str1.substring(0,i+6)+"[Page:"+ page +"]"+str1.substring(i+6)
		}
		else
		{
			 str2=str1.substring(0,j)+"[Page:"+ page +"]";
			 str3=str1.substring(j+1);
			 k=str3.indexOf("]");
			 str2=str2+str3.substring(k+1);
		}
	}
	window.location=str2;
}
function SearchTitle()
{
	var urle;
	if (Keyword.value.length==0){alert("请输入关键字!");return;}
	urle=location.pathname+"?WP=P121&PARA=[[IKW:"+ escape(Keyword.value)+"]";
	if(select.value!=0)
		urle=urle+"[ICIDS:"+select.value+"]";
	urle=urle+"]";
	window.open(urle);
}
function AdvanceSearch(obj)
{

	var i;
	var j;
	var str;
	var str1;

	var urle;
	if (Keyword.value.length==0){alert("请输入关键字!");return;}
	if(obj.name=="oldsearch")
	{

		str=location.href;
		alert(str);
        i=str.indexOf("[IKW:");
        alert(i);
		str1=str.substring(i+1);
		alert(str1);
		j=str1.indexOf("]");
		urle=str.substring(0,i)+str1.substring(0,j-1)+","+ escape(Keyword.value)+str1.substring(j);

	}

	else if(obj.name=="newsearch")
	{
		urle=location.pathname+"?WP=P121&PARA=[[IKW:"+escape(Keyword.value)+"]";
		if(select.value!=0)
			urle=urle+"[ICIDS:"+select.value+"]";
		urle=urle+"]";
	}
	else
	{
		urle=location.pathname+"?WP=P121&PARA=[[IFS:1][IKW:"+escape(Keyword.value)+"]";
		if(select.value!=0)
			urle=urle+"[ICIDS:"+select.value+"]";
		urle=urle+"]";
	}
	window.location=urle;
}

function move(obj,time,speedx,speedy)
{	
	
	
	var oLeft;
	var oTop;
	oLeft=String(document.all(obj).style.left);
	oTop=String(document.all(obj).style.top);	
	
	if(oLeft=="0px" && oTop=="0px")
	{
		document.all(obj).style.left=Rnd()*800;		
		document.all(obj).style.top=Rnd()*600;
	}
	if(document.all(obj).prototype==1)
	{
	    if(parseFloat(document.all(obj).style.left)+parseFloat(document.all(obj).width)+20>window.document.body.offsetWidth+window.document.body.scrollLeft)
	    {
	    	speedx=-1*Math.abs(speedx)
	    }
	    if(parseFloat(document.all(obj).style.left)<window.document.body.scrollLeft)
	    {
	    	speedx=Math.abs(speedx)
	    }
	    if(parseFloat(document.all(obj).style.top)+30>window.document.body.offsetHeight+window.document.body.scrollTop)
	    {
	    	speedy=-1*Math.abs(speedy)
	    }
	    if(parseFloat(document.all(obj).style.top)<window.document.body.scrollTop)
	    {
	    	speedy=Math.abs(speedy)
	    }
		document.all(obj).style.left=parseFloat(document.all(obj).style.left)+parseFloat(speedx)
		document.all(obj).style.top=parseFloat(document.all(obj).style.top)+parseFloat(speedy)
	}
	setTimeout("move('"+obj+"','"+time+"','"+speedx+"','"+speedy+"')",time);
		

}

function Rnd()
{
	
	return(Math.random());
	
}