// LGW 2006.12.16
function OpenPage(cURL) {
	location.replace(cURL);
}

function popWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;TopPosition=20
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,copyhistory=no,resizable=no';
	win=window.open(mypage,myname,settings);
	if(win.focus) win.focus();
}

function NotDisplayF()
{
	addclass.style.display="none";
	modiclass.style.display="none";
	deleclass.style.display="none";
	addprj.style.display="none";
	deleinfo.style.display="none";
}

function DisplayF(sid)
{
	NotDisplayF();
	eval(sid).style.display='';
}

function NewAdd(id,ci) {
	var win=window.open('newadd.asp?ty='+id+'&le=<%Response.Write(FavUpID)%>&ci='+ci, '', "height=520,width=760,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
	if(win.focus) win.focus();
}
function ExtTree(sid)
{
	if (eval('T_'+sid).style.display=='none') {
		eval('T_'+sid).style.display='';
		eval('i_'+sid).src='images/Tree/folder3.gif';
	} else {
		eval('T_'+sid).style.display='none';
		eval('i_'+sid).src='images/Tree/folder4.gif';
	}
}

//Dynamic write object tag - SiC/CYAN 2004
function ubbShowObj(strType,strID,strURL,intWidth,intHeight)
{
	var varHeader="b";
	var tmpstr="";
	var bSwitch = false;
	//Reverse the State
	bSwitch = document.getElementById(varHeader+strID).value;
	bSwitch	=~bSwitch;
	document.getElementById(varHeader+strID).value = bSwitch;
	if(bSwitch){
		//Code for already shown
		document.getElementById(strID).innerHTML = "网址: <A href='"+strURL+"' target='_blank'>"+strURL+"</a>";
	}else{
		//Code for not shown
		switch(strType){
			case "swf":
				tmpstr="<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width="+intWidth+" height="+intHeight+"><param name=movie value='"+strURL+"'><param name=quality value=high><param name=AllowScriptAccess value=never><embed src="+strURL+" quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width="+intWidth+" height="+intHeight+">"+strURL+"</embed></OBJECT>";
				break;
			case "wmp":
				tmpstr="<OBJECT classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902' type='application/x-oleobject' standby='Loading...' width="+intWidth+" height="+intHeight+"><PARAM NAME='FileName' VALUE='"+strURL+"'><param name='ShowStatusBar' value='-1'><PARAM NAME='AutoStart' VALUE='true'><EMBED type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' SRC='"+strURL+"' AutoStart=true width="+intWidth+" height="+intHeight+"></EMBED></OBJECT>";
				break;
			case "rm":
				tmpstr="<OBJECT CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' WIDTH="+intWidth+" HEIGHT="+intHeight+"><PARAM NAME='SRC' VALUE='"+strURL+"'><PARAM NAME='CONTROLS' VALUE='ImageWindow'><PARAM NAME='CONSOLE' VALUE='one'><PARAM NAME=AUTOSTART VALUE=true><EMBED SRC='"+strURL+"' NOJAVA=true CONTROLS=ImageWindow CONSOLE=one WIDTH="+intWidth+" HEIGHT="+intHeight+"></OBJECT><br><OBJECT CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' WIDTH="+intWidth+" HEIGHT=32><PARAM NAME='CONTROLS' VALUE='StatusBar'><PARAM NAME=AUTOSTART VALUE=true><PARAM NAME='CONSOLE' VALUE='one'><EMBED SRC='"+strURL+"' NOJAVA=true CONTROLS=StatusBar CONSOLE=one WIDTH="+intWidth+" HEIGHT=24></OBJECT><br><OBJECT CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' WIDTH="+intWidth+" HEIGHT=32><PARAM NAME='CONTROLS' VALUE='ControlPanel'><PARAM NAME=AUTOSTART VALUE=true><PARAM NAME='CONSOLE' VALUE='one'><EMBED SRC='"+strURL+"' NOJAVA=true CONTROLS=ControlPanel CONSOLE=one WIDTH="+intWidth+" HEIGHT=24 AUTOSTART=true LOOP=false></OBJECT>";
				break;
			case "qt":
				tmpstr="<embed src='"+strURL+"' autoplay=true Loop=false controller=true playeveryframe=false cache=false scale=TOFIT bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>"
		}
		document.getElementById(strID).innerHTML = tmpstr;
	}
}

//Quote Comment Text - SiC/CYAN 2004
function doquote(objID,strAuthor){
	document.inputform.message.value += "[quote="+strAuthor+"] "+document.getElementById(objID).innerText+" [/quote]\n";
	window.location.hash="comment";
}

function showIntro(objID)
{
	if (document.getElementById(objID).style.display == "none") {
		document.getElementById(objID).style.display = "";
	}else{
		document.getElementById(objID).style.display = "none";
	}
}

function Printer(objName)
{
	var Obj;
	Obj = eval(objName);
	if(typeof(Obj)=="object") Obj.style.display = "none";

//eval(objName).style.display = "none";

	window.print();

	//eval(objName).style.display = "block";

	if(typeof(Obj)=="object") Obj.style.display = "block";
}

//根据varValue的值选中option
// selectedOption(document.all.(Name),(Value));
function selectedOption(varObj,varValue)
{
	if(typeof(varObj)=="object")
	{
		for(var lnIndex=0;lnIndex<varObj.length;lnIndex++)
		{
			if(varObj.options[lnIndex].value==varValue)
			{
				varObj.selectedIndex=lnIndex;
				break;
			}
		}
	}
}

// 显示Select Option 并选择默认值 LGW 2007.8.3
function WriteSelectOption(taOptions,tcDefault)
{
	var lnIndex;
	if ( taOptions.length >0)
		with(document)
		{
			for (lnIndex=0; lnIndex<taOptions.length; lnIndex++) {
				write("<option value='"+taOptions[lnIndex][0]+"'");
				if (tcDefault==taOptions[lnIndex][0]||tcDefault==taOptions[lnIndex][1]) write(" selected");
				write(">"+taOptions[lnIndex][1]+"</option>");
			}
		}
}

/** 修剪字串前后的空格 Base 20030820 */
function trim(Str) {
  var count = Str.length;
  var st    = 0;       // start
  var end   = count-1; // end

  if (Str == "") return Str;
  while (st < count) {
    if (Str.charAt(st) == " "||Str.charAt(st) == "　"||escape(Str.charAt(st)) == "%u3000")
      st ++;
    else
      break;
  }
  while (end > st) {
    if (Str.charAt(end) == " "||Str.charAt(end) == "　"||escape(Str.charAt(end)) == "%u3000")
      end --;
    else
      break;
  }
  return Str.substring(st,end + 1);
}
