//===========================================================
// Topbar.js
// by jackzhu  jackzhu@easysite.com.cn jackzhu98@yahoo.com
// Nov,11,1999
// This js file is for creating a dropdown menu 
// other files needed: global.js, menu.js
//===========================================================
var rootURL="/techcenter/";

var HTMLStr="";
var MenuStr="";
var CurrentTitle="";  //IDStr of Current Title
var VisibalTitle="";
var TitleIndex=0;    
var ATitle=0;

var MenuIndex=0;	   //Used for adding Menus
var MenuLeft=106;
var MenuTop=82;

//default TopBanner Properties
var TopBannerBgColor="white";
var TopBannerImg=rootURL + "images/T_TC.jpg";
var TopBannerImgTitle="中科软技术中心";
var SepLine="/global/iamges/blueSepLine.gif";

//default Title Properties
var TitleWidth=80;
var TitleHeight=18;
//var TitleBgColor="#3050CF";
//var TitleActiveBgColor="#3050CF";
var TitleBorderColor1="white";
var TitleBorderColor2="black";
var TitleFontColor="white";
var TitleActiveFontColor="white"

//default Menu Properties
var MenuWidth=100;
var MenuHeight=22;
//var MenuBgColor="#3050CF";
var MenuActiveBgColor=TopBannerBgColor;
var MenuBorderColor1="#000000";
var MenuBorderColor2="#ffffff";
var MenuFontColor="white";
var MenuActiveFontColor="black";


//default MenuPane Properties
var MenuPaneWidth=180;
var MenuPaneBgColor="#ffcc00";
var MenuPaneBorderLeftColor="#ffffff";
var MenuPaneBorderRightColor="black";
var MenuPaneBorderTopColor="white";
var MenuPaneBorderBottomColor="black";



function MakeTitleStr()
{
	TitleStr=
		"<DIV ID='DIV_TitlePane' STYLE='BACKGROUND-COLOR:"+ TitleBgColor +";position:absolute;top:" + MenuTop + ";left:" + MenuLeft +";width:100%;height:" + TitleHeight + ";z_index:6;'>" + newLineChar +
		"<table ID='TABLE_MenuPane' border=0 cellpadding=0 cellspacing=0 width=100% height=20>" + newLineChar +
		"<tr>" + newLineChar +
		"<td width=1><img src='/global/1trans.gif' width=1 height=1></td>" + newLineChar +
		"<!--TOP_TITLES-->" + newLineChar +
		"<td width=100% align=right>" + newLineChar +
		"</td>" + newLineChar +
		"</tr>" + newLineChar +
		"</table>" + newLineChar +
		"</DIV>";
}


function addTitle(TitleIDStr,TitleDisplayStr,TitleURLStr,TitleHelpStr)
{
	if (CurrentTitle=="")
		{
			CurrentTitle=TitleIDStr;  //set TitleIndex for the very first time
			TitleIndex = 0;
			MenuIndex=0;
		}	
	TitleIndex+=1;
	
	tagStr="<!--TOP_TITLES-->";

	srcStr= "<td width=" + TitleWidth + " nowrap align=center>";
		
	if (ATitle>0 && TitleIndex==ATitle)
		{
			srcStr = srcStr + "<a href='" + TitleURLStr + 
							  "' title='" + TitleHelpStr + "' " +
							  "onmouseover=showMenu('" + TitleIDStr + "')>" +	
							  "<SPAN ID='TITLE_" + TitleIDStr + "' " +
							  "CLASS='TitleOff' buttonType='Title'>";
		}	
	else
		{
			srcStr = srcStr + "<a href='" + TitleURLStr + 
							  "' title='" + TitleHelpStr + "' " +
							  "onmouseover=showMenu('" + TitleIDStr + "')>" +	
							  "<SPAN ID='TITLE_" + TitleIDStr + "' " +
							  "CLASS='TitleOff' buttonType='Title'>";
		}
		
	srcStr = srcStr + TitleDisplayStr + "</SPAN></a></td>";

	srcStr  = srcStr + tagStr;

	TitleStr = TitleStr.replace(tagStr, srcStr); //replace TitleStr;
}

function addMenuPane(TitleIDStr)
{
	mLeft=MenuLeft + (TitleIndex-1) * TitleWidth;

	//add a menu pane div for menu
	MenuStr = MenuStr + 
		  "<DIV ID='MENU_" + TitleIDStr + "' class='MenuPane' " +	
		  "STYLE='position:absolute;top:" + (MenuTop+19) + ";left:" + mLeft + ";" +
		  "width:" + MenuWidth + ";z-index:10;background-color:"+MenuBgColor+";" +
		  "display:none;z_index=10;'>" + newLineChar +
		  "<img src='/global/1trans.gif' width=1 height=8><br>" + 
		  "<!--MENU_" + TitleIDStr + "_PANES-->" + newLineChar +
		  "</DIV>"+ newLineChar;
}

function addMenuItem(TitleIDStr,MenuDisplayStr,MenuURLStr,MenuHelpStr)
{
	if (BrowserSupported!=true)
		return;

	if (TitleIDStr==CurrentTitle)  	//if the menu belongs to the same Title as last one
		MenuIndex +=1;		//Increase MenuIndex
	else	
		{
			CurrentTitle=TitleIDStr;  //Update TitleIndex
			MenuIndex=1;		//and reset MenuIndex
			addMenuPane(TitleIDStr);
		}
		
		
	tagStr="<!--MENU_" + TitleIDStr + "_PANES-->";

	srcStr= "<a href='" + MenuURLStr + 
			"' title='" + MenuHelpStr + "'>" +
			"<SPAN ID='MENU_" + CurrentTitle + "_" + MenuIndex + 
			"' class='MenuOff' buttonType='Menu' valign=center>" +
			MenuDisplayStr + "</SPAN></a>";

	srcStr  = srcStr + tagStr;

	MenuStr = MenuStr.replace(tagStr, srcStr); //replace MenuStr;//replace MenuStr;
	
}


function MakeHTMLStr()
{
	HTMLStr = 
	"<table width=300  border=0 cellpadding=0 cellspacing=0 bgcolor=" + TopBannerBgColor + ">"+ newLineChar +
	"<tr>"+ newLineChar +
	"<td rowspan=2 width=400 ></td>"+ newLineChar +
	
	"</td>" + newLineChar +
	"</tr>" + newLineChar +
	"<tr>" + newLineChar +
	"<td width=100%>"+ newLineChar +
	TitleStr +
	"</td>" + newLineChar +
	"</tr>" + newLineChar +
	"</table>" + newLineChar +
	MenuStr;
}

		 
function WriteStyle()
{
StyleStr="<style TYPE='text/css'>"+ newLineChar +
		 "<!--"+ newLineChar +
		 "UL			{margin-top: 0pt}"+ newLineChar +
		 "a				{text-decoration:none;FONT-FAMILY: 宋体;font-size:9pt}"+ newLineChar +
		 "a:hover		{color:red; text-decoration:underline}"+ newLineChar +
		 ".normal       {Font-family:宋体;font-size:9pt;}"+
		 ".CurrentMenu  {Font-family:宋体;font-size:9pt;color:black;}"+
		 ".MenuPane"+ newLineChar +
		 "{"+ newLineChar +
		 "  WIDTH: " + MenuPaneWidth + ";" + newLineChar +
		 "	BACKGROUND: " + MenuPaneBgColor + ";" +  newLineChar +
		 "	BORDER-LEFT: " + MenuPaneBorderLeftColor + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + MenuPaneBorderRightColor + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + MenuPaneBorderTopColor + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + MenuPaneBorderBottomColor + " solid 1px;"+ newLineChar +
		 "	PADDING-TOP: 0px;"+ newLineChar +
		 "	PADDING-LEFT: 3px;"+ newLineChar +
		 "	PADDING-RIGHT: 3px;"+ newLineChar +
		 "	PADDING-BOTTOM: 3px;"+ newLineChar +		 
		 "  } "+ newLineChar +
		 //========================ATitleOff==========================
		 "  .ATitleOff"+ newLineChar +  
		 "  {"+ newLineChar +
		 "  WIDTH: " + TitleWidth + ";" + newLineChar +
		 "  HEIGHT: " + TitleHeight + ";" + newLineChar +
		 " 	BACKGROUND-COLOR: " + TopBannerBgColor + ";" + newLineChar +
		 "	BORDER-LEFT: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	CURSOR: hand;"+ newLineChar +		 
		 "	COLOR: "+ "black" + ";"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +		 
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 2px;"+ newLineChar +
		 "  }"+ newLineChar +
		 //========================ATitleUp==========================
		 "  .ATitleUp"+ newLineChar +  
		 "  {"+ newLineChar +
		 "  WIDTH: " + TitleWidth + ";" + newLineChar +
		 "  HEIGHT: " + TitleHeight + ";" + newLineChar +
		 " 	BACKGROUND-COLOR: " + TopBannerBgColor + ";" + newLineChar +
		 "	BORDER-LEFT: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + TopBannerBgColor + " solid 1px;"+ newLineChar +
		 "	CURSOR: hand;"+ newLineChar +		 
		 "	COLOR: "+ "black" + ";"+ newLineChar +
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 2px;"+ newLineChar +
		 "  }"+ newLineChar +
		//========================TitleOff==========================
		 "  .TitleOff"+ newLineChar +
		 "  {"+ newLineChar +
		 "  WIDTH: " + TitleWidth + ";" + newLineChar +
		 "  HEIGHT: " + TitleHeight + ";" + newLineChar +
		 "	COLOR: "+ TitleFontColor + ";"+ newLineChar +
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +		 
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 2px;"+ newLineChar +
		 "  }"+ newLineChar +
		 //========================TitleUp==========================
		 "  .TitleUp"+ newLineChar +
		 "  {"+ newLineChar +
		 "  WIDTH: " + TitleWidth + ";" + newLineChar +
		 "  HEIGHT: " + TitleHeight + ";" + newLineChar +
		 "  BACKGROUND-COLOR: " + TitleActiveBgColor + ";" + newLineChar +
		 "	COLOR: "+ TitleActiveFontColor + ";"+ newLineChar +
		 "	CURSOR: hand;"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +		 
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 2px;"+ newLineChar +
		 "  }"+ newLineChar +
		 //========================TitleDown==========================
		 "  .TitleDown"+ newLineChar +
		 "  {"+ newLineChar +
		 "  WIDTH: " + TitleWidth + ";" + newLineChar +
		 "  HEIGHT: " + TitleHeight + ";" + newLineChar +
		 "  BACKGROUND-COLOR: " + TitleFontColor + ";" + newLineChar +
		 "	BORDER-LEFT: " + TitleFontColor + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + TitleFontColor + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + TitleFontColor + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + TitleFontColor + " solid 1px;"+ newLineChar +
		 "	COLOR: "+ TitleBgColor + ";"+ newLineChar +
		 "	CURSOR: hand;"+ newLineChar +
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 2px;"+ newLineChar +
		 "  }"+ newLineChar +
		 //========================MenuOff==========================
		 "  .MenuOff"+ newLineChar +
		 "  {"+ newLineChar +
		 "  WIDTH:" + MenuWidth + ";" + newLineChar +
		 "  HEIGHT:" + MenuHeight + ";" + newLineChar +
 		 " 	BACKGROUND-COLOR: " + MenuBgColor + ";" + newLineChar +
		 "	BORDER-BOTTOM: " + MenuBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-LEFT: " + MenuBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + MenuBgColor + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + MenuBgColor + " solid 1px;"+ newLineChar +
		 "	COLOR: " + MenuFontColor + ";"+ newLineChar +
		 "	CURSOR: hand;"+ newLineChar +
		 "	FONT-FAMILY: 宋体;"+ newLineChar +
		 "	FONT-SIZE: 9pt;"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	PADDING-LEFT: 10px;"+ newLineChar +
		 "	PADDING-TOP: 3px;"+ newLineChar +
		 "  }"+ newLineChar +
		 //========================MenuUp==========================
		 "  .MenuUp"+ newLineChar +
	     "  {"+ newLineChar +
		 "  WIDTH:" + MenuWidth + ";" + newLineChar +
		 "  HEIGHT:" + MenuHeight + ";" + newLineChar +
		 "	COLOR: " + MenuActiveFontColor + ";"+ newLineChar +
   		 "	CURSOR: hand;"+ newLineChar +
		 " 	BACKGROUND-COLOR: " + MenuActiveBgColor + ";" + newLineChar +
		 "	BORDER-LEFT: " + MenuBorderColor1 + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + MenuBorderColor2 + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + MenuBorderColor1 + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + MenuBorderColor2 + " solid 1px;"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 3px;"+ newLineChar +
		 "	PADDING-LEFT: 10px;"+ newLineChar +
		 "	}"+ newLineChar +
		 //========================MenuDown==========================
		 "	.MenuDown"+ newLineChar +
		 "	{"+ newLineChar +
		 "  WIDTH:" + MenuWidth + ";" + newLineChar +
		 "  HEIGHT:" + MenuHeight + ";" + newLineChar +
		 "	COLOR: " + MenuActiveFontColor + ";"+ newLineChar +
   		 "	CURSOR: hand;"+ newLineChar +
		 " 	BACKGROUND-COLOR: " + TopBannerBgColor + ";" + newLineChar +
		 "	BORDER-LEFT: " + MenuBorderColor2 + " solid 1px;"+ newLineChar +
		 "	BORDER-RIGHT: " + MenuBorderColor1 + " solid 1px;"+ newLineChar +
		 "	BORDER-TOP: " + MenuBorderColor2 + " solid 1px;"+ newLineChar +
		 "	BORDER-BOTTOM: " + MenuBorderColor1 + " solid 1px;"+ newLineChar +
		 //"	FONT-WEIGHT: bold;"+ newLineChar +
		 "	LETTER-SPACING: 0pt;"+ newLineChar +
		 "	TEXT-DECORATION: none;"+ newLineChar +
		 "	PADDING-TOP: 3px;"+ newLineChar +
		 "	PADDING-LEFT: 10px;"+ newLineChar +
		 "	}"+ newLineChar +
		 "	-->"+ newLineChar +
		 "</style>";		 

		document.write (StyleStr);
}





function showMenu(TitleIDStr)
{
	menuID="MENU_" + TitleIDStr;
	
	hideMenu();
		
	VisibalTitle=menuID;
	
	thisMenu = document.all(menuID);
	if (thisMenu != null)
			thisMenu.style.display = "";
}

function hideMenu()
{
	if (VisibalTitle=="")
	 		return;
	 		
	thisMenu = document.all(VisibalTitle);
	
	VisibalTitle="";
	if (thisMenu != null)
			thisMenu.style.display = "none";
}

//====================================================
function ShowTopBanner()
{
	WriteStyle();
	MakeTitleStr();
	LoadMenu();
	MakeHTMLStr();
	document.write (HTMLStr);
}
//=====================================================



BodyStr="<BODY bgcolor='white' leftmargin=0 rightmargin=0 topmargin=0 link=#993333 vlink=#cc6600 onmousedown='DepressButton();' ONMOUSEOVER='RaiseButton();' ONMOUSEUP='RaiseButton();'>";
document.write (BodyStr);

var oLastBtn=0;

function RaiseButton()
{
		window.event.cancelBubble=true;
		oBtn = window.event.srcElement;
		
		SrcID=oBtn.id;
		
		if (!(SrcID.indexOf("TITLE_")==0 || SrcID.indexOf("MENU_")==0))
			hideMenu();
		
		var bChosen = false;

		if(oLastBtn && oLastBtn != oBtn)
			HideButton();
		
		if(oBtn.buttonType)
		{
			oBtn.className = oBtn.buttonType + "Up";
			oLastBtn=oBtn;
		}
		else 
			oLastBtn = 0;
}

function DepressButton()
{
		window.event.cancelBubble=true;
		oBtn = window.event.srcElement;
		if(oBtn.buttonType)
			oBtn.className = oBtn.buttonType + "Down"; 
}

function HideButton()
{
		oLastBtn.className = oLastBtn.buttonType + "Off";
}




//======Set=============================================================

function SetTopBanner(newTopBannerImg,newTopBannerImgTitle,newTopBannerBgColor)
{
	if (newTopBannerImg!="")
			TopBannerImg=newTopBannerImg;
	if (newTopBannerImgTitle!="")
			TopBannerImgTitle=newTopBannerImgTitle;
	if (newTopBannerBgColor!="")
			TopBannerBgColor=newTopBannerBgColor;	
}

function SetTitleColor(BgColor,ActiveBgColor,FontColor,ActiveFontColor,BorderColor1,BorderColor2)
{
	if (BgColor!="")
		TitleBgColor=BgColor;
	if (ActiveBgColor!="")
		TitleActiveBgColor=ActiveBgColor;
	if (FontColor!="")
		TitleFontColor=FontColor;
	if (ActiveFontColor!="")
		TitleActiveFontColor=ActiveFontColor;
	if (BorderColor1!="")
		TitleBorderColor1=BorderColor1;
	if (BorderColor2!="")
		TitleBorderColor2=BorderColor2;
}

function SetMenuColor(BgColor,ActiveBgColor,FontColor,ActiveFontColor,BorderColor1,BorderColor2)
{
	if (BgColor!="")
		MenuBgColor=BgColor;
	if (ActiveBgColor!="")
		MenuActiveBgColor=ActiveBgColor;
	if (FontColor!="")
		MenuFontColor=FontColor;
	if (ActiveFontColor!="")
		MenuActiveFontColor=ActiveFontColor;
	if (BorderColor1!="")
		MenuBorderColor1=BorderColor1;
	if (BorderColor2!="")
		MenuBorderColor2=BorderColor2;
}

function SetATitle(ATitleNum)
{
	if (ATitleNum>0)
		ATitle=ATitleNum;
}