﻿resizeTo(screen.width,screen.height,moveTo(0,0));

function openPage(filename)
{
	window.open(filename,'', 'fullscreen=1,titlebar=1,scrollbars=1,toolbar=0,status=0,resizable=1');
}

function openWindow(width, height, filename)
{
	var features="'dialogWidth:"+width+";dialogHeight:"+height+";status:0;help:0;scrollbar:0;'";
	var arr = showModalDialog(filename, window, features);
	refresh();
}

function refresh()
{
	Anthem_InvokePageMethod('Refresh',[],function(result) {});
}

function mouseEnter()
{
window.event.srcElement.className="itemover";
}
function mouseLeave()
{
window.event.srcElement.className="item";
}

function courseEnter()
{
window.event.srcElement.className="courseover";
}
function courseLeave()
{
window.event.srcElement.className="course";
}
//以下为机构自动建议的js程序
function ShowDiv(divid)
{
	
	if (document.layers) 
	{
	document.layers[divid].height="150px";
	document.layers[divid].display="show";
	}
	else 
	{

	document.getElementById(divid).style.height="150px";
	document.getElementById(divid).style.position = 'absolute'; 
	document.getElementById(divid).style.zIndex = 2;
	document.getElementById(divid).style.display="block";
	}
}

function HideDiv(divid)
{
	if (document.layers) 
	{
	document.layers[divid].visibility="hide";
	}
	else 
	{
	document.getElementById(divid).style.display="none";
	}
}

function ClearResults()
{
	var resultsdiv=document.getElementById("searchresults");
	var countre=resultsdiv.childNodes.length;
	for  (var i=countre-1; i>=0; i--)
	{
		resultsdiv.removeChild(resultsdiv.childNodes[i]);
	}
}
//
function LoadResults(searchterm)
{
	if(searchterm.length==0 || window.event.keyCode==13)
	{
		ClearResults();
		HideDiv("searchresults");
		return;
	}
	Anthem_InvokePageMethod('RetrieveRows', [searchterm], LoadResultsCallback);
}

function LoadResultsCallback(result)
{
	ShowDiv("searchresults");
	ClearResults();

	var items=result.value;
	var count=items.Rows.length;

	var divResults=document.getElementById("searchresults");
	var tblTable=document.createElement("table");
	var tablebody=document.createElement("tbody");
	var tablerow, tablecell, tablenode;

	for (var i=0; i<count; i++)
	{
		var currenttext=items.Rows[i].Name;
		tablerow=document.createElement("tr");
		tablecell=document.createElement("td");
		tablecell.id=items.Rows[i].Id

		tablecell.onmouseover=function(){this.className='mouseOver';};
		tablecell.onmouseout=function(){this.className='mouseOut'};
		tablecell.setAttribute("border", "0");
		tablecell.onclick=function(){ReplaceInput(this);};
		tablenode=document.createTextNode(currenttext);

		tablecell.appendChild(tablenode);
		tablerow.appendChild(tablecell);
		tablebody.appendChild(tablerow);
	}

	tblTable.appendChild(tablebody);
	divResults.appendChild(tblTable);
}

function ReplaceInput(tablecell)
{

	var inputbox=document.getElementById("OrganTitle");
	//var organid=document.getElementById("OrganID");
	inputbox.value=tablecell.firstChild.nodeValue;
	//organid.value=tablecell.id;
	ClearResults();
	HideDiv("searchresults");
}
//以上为机构自动建议的js程序
//以下为上传文件的js程序
	function upload()
	{
		Anthem_InvokePageMethod('getNavigateUrl',[],
		function(result) 
		{
			var folderes=new Array();
			folderes=result.value.split(",");
			var myScript="/compus/ftb.imageGallery.aspx?rif=" + folderes[1] + "&cif=" + folderes[1] ;
			window.open(myScript,'', 'fullscreen:1;location:1;scrollbars:1;help:0;status:0;resizeable:1;');
			//var filename=showModalDialog(myScript,window,'dialogWidth:560px; dialogHeight:500px;help:0;status:0;resizeable:1;');
			//if (filename != null) {
			//filestring="<A href="+filename+">"+filename+"</A>";
			//oEditor = document.getElementById("Content");
	//oEditor.document.open();
	//oEditor.document.write(filename);//写入内容
	//oEditor.document.close();
			//oEditor.value+=filestring;
			//} 
			//else 
			//{
				//alert(""您没有选择图片。"");
			//}
		}
		);
	}
	
//以上为FTB上传文件的js程序
//以下为FreeTextBox编辑器
function edit()
{
		Anthem_InvokePageMethod('getNavigateUrl',[],
		function(result) 
		{
			var folderes=new Array();
			folderes=result.value.split(",");
			var myScript="/compus/ftbEditor.aspx?d=" + folderes[1] + "&f=" + folderes[2];
			window.open(myScript,'', 'fullscreen:1;scrollbars:1;help:0;status:0;resizeable:1;');
		}
		);
}

function saveFile()
{
		Anthem_InvokePageMethod('SaveFile',[],
		function(result) 
		{
			var filename=document.getElementById("FileName");
			window.opener.saveFileName(filename.value);
		}
		);
}
//以上为FreeTextBox编辑器

function insertFeedBack()
{
	Anthem_InvokePageMethod('InsertFeedBack',[],
	function(result)
	{
		var editor=document.getElementById("Editor");
		editor.value="";
		var items=new Array();
		items=result.value.split(",");
		var count=items.length-1;
		var feedbacks=document.getElementById("FeedBacks");
		var childnode=document.createElement("div");
		childnode.className="replyTitle";
		var sourceDiv=document.createElement("sourceDiv");
		sourceDiv.className="sourceDiv";
		sourceDiv.innerHTML=items[2]+"&nbsp;&nbsp;("+items[3]+")";
		childnode.appendChild(sourceDiv);

		var menuDiv=document.createElement("menuDiv");
		childnode.appendChild(menuDiv);

		feedbacks.appendChild(childnode);
		var content=document.createElement("div");
		content.className="contentDiv";
		content.innerHTML=items[1];

		feedbacks.appendChild(content);
		sept=document.createElement("div");
		sept.innerHTML="&nbsp;";
		feedbacks.appendChild(sept);
	}
	);
}

var Drag={
	"obj":null,
	"init":function(a, aRoot) {
		a.onmousedown=Drag.start;
		a.root=aRoot;
		if (isNaN(parseInt(a.root.style.left)))a.root.style.left="0px";
		if (isNaN(parseInt(a.root.style.top)))a.root.style.top="0px";
		a.root.onDragStart=new Function();
		a.root.onDragEnd=new Function();
		a.root.onDrag=new Function();
		},
	"start":function(a) {
		top.event.cancelBubble=true;
		var b=Drag.obj=this;
		a=Drag.fixE(a);
		var c=parseInt(b.root.style.top);
		var d=parseInt(b.root.style.left);
		b.root.onDragStart(d,c,a.clientX, a.clientY);
		b.lastMouseX=a.clientX;
		b.lastMouseY=a.clientY;
		top.document.onmousemove=Drag.drag;
		top.document.onmouseup=Drag.end;
		return false;
		},
	"drag":function(a) {
		a=Drag.fixE(a);
		var b=Drag.obj;
		var c=a.clientY;
		var d=a.clientX;
		var e=parseInt(b.root.style.top);
		var f=parseInt(b.root.style.left);
		var h,g;
		h=f+d-b.lastMouseX;
		g=e+c-b.lastMouseY;
		b.root.style.left=h+"px";
		b.root.style.top=g+"px";
		b.lastMouseX=d;
		b.lastMouseY=c;
		b.root.onDrag(h,g,a.clientX, a.clientY);
		return false;
		},
	"end":function() {
		top.document.onmousemove=null;
		top.document.onmouseup=null;
		Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left), parseInt(Drag.obj.root.style.top));
		Drag.obj=null;
		},
	"fixE":function(a){
		if(typeof a=="undefined") a=top.event;
		if(typeof a.layerX=="undefined")a.layerX=a.offsetX;
		if(typeof a.layerY=="undefined")a.layerY=a.offsetY;
		return a;
		}
};