if (!message) var message = "";


		
window.onerror = new Function("return true")

var bgColor;
var rollbgColor;

var mainPaneTopY = 0;
var mainPaneHeight = 25;
var mainPaneBorder = 0;
var subMenuPaneTopY = 26;
var subMenuPaneWidth = 72;
var subMenuPaneBorder = 0;

var leftX	= 0;
var rightX	= 0;
var topY	= 0;
var buttonY	= 0;

var lastMenu	= null;

bgColor	= "#5B63BD";
rollbgColor = "#3544B2";

function Menu()
{
	this.addItem	= addItem;
	this.addSubItem	= addSubItem;
	this.showMenu	= showMenu;

	HTMLstr = "";
	HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
	HTMLstr += "\n";
	HTMLstr += "<div id='MainTable' style='z-index:500'>\n";
	//HTMLstr += "<table width='100%' height="+mainPaneHeight+" bgcolor='"+bgColor+"' border='"+mainPaneBorder+"' cellspacing=0 cellpadding=0>\n";
	HTMLstr += "<table width='100%' height=" + mainPaneHeight + " cellspacing=0 cellpadding=0>\n";
	HTMLstr += "<tr>\n\n";
	HTMLstr += "<!-- MAIN MENU STARTS -->\n";
	HTMLstr += "<!-- MAIN_MENU -->\n";
	HTMLstr += "<!-- MAIN MENU ENDS -->\n";
	HTMLstr += "<td width=0 style='padding-top:0;cursor:hand' onmouseover=\"hideAll()\"></td>\n";
	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	HTMLstr += "\n";
	HTMLstr += "<!-- SUB MENU STARTS -->\n";
	HTMLstr += "<!-- SUB_MENU -->\n";
	HTMLstr += "<!-- SUB MENU ENDS -->\n";
	HTMLstr += "\n";
	HTMLstr+= "</div>\n";
	HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";
}

function addItem(idItem, text, hint, location, altLocation, MenuItemWidth)
{
	var MENUitem = "";
	MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
	MENUitem += "<td width="+MenuItemWidth+" style='padding-top:0'>\n";
	MENUitem += "<div id='"+idItem+"' style='position:relative' noWrap>\n";
	
	if (location != null) //HOME
	{
		MENUitem += "<a class=MenuItemHome ";
		MENUitem += "href='"+location+"' ";
		MENUitem += "onmouseover=\"hideAll()\" ";
		if (hint != null) MENUitem += "title='"+hint+"' ";
		if (altLocation != null) MENUitem += "target='"+altLocation+"' ";
		MENUitem += ">";
		//MENUitem += "|\n";
	}
	else
	{
		if (hint == null) //Message
		{
			MENUitem += "<a class=MenuItemMsg>";
			MENUitem += "&nbsp;\n";
			
		}
		else 
		{
			MENUitem += "<a class=MenuItem ";
			MENUitem += "href='" + altLocation + "' ";
			MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"');\" ";
			if (hint != null) MENUitem += "title='"+hint+"' ";
			MENUitem += ">";
		}
	}
	MENUitem += text;
	MENUitem += "</a>\n";
	MENUitem += "</div>\n";
	MENUitem += "</td>\n";
	MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
	MENUitem += "<!-- MAIN_MENU -->\n";

	HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}

function addSubItem(idParent, text, hint, location, target)
{
	var MENUitem = "";
	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		MENUitem += "\n";
		MENUitem += "<div id='"+idParent+"submenu' style='clip:auto;position:absolute; visibility: hidden; width: "+subMenuPaneWidth+";border-top:1 solid #3544B2;border-right:1 solid #3544B2;border-left:1 solid #3544B2;border-bottom:1 solid #3544B2;top:-500;z-index:"+Math.floor(Math.random() * 10000)+"'>\n";
		MENUitem += "<table border='"+subMenuPaneBorder+"' bgcolor='"+bgColor+"' width="+subMenuPaneWidth+" cellspacing=0 cellpadding=2>\n";
		MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
		MENUitem += "</table>\n";
		MENUitem += "</div>\n";
		MENUitem += "\n";
		MENUitem += "<!-- SUB_MENU -->\n";
		HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
	}

	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
	if (location == "")
	{
		MENUitem = "<tr><td style='padding-left:9;padding-top:2;'><a class=subMenuItem>"+text+"</a><br></td></tr>\n";
	}
	else
	{
                
		if (target == 1) 
                {
                  target = "_NEW";
                }
                else
                {
                   if (target == 2) 
                   {
                      target = "_parent";
                   }
                   else
                   {
                      target = "";
                   }
                }
		MENUitem = "<tr><td style='cursor:hand;padding-left:9;padding-top:2;'><a title='"+hint+"' href='"+location+"' target='"+target+"' onmouseover='document.all[eval(this.sourceIndex-1)].bgColor=\""+rollbgColor+"\";' onmouseout='document.all[eval(this.sourceIndex-1)].bgColor=\"\"'><font  class=subMenuItem>"+text+"</font></a><br></td></tr>\n";
	}
	MENUitem += Lookup;
	HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}

function showMenu()
{
	document.writeln(HTMLstr);

	centerDiv();
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
	document.body.onmousemove=updateIt;
}

function centerDiv()
{
	if (document.all.theCenter){
		for(i=0;i<document.all.length;i++){
			if(document.all[i].tagName=="DIV"){
				if(document.all[i].style.position=="absolute"){
					if(parseInt(document.all[i].style.left)) document.all[i].style.left=parseInt(document.all[i].style.left)+parseInt(document.all.theCenter.offsetLeft);
				}
			}
		}
	}
}

function displaySubMenu(idMainMenu)
{
	var menu;
	var submenu;

	menu = eval(idMainMenu);
	submenu = eval(idMainMenu+'submenu.style');
	submenu.left = calculateTotalOffset(menu, 'offsetLeft')+4;
	submenu.top  = calculateTotalOffset(menu, 'offsetTop')+subMenuPaneTopY;
	submenu.visibility = "visible";
	if (lastMenu != null && lastMenu != submenu) hideAll();

	var tmpleftX = calculateTotalOffset(menu, 'offsetLeft');
	var tmptopY = calculateTotalOffset(menu, 'offsetTop');

	leftX	= tmpleftX-30;
	rightX	= tmpleftX+subMenuPaneWidth+30;
	topY	= 0; //tmptopY-50;
	buttonY	= tmptopY+parseInt(eval(idMainMenu+'submenu.offsetHeight'))+50;

	lastMenu = submenu;
}

function hideAll()
{
	if (lastMenu != null) {lastMenu.visibility = "hidden";lastMenu.left = 0;}
}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	totalOffset += eval('item.'+offsetName);
	item = eval('item.offsetParent');
	totalOffset += eval('item.'+offsetName);
	item = eval('item.offsetParent');
	return totalOffset;
}

function calculateTotalOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function updateIt()
{
		var x = window.event.clientX;
		var y = window.event.clientY;
	
		if (x > rightX || x < leftX) hideAll();
		if (y > buttonY || y < topY) hideAll();
//		else if (y > rightY) hideAll();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function adpower(C,N,S) {
	document.body.insertAdjacentHTML('AfterEnd','<iFRAME WIDTH=0 HEIGHT=0 src=\"http://fcfive.fcwin.com.tw/adcount.asp?C='+C+'&N='+N+'&S='+S+'\"><\/iFRAME>')
}

function RecomMail(){
	if (navigator.appVersion.indexOf("IE")>0)
		window.open("email.asp?"+location,null,"height=280,width=350,top=50,left=50,status=no,toolbar=no,menubar=no,location=no");
	else
		alert("抱歉 ! 你不是使用 Internet Explorer ,\n無法使用此功能 !!\n 我們誠心建議您改用 IE5 !!");
}
