var IE = (document.all) ? 1 : 0;
var NS = (document.layers) ? 1 : 0;

// WINDOW STATUS FUNCTIONS
window.defaultStatus = "";

var bV=parseInt(navigator.appVersion);
var NN4=(document.layers) ? true : false;
var IE4=((document.all)&&(bV>=4))?true:false;
var moveFlag=false;

var fntSize=9;					
var tipBgColor="FFFFCC";		
var tipBorderColor="000000";	
var tipTextColor="000000";		

function turnit(ss,ii,climg,opimg){
	if (ss.style.display=="none"){
		ss.style.display="";
	  	ii.src=opimg;
	}else{
		ss.style.display="none"; 
	  	ii.src=climg;
	}	
} 

function turnit2(ss,ii,climg,opimg,jj,climg2,opimg2){
	if (ss.style.display=="none"){
		ss.style.display="";
	  	ii.src=opimg;
	  	jj.src=opimg2;
	}else{
		ss.style.display="none"; 
	  	ii.src=climg;
	  	jj.src=climg2;
	}
} 

function setReload(){
  window.location.reload()
}

function showTip(msg){
  var obj = 'TipBox';

  moveFlag=true;
  if(NN4){
	with (document[obj].document){
	  open();
	  write('<layer ID=TipBox bgColor=#'+tipBgColor+' style="border:1px solid #'+tipBorderColor+'; font-size:'+fntSize+'pt;"><font color=#'+tipTextColor+' lang="gb2312" face="宋体">'+msg+'</font></layer>');
	  close();
	}
    document.layers[obj].visibility = 'visible';
  }else if(IE4){
	IE_MouseMove();
    document.all[obj].innerHTML = msg;
    document.all[obj].style.visibility = 'visible';
  }
}

function hideTip(){
  var obj = 'TipBox';

  moveFlag=false;
  if(NN4){
    if(document.layers[obj] != null) document.layers[obj].visibility = 'hidden';
  }else if(IE4)
    document.all[obj].style.visibility = 'hidden';
}

function IE_MouseMove(){
  if(moveFlag){
	var x = event.x;
	var y = event.y;

	var objp = document.all.TipBox.style;
	var xx = (document.body.scrollLeft+x);
	var yy = (document.body.scrollTop+y);

	objp.pixelLeft = xx;
	objp.pixelTop = yy+10;
  }
} 

function NN_MouseMove(e){
  if(moveFlag){
	var objp = document.layers.TipBox;
	objp.moveTo(e.x+20, e.y);
  }
}

if(IE4){
  document.write("<DIV ID=TipBox STYLE='position:absolute; visibility: hidden; padding: 0.2em 0.2em 0.2em 0.2em; color: #"+tipTextColor+"; background-color: #"+tipBgColor+"; border:1px solid #"+tipBorderColor+"; font-size: "+fntSize+"pt'></DIV>");
  document.onmousemove = IE_MouseMove;
}else{
  document.write("<DIV ID=TipBox STYLE='position:absolute; visibility: hidden; background-color: #"+tipBgColor+"; border:1px solid #"+tipBorderColor+"; font-size: "+fntSize+"pt'></DIV>");
  document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = NN_MouseMove;
  setTimeout("window.onresize=setReload",500)
}

function ShowHit( aText ){
	document.write( "<table width='100%' border=0><tr><td width='30'><img src='images/light.JPG' style='filter:alpha(opacity=20)'></td><td><font color='#40436b' style='font-size:9pt'><b>你知道吗?</b> " + aText + "</font></td></tr></table>" );
}

function ShowDialog( loc ){
	//window.showModalDialog( loc,'','scrollbars=yes;resizable=no;help=yes;status=no;dialogTop='+((screen.height-600)/2)+';dialogLeft='+((screen.width-400)/2)+';dialogWidth=402px;dialogHeight=415px;center=yes')
	window.showModalDialog( loc,'','center=yes;help=no;resizable=yes;status=no;dialogHeight:300px;dialogWidth:650px')
}

function openwin( aurl, w, h ){
	var attribution;
	attribution = "toolbar = no, " +
	"menubar = no, " +
	"scrollbars = yes, " +
	"status = no, " +
	"location = no, " +
	"resizable = no, " +
	"directories = no, " +
	"width = "+w+", " +
	"height = "+h+", " +
	"top = " + (screen.height-h)/2 + "," +
	"left = " +(screen.width-w)/2 + "," +
	"maxinizebox = 0";
	window.open( aurl,"attent",attribution );
}

function popUp( loc, w, h, menubar ) {
	if( w == null ) { w = 402; }
	if( h == null ) { h = 415; }
	if( menubar == null || menubar == false ) {
		menubar = "";
	} else {
		menubar = "menubar,";
	}

	if( NS ) { w += 50; }
	// Need the var or else IE4 blows up not recognizing editorWin
	var editorWin = window.showModalDialog(loc,'editWin', menubar + 'resizable,scrollbars,width=' + w + ',height=' + h);
	//if( !newWin.opener )
		//newWin.opener = window;
	editorWin.focus(); //causing intermittent errors
}

//调用页面
function js_callpage( URL, width, height ) {
 var newwin = window.open( URL, "homeWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top="+(screen.height-height)/2+",left="+(screen.width-width)/2+",width="+width+",height="+height );
return false;
}
function blankwin( URL ) {
 var newwin = window.open( URL, "blankwin", "" );
}
//右键功能
//document.oncontextmenu=new Function("event.returnValue=false;");
//选定页面上的文字
//document.onselectstart=new Function("event.returnValue=false;");

// 字段排序
// 注意在调用页面里要先写入 <INPUT name=Order type=hidden>          排序的字段
//                       <INPUT name=OrderDirection type=hidden> 排序的顺序
function NewOrder(NewOrderNum)
{
	//Order为排序的
	if(document.mainform.Order.value!=NewOrderNum)
	{
		document.mainform.Order.value=NewOrderNum;
		document.mainform.OrderDirection.value = 2;
	} else {
		var TempVar=document.mainform.OrderDirection.value;
		document.mainform.OrderDirection.value=TempVar==1?2:1;
	}
	document.mainform.submit();
}

function doOrder(OrdFld)
{
	if (document.mainform.h_OrderField.value!=OrdFld)
	{
		document.mainform.h_OrderField.value=OrdFld;
		document.mainform.h_OrderDirection.value="ASC";
	}
	else
	{
		var TempDir=document.mainform.h_OrderDirection.value;
		document.mainform.h_OrderDirection.value=TempDir=="DESC"?"ASC":"DESC";
	}
	document.mainform.submit();
}

function Redir(ParentID)
{
	window.location.href = "public.asp?psid="+ParentID;
}

function doCancel(aURL){
	document.forms(0).action.value="";
	if (aURL!="")
		document.forms(0).action=aURL;
	document.forms(0).submit();
	//document.form1.submit(); // 不好，固定了表单名；
}

