﻿
// -------------------------------------------------------------    Variable for Common Function for Login Menu -----------------------------------------



var loginLeftMenuSectionImageOut = ".gif";

var loginLeftMenuSectionImageOver = "_over.gif";

var loginLeftMenuName = "loginMainMenu";

var loginLeftMenuImageName = "loginMainMenu";

var loginLayerCommonName = "loginPopup";

var loginMenuFlag = false;

var loginFirstLayerFlag = false;

var loginFirstLayerTimerID;

var loginActiveLeftMenuID = "";

var mainTopicNo;

var loginMainTopic = selectedSection;



var loginLayer = new Array()

var loginLayer2 = new Array()



// -------------------------------------------------------------    End of Variable for Common Function for Left Menu -----------------------------------------

// -------------------------------------------------------------    Variable for Common Function for First Level Layers-----------------------------------------



var loginfirstLayerImagesFlag = false;

var loginSecondLayerFlag = false;

var activeLoginFirstLayerImageID = "";

var activeLoginSecondLayerID = "";

var loginSecondLayerTimerID;

var subTopic = "";



var loginSecondLayer = new Array()

var loginSecondLayer2 = new Array()



// -------------------------------------------------------------    End of Variable for Common Function for First Level Layers -----------------------------------------

// -------------------------------------------------------------    Common Function for Left Menu -----------------------------------------



function loginDoShowMenu(imgName)

{

	var iconNo = parseInt(imgName);

	//(iconNo<8)?iconNo='0'+iconNo:iconNo=iconNo;

	

	//if (imgName==0){imgName=99;}

	//alert('loginMainTopic: '+ loginMainTopic + '  imgName: '+ imgName + 'loginMenuFlag: ' + loginMenuFlag);

	if(loginMainTopic != imgName && !loginMenuFlag)

	//if(!loginMenuFlag)

	

	{

//		alert (loginLeftMenuName+imgName);

		document.images[loginLeftMenuName+imgName].src=document.images[loginLeftMenuName+imgName].src.replace(loginLeftMenuSectionImageOut, loginLeftMenuSectionImageOver)

		loginMenuFlag = true;

	}

	if (!loginFirstLayerFlag)

	{

		loginMM_showHideLayers(loginLayerCommonName+iconNo,'','show');

		loginFirstLayerFlag=true;

	}

	loginActiveLeftMenuID = imgName

}



function loginLeftMenuMouseOver(imgName) 

{

	//alert('loginActiveLeftMenuID : '+loginActiveLeftMenuID);

	//alert('imgName : '+imgName)

	if (loginActiveLeftMenuID == imgName)

	{

		//alert('leftMenuMouseOver_1st_if')

		if (loginFirstLayerTimerID) clearTimeout(loginFirstLayerTimerID);

		loginFirstLayerTimerID = null;

	}

	else

	{

		//alert('leftMenuMouseOver_1st_else')

		if (loginFirstLayerTimerID) clearTimeout(loginFirstLayerTimerID);

		loginFirstLayerTimerID = null;

		if (loginActiveLeftMenuID!=""){loginDoHideMenu(loginActiveLeftMenuID);}

		loginDoShowMenu(imgName);

//		alert ("Hiya");

	}

}



function loginDoHideMenu(imgName)

{

	var iconNo = parseInt(imgName);

	//(iconNo<8)?iconNo='0'+iconNo:iconNo=iconNo;

	//if(true)

	//if (imgName==0){imgName=99;}

	

	if(loginMainTopic != imgName)

	{

		document.images[loginLeftMenuName+imgName].src=document.images[loginLeftMenuName+imgName].src.replace(loginLeftMenuSectionImageOver, loginLeftMenuSectionImageOut)

		loginMenuFlag = false;

	}

	if (loginFirstLayerFlag)

	{

		loginMM_showHideLayers(loginLayerCommonName+iconNo,'','hide')

		loginFirstLayerFlag=false;

	}

	loginActiveLeftMenuID = "";

}



function loginLeftMenuMouseOut(imgName) {

	

	if (loginActiveLeftMenuID == imgName)

	{

		loginFirstLayerTimerID = setTimeout("loginDoHideMenu('"+imgName+"')", 500);

	}

	else

	{

		loginDoHideMenu(imgName);

	}

}



// -------------------------------------------------------------   End of Common Function for Left Menu -----------------------------------------

// -------------------------------------------------------------    Common Function for First Level Layers -----------------------------------------



function loginDoShowLayer(imgName, layerName)

{

	//var tempLayerName = layerName.substring(0, (layerName.length-2))

	var tempLayerName = layerName

	var tempLayer = "";

	var tempImage = "";

	var tempPath = "";

	if(subTopic != imgName && !loginfirstLayerImagesFlag)

	//if(!loginMenuFlag)

	{

		if(document.layers) //netscape 4.x version

		{

			tempLayer = document.layers[tempLayerName].document;

			tempImage = tempLayer.images[imgName];

			tempImage.src=tempImage.src.replace(loginLeftMenuSectionImageOut, loginLeftMenuSectionImageOver)

		}

		else

		{

			//alert (imgName);

			var tempImgName = 'loginMenu'+selectedSection+'_'+selectedSubSection;

			//alert (tempImgName);

			if (imgName != tempImgName){

				document.images[imgName].src=document.images[imgName].src.replace(loginLeftMenuSectionImageOut, loginLeftMenuSectionImageOver)

			}

		}

		

		loginfirstLayerImagesFlag = true;

	}

	if (!loginSecondLayerFlag )

	{

		//loginMM_showHideLayers(layerName,'','show');

		loginSecondLayerFlag =true;

	}

	activeLoginFirstLayerImageID = imgName

	activeLoginSecondLayerID = layerName

}



function loginFirstLayerMouseOver(imgName, layerName) 

{

	if (activeLoginFirstLayerImageID == imgName && activeLoginSecondLayerID == layerName)

	{

		if (loginSecondLayerTimerID) clearTimeout(loginSecondLayerTimerID);

		loginSecondLayerTimerID = null;

	}

	else

	{

		if (loginSecondLayerTimerID) clearTimeout(loginSecondLayerTimerID);

		loginSecondLayerTimerID = null;

		if (activeLoginFirstLayerImageID!=""){loginDoHideLayer(activeLoginFirstLayerImageID, activeLoginSecondLayerID);}

		loginDoShowLayer(imgName, layerName)	

	}

}



function loginDoHideLayer(imgName, layerName)

{

	//var tempLayerName = layerName.substring(0, layerName.length-2)

	var tempLayerName = layerName

	var tempLayer = "";

	var tempImage = "";

	//if(true)

	if(subTopic != imgName)

	{

		if(document.layers) //netscape 4.x version

		{

			tempLayer = document.layers[tempLayerName].document;

			tempImage = tempLayer.images[imgName];

			tempImage.src=tempImage.src.replace(loginLeftMenuSectionImageOver, loginLeftMenuSectionImageOut)

		}

		else

		{

			var tempImgName = 'loginMainMenu'+selectedSection+'_'+selectedSubSection;

			//alert (tempImgName);

			if (imgName != tempImgName){

				document.images[imgName].src=document.images[imgName].src.replace(loginLeftMenuSectionImageOver, loginLeftMenuSectionImageOut)

			}

			

		}

		

		loginfirstLayerImagesFlag = false;

	}

	if (loginSecondLayerFlag )

	{

		//loginMM_showHideLayers(layerName,'','hide')

		loginSecondLayerFlag =false;

	}

	activeLoginFirstLayerImageID = "";

	activeLoginSecondLayerID = "";

}



function loginFirstLayerMouseOut(imgName, layerName) {

	

	if (activeLoginFirstLayerImageID == imgName && activeLoginSecondLayerID == layerName)

	{

		loginSecondLayerTimerID = setTimeout("loginDoHideLayer('"+imgName+"', '"+layerName+"')", 500);

	}

	else

	{

		loginDoHideLayer(imgName, layerName);

	}

}



// -------------------------------------------------------------   End of Common Function for First Level Layers -----------------------------------------

// -------------------------------------------------------------   Top Menu Layer script ---------------------------------------------------------------------------

//var left_menu_img_path='/file_manager/tc/../whp_images/whp_pl_template/left_menu/';

var topOffSet=163+8; //position + icon top

var leftOffSet=0;



//only using in chineses verison for replace the dummy space between the character

function loginReplaceSpace(str) {

	var retStr=str;

	for (var i=0; i<str.length-1; i++) {

		retStr = retStr.replace(' ','');

	}

	return retStr;

}



function loginGetDim(el){

	for (var lx=0,ly=0;el!=null;

		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);

	return {x:lx,y:ly}

}



function loginMoveDivs(layerObj, inObjTop, inObjLeft){

layerObj.top  = inObjTop - 1;

layerObj.left  = inObjLeft;

}



function loginSetLayerPosition()

{

	//alert ('hello');

	for (var i=0; i<3; i++)

	{

//		alert (i);

		 if (document.all){loginMoveDivs(document.all['loginPopup'+i].style, loginGetDim(document.images['loginMainMenu'+i]).y, loginGetDim(document.images['loginMainMenu'+i]).x+191);}

		 if (document.layers){loginMoveDivs(document.layers['loginPopup'+i], document.images['loginMainMenu'+i].y, document.images['loginMainMenu'+i].x+191);}

		 if (!document.all && document.getElementById) {loginMoveDivs(document.getElementById('loginPopup'+i).style, document.images['loginMainMenu'+i].y, document.images['loginMainMenu'+i].x+191);}

//		 alert ('finished : ' +i);

	}

} 



function loginGetLayer()

{

	var scriptBuffer='';

	var isOver='';

	var iconNo = '';

	var subIconNo = '';

	

	for (var i=0; i<LoginSection[langNo].length; i++){

		iconNo = parseInt(i);

		if (document.layers)

		{document.writeln('<layer name="loginPopup'+i+'" top=0 left=0 width=90 height=58 visibility="hide" onMouseOver="loginLeftMenuMouseOver(\''+i+'\')" onMouseOut="loginLeftMenuMouseOut(\''+i+'\')">');}

		else

		{document.writeln('<div id="loginPopup'+i+'" style="position:absolute; left:0; top:0; width:90; height:58; z-index:2; visibility: hidden;">');}

		

		document.writeln('<table width="90" border="0" alt="" cellspacing="1" cellpadding="0" onMouseOver="loginLeftMenuMouseOver(\''+i+'\')" onMouseOut="loginLeftMenuMouseOut(\''+i+'\')" bgcolor="#9E9E9E">');



		for (var j=1; j< LoginSubSection[langNo][i].length; j++) {

			subIconNo = parseInt(j);

			//(subIconNo<10)?subIconNo='0'+subIconNo:subIconNo=subIconNo;

			document.writeln('<tr><td height="23"><table cellpadding="2" cellspacing="0" border="0" width="100%" height="100%">');

			document.writeln('<tr valign="top">');

			document.writeln('<td width="100%" class="layer" id="loginTd'+i+j+'" bgcolor="#E8E8E8"><a href="'+LoginSubSection[langNo][i][j]+'" onmouseout="restoreColor(\'loginTd'+i+j+'\', \'loginFont'+i+j+'\'); firstLayerMouseOut(\''+loginLeftMenuName+i+'_'+j+'\', \''+loginLayerCommonName+iconNo+subIconNo+'\');" onmouseover="changeColor(\'loginTd'+i+j+'\', \'loginFont'+i+j+'\');firstLayerMouseOver(\''+loginLeftMenuName+i+'_'+j+'\', \''+loginLayerCommonName+iconNo+subIconNo+'\');"><img src="../whp_images/whp_pl_template/spacer.gif" width="100%" height="1" name="'+loginLeftMenuName+i+'_'+j+'" border="0"><br><font id="loginFont'+i+j+'" color="#545454">'+LoginSubSectionTitle[langNo][i][j]+'<img src="../whp_images/whp_pl_template/spacer.gif" width="1" height="1" align="right" name="'+loginLeftMenuName+i+'_'+j+'" border="0"></font></a></td>');

			document.writeln('</tr>');

			document.writeln('</table></td></tr>');

		}





		document.writeln('</table>');

		

		if (document.layers)

		{document.writeln('</layer>');}

		else

		{document.writeln('</div>');}

	}

	



}



function loginMM_showHideLayers() { //v6.0

  var i,p,v,obj,args=loginMM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=loginMM_findObj(args[i]))!=null) { v=args[i+2];

    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

    obj.visibility=v; }

}





function loginMM_findObj(n, d) { //v4.01

  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=loginMM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



// -------------------------------------------------------------   End of Top Menu Layer script -----------------------------------------------------------------







function loginSimg(obj,src)

{

        if (document.images){

                obj.src = src;

        }

}



function loginMM_openBrWindow(theURL,winName,features) { //v2.0

  if(isText) theURL="ht"+"tp://"+graphicPath+updatePath(folderPath+theURL);

  window.open(theURL,winName,features);

}



function loginMM_jumpMenu(targ,selObj,restore){ //v3.0

  var tempPath = "";

  if(isText) {tempPath=locationPath+folderPath;}

  eval(targ+".location='"+tempPath+selObj.options[selObj.selectedIndex].value+"'");

  if (restore) selObj.selectedIndex=0;

}



function getloginMenu(){

	//var scriptBuffer='';

	var isOver='';



	document.writeln('<table cellpadding="0" cellspacing="0" width="100%" border="0">');

	document.writeln('<tr><td><img src="../whp_images/whp_pl_template/c_left_hd_login.gif" width="191" height="22" alt="登入" border="0"></td></tr>');

	for (var i=0; i<LoginSection[langNo].length; i++){

		document.write('<tr><td><a href="'+LoginSection[langNo][i]+'" onmouseout="loginLeftMenuMouseOut(\''+i+'\')" onmouseover="loginLeftMenuMouseOver(\''+i+'\')"><img src="../whp_images/whp_pl_template/c_login'+i+'.gif" name="loginMainMenu'+i+'" border="0" alt="'+LoginTitle[langNo][i]+'"></a></td></tr>')

	}

	document.writeln('</table>');

}

