﻿var HmenuPrefix ='AirIndiaHMenu1_';
/**
* FILENAME: singair_2_0.js
* DESCRIPTION :Common Javascript code for SIA Project
* AUTHOR: Prakash Prabhu and Dan Ruspini
**/
/*
 *  General Cross Browser Java Script Function 
 */
//++
// cross browser get object by id or name.  if the name is
// not a string, it is passed by unchanged since it can't be an id.
// if it is a string, it tries DOM first, then IE 4/5 then Netscape 4
// if forceIEBehavior is true and the getElementById
// fails, routine will try to find a name instead of IE
//--
function getObj( name, forceIEBehavior )
{
    var newObj;
    if ( typeof name == "string" ) 
    {
        if (document.getElementById) 
        {
            newObj = document.getElementById(name);
            
            if ( newObj == null && forceIEBehavior != null & forceIEBehavior ) 
            {
                var newObjArray = document.getElementsByName( name );
                if ( newObjArray != null && newObjArray.length > 0 ) 
                    newObj = newObjArray[ 0 ];
            }else
            {
                var newObjArray = document.getElementsByName( name );
                if ( newObjArray != null && newObjArray.length > 0 ) 
                    newObj = newObjArray[ 0 ];
            }
        }
        else if (document.all) 
        {
            newObj = document.all[name];
        }
        else if (document.layers) 
        {
            newObj = document.layers[name];
        }
    }
    else
        newObj = name;
        
    return newObj;
}


//++
// cross browser get all objects with the same name in an array.
// tries DOM first, then IE 4/5 then Netscape 4
//--
function getObjArray( name )
{
    var newObjArray;
    if ( typeof name == "string" ) {
        if (document.getElementById) {
			 newObjArray = document.getElementsByName(name);
        }
        else if(document.getElementsByName)
            newObjArray = document.getElementsByName(name);
        else if (document.all)
            newObjArray = document.all[name];
        else if (document.layers)
            newObjArray = document.layers[name];
    }
    else
        newObjArray = name;
    return newObjArray;
}
//++
// cross browser update inner HTML object
// --
function doUpdateHtml(obj,text) {
	if(obj.innerHTML != null)
		obj.innerHTML = text;
	else if(obj.insertAdjacentHTML != null) {
		obj.insertAdjacentHTML("beforeEnd",text);
	}
	else if(document.createElement != null) {
	
	}
}
function doUpdateText(obj,text) {
	if(obj.innerText != null)
		obj.innerText = text;
	else if(obj.innerHTML != null)
		obj.innerHTML = text;
	else if(obj.insertAdjacentHTML != null) {
		obj.insertAdjacentHTML("beforeEnd",text);
	}
	else if(document.createElement != null) {
	}
}
function doGetText(obj) {
	if(obj.innerText != null)
		return obj.innerText;
	else if(obj.innerHTML != null)
		return obj.innerHTML;
}


//++
// cross browser get style object by id or name.
// tries DOM first, then IE 4/5 then Netscape 4
// if forceIEBehavior is true and the getElementById
// fails, routine will try to find a name instead of IE
//--
function getStyle( name, forceIEBehavior )
{
    var myObj = getObj( name, forceIEBehavior );
    return myObj == null ? null : myObj.style;
}

//++
// cross browser routine to hide an element
//--
function hideElement( name )
{
	if ( document.getElementById )
	{
		getStyle( name ).visibility="hidden";
		getStyle( name ).display="none";
	}
	else if ( document.layers )
	{
		getObj( name ).visibility = "hide";
	}
}

//++
// cross browser routine to show an element
//--
function showElement( name )
{   
    if ( document.getElementById )
    {
        getStyle( name ).display="block";
	    getStyle( name ).visibility="visible"
    }
    else if ( document.layers )
    {
        getStyle( name ).display="none";
	    getObj( name ).visibility = "show";
    }
}

//++
// cross browser routine to hide/show an element
//--
function menuElementStatus( name )
{
	if ( document.getElementById ){
		if(getStyle( name ).visibility == "visible")
			return true
		else
			return false
	}else if ( document.layers ){
		if(getObj( name ).visibility == "show")
			return true
		else
			return false
	}
}



/*
 *  Menus and Navigation
 */
var currentlyHovering_Main = false;

function doMenu(pId,pEvt) {
    currentlyHovering = true;
    var pEvent= (window.event) ? window.event : pEvt;
    
    if (window.event)event.cancelBubble=true;
	else if (pEvent.stopPropagation)pEvent.stopPropagation()

    setTimeout('doPopulateCheck('+pId+','+(pEvent.type=="click")+','+(pEvent.type=="mouseover")+')',500);
}

function doPopulateCheck(pId,pblnClickStatus,pblnmouseoverStatus) {

    if (!currentlyHovering_Main){
        doPopulateMenu(pId,pblnClickStatus,pblnmouseoverStatus);
    }
}

function doHideMenus(){
	var objSubMenu;
	for (i=0;i<9;i++) 
	{
		objSubMenu ='menuItem' + i.toString();
		if(getObj(objSubMenu))
		{
			if (menuElementStatus( objSubMenu ) )
			{
				hideElement( objSubMenu );
				var navElement = getObj(HmenuPrefix+'navItem' + i.toString());
				if (navElement != null) 
				{
						if (navElement.className.indexOf("On") != -1) 
						navElement.className = navElement.className.substring(0, (navElement.className.length-2));
				}
				return;
			}
		}
	}
}

function doPopulateMenu(pId,pblnClickStatus,pblnmouseoverStatus){
        doHideMenus();
        var objMenu = getObj(HmenuPrefix+'navItem' + pId);
        var strSubMenu = 'menuItem' + pId;
        
        if (pblnClickStatus==true && (!menuElementStatus( strSubMenu )) || pblnmouseoverStatus==true){
            objMenu.className = objMenu.className + "On";
            showElement( strSubMenu );
            objMenu.background.src = "images/public_menu_back_b.jpg";
        }	
        else if (pblnClickStatus==true){
            if (objMenu.className.indexOf("On") != -1) {
                    objMenu.className = objMenu.className.substring(0, (objMenu.className.length-2));
            }
            hideElement( strSubMenu );
        }
}

function doHideSubMenu(pId){
	var objMId = getObj(HmenuPrefix+'navItem' + pId)
	var objSMId = getObj('menuItem' + pId)
	
	if (!currentlyHovering) {
		if (typeof objSMId !="undefined" && objSMId.style.visibility =="visible"){
			if (objMId.className.indexOf("On") != -1) {
				objMId.className = objMId.className.substring(0, (objMId.className.length-2));
				hideElement( 'menuItem' + pId );
				strVal = getObj('selectedMenu').value;
				if(getObj(HmenuPrefix+'navItem' +strVal)){
					objNavSelected = getObj(HmenuPrefix+'navItem' +strVal);
					if(objNavSelected.className != objNavSelected.clasName+"On")
						objNavSelected.className = objNavSelected.className + "On";
					showElement( 'menuItem'+strVal);
					currentlyHovering = true;
				}
			}
		}
	}
	
}
/*---------------Start Used for Menu Generation -----------------*/
function doHideMenu(pId) {
	//menu disappear speed onMouseout (in miliseconds)
    currentlyHovering=false;
    setTimeout("doHideCheck("+pId+")",500);
}

function doHideCheck(pId) {
    if (!currentlyHovering){
    	setTimeout("doHideSubMenu("+pId+")",1000);
    }
}

function doPersistHover(pId) {
	currentlyHovering = true;
    currentlyHovering_Main = true;
}

function doNotPersistHover(pId) {
    currentlyHovering_Main = false;
	 //menu disappear speed onMouseout (in miliseconds)
    if (currentlyHovering){
        currentlyHovering = false;
        setTimeout("doHideSubMenu("+pId+")",1500);
    }
}

function setMenu(pId){
	getObj('selectedMenu').value=pId;
}
/*---------------End Used for Menu Generation -----------------*/


/*---------------Start Used for Setting Footer Height()) -----------------*/

//Get highest height and Set Footer height
  function setFooterHeight(){
    //list of outer content DIV ids
    var box = new Array("left","middle","right"); 
    //determine the tallest div
    for(x=0;x<box.length;x++){ 
        h = getObj(box[x]).offsetHeight;
        for(y=0;y<box.length;y++){
            test_h = getObj(box[y]).offsetHeight;
            if(h<test_h){ 
                h = test_h;
            }
        }  
    }
    if(h < 400){
        h=800;
    }
    //set the height of all divs to the tallest
    for(x=0;x<box.length;x++){
        getObj(box[x]).style.height = h +"px"; 
    }
  }
  
/*---------------End Used for Setting Footer Height  -----------------*/


/*---------------Start Used for Button -----------------*/  

function doRollover(elID) {
	var midEl = getObj(elID + "Middle");
	var leftEl = getObj(elID + "Left");
	var rightEl = getObj(elID + "Right");
	
	if (midEl.className.indexOf("Roll") == -1) {
		midEl.className = midEl.className + "Roll";
		leftEl.className = leftEl.className + "Roll";
		rightEl.className = rightEl.className + "Roll";
	}
}

function doRestore(elID) {
	var midEl = getObj(elID + "Middle");
	var leftEl = getObj(elID + "Left");
	var rightEl = getObj(elID + "Right");
	
	if (midEl.className.indexOf("Roll") != -1) {
		midEl.className = midEl.className.substring(0, (midEl.className.length-4));
		leftEl.className = leftEl.className.substring(0, (leftEl.className.length-4));
		rightEl.className = rightEl.className.substring(0, (rightEl.className.length-4));
	}
}

/*---------------End Used for Button  -----------------*/


//---------------------------------------------------------------------------------------------------------------------------------------------------------------------

function leftNavClick(id, numNav) {
	var selNav = document.getElementById("leftNav" + id);
	if (selNav.className == "parent") {
		// close currently selected
		for (var i=0; i<numNav; i++) {
			document.getElementById("leftNav" + i).className = "parent";
			if (document.getElementById("leftNav" + i + "Children") != null) {
				document.getElementById("leftNav" + i + "Children").style.display = "none";
			}
		}
		selNav.className = "parentselected";
		document.getElementById("leftNav" + id + "Children").style.display = "";
	}
	return false;
}

function statusNavClick(id, numTabs, isKF) {
	var elStatusNavPrefix = "statusNav";
	var elStatusBodyPrefix = "statusBody";
	if (isKF != null && isKF == true) {
		elStatusNavPrefix += "KF";
	}
	
	var sNavElement = getObj("statusNav" + id);
	if (sNavElement.className != elStatusNavPrefix + "On") {
		for (var i=0; i<numTabs; i++) {
			getObj("statusNav" + i).className = elStatusNavPrefix + "Off";
			getObj("statusBody" + i).style.display = "none";  // hide body under inactive tabs
		}
		if (id < numTabs-1) {
			sNavElement.className = elStatusNavPrefix + "On";  // active tab
			getObj("statusNav" + (id+1)).className = elStatusNavPrefix + "OffAfterOn";  // set tab left of active to special style
		} else {
			// last element
			sNavElement.className = elStatusNavPrefix + "OnLast";
		}
		getObj(elStatusBodyPrefix + id).style.display = "block";  // show body under active tab
	}
}

function checkboxClick(id) {
	cb = getObj(id);
	if(cb.click != null && cb.click != "undefined")
		cb.click();
		
	cb.checked = !cb.checked;
}

function radioClick(id, val) {
	r = getObj(id);
	if(r.click != null && r.click != "undefined")
		r.click();
		
	r.checked = true;
}

function MM_preloadImages() {
 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];}}
}

/*
 *  Interstitial
 */
function doInterstitialSubmit(formName, msg) {
    // TODO: check for Safari
    if(null != formName)
    {
    	var form = getObj(formName);
    	if(form != null) form.submit();
    	else {
    		alert("Unable to submit form.");
    		return false;
    	}
    }

    
    var bd = getObj('content2col');
    if (null==bd || "undefined"==bd) bd = getObj('content3col');
    if (null==bd || "undefined"==bd) bd = getObj('contentCategory');
    
    var hd = getObj('header');
    var ft = getObj('footer');
    if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("rv:1.7")!=-1) {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    else if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1) {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    // default to IE
    else {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd){
        	 bd.style.display="none";
       	}
    }
    var subMsg = "";
    //See if any additional arguments were passed in
    if(arguments.length > 2) {
    	subMsg = arguments[2];
    }

    doUpdateText(getObj('interstitialText'),msg);
    doUpdateText(getObj('interstitialSubText'),subMsg);
    getObj('interstitialWindow').style.display = "block";


    return false;
}

/*
 *  Interstitial for popup
 */
function doInterstitialSubmitPopup(formName, msg) {
    // TODO: check for Safari
    if(null != formName)
    {
    	var form = getObj(formName);
    	if(form != null) form.submit();
    	else {
    		alert("Unable to submit form.");
    		return false;
    	}
    }


    var bd = getObj('contentPopup');

    if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("rv:1.7")!=-1) {
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    else if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1) {
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    // default to IE
    else {
        if (null!=bd && "undefined"!=bd){
        	 bd.style.display="none";
       	}
    }
    var subMsg = "";
    //See if any additional arguments were passed in
    if(arguments.length > 2) {
    	subMsg = arguments[2];
    }

    doUpdateText(getObj('interstitialText'),msg);
    doUpdateText(getObj('interstitialSubText'),subMsg);
    getObj('interstitialWindow').style.display = "block";


    return false;
}


/*Start of Global Corporate purpose script*/
function opencorptravellink(){
//window.open('http://202.40.225.14/OneToOne/ScriptPublisher/ScrptPub.dll?ESPJ=10126&ESPTP=11039&ESPW=SIADB&DisableDSGNCache=1',"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
window.open('http://ctl.singaporeair.com.sg/OneToOne/ScriptPublisher/ScrptPub.dll?ESPJ=10126&ESPTP=11039&ESPW=SIADB&DisableDSGNCache=1',"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
}
/*End of Global Corporate purpose script*/


/*Start of TS KrisShop purpose script*/
function linkToPDF(pdfName,newBrowserInstance){
   window.open(pdfName,"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=700,height=400,top=150,left=100')
}
/*
* Open up a new child window with the designation content
* @param url -- The url of the file you would like to load (REQUIRED)
* @param name -- The name of the window to open, will default to popupWindow if not supplied (OPTIONAL)
* @param height -- The height of the window to open, should only be used if absolutely necessary (OPTIONAL)
* @param width -- The width of the window to open, should only be used if absolutely necessary (OPTIONAL)
*/

function makePopupWindow(url, name,height, width) {
	if (null==name || "undefined"==name) name = "popupWindow";
	if (null==height || "undefined"==height) height = 600;
	if (null==width || "undefined"==width) width = 600;
    var sFullPath = "";
    if(url.indexOf("http://") > -1)
    	sFullPath = url;
    else { //Must be a relative path
        var sProtocol = self.location.protocol;
	    var sHost     = self.location.host;
	    var sPath     = self.location.pathname;
	    var aUrl      = sPath.split("/");
	    //var surl = "http: + // + lapsxd30:8881 + / + saatest/ + en_UK"

	    //Add the context root if not there
	    if(url.indexOf(WEBAPP_CONTEXT) == -1) 
	    	sFullPath = WEBAPP_CONTEXT;
   	    if(url.indexOf(LOCALE_CONTEXT) == -1) 
	    	sFullPath += "/" + LOCALE_CONTEXT;
		sFullPath = sFullPath + url;
    }
    var sUrl = SHOWPOPUPACTIONURL;
    if(sUrl.indexOf("?") > -1)
    	sUrl += "&";
    else
    	sUrl += "?";
    
    sUrl += "method=window&windowUrl=" + sFullPath;
    
 	var winOptions = "toolbar=no,location=yes,directories=no,status=no,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,width=" + width +",height=" + height + ",top=10,left=100";
	window.open(sUrl,name,winOptions);
}
/* Added for using popup actions jspx */
function makeActionPopupWindow(url, name,height, width){
	if (null==name || "undefined"==name) name = "popupWindow";
	if (null==height || "undefined"==height) height = 600;
	if (null==width || "undefined"==width) width = 600;
    var sUrl = SHOWPOPUPACTIONURL;
    
    if(sUrl.indexOf("?") > -1)
    	sUrl += "&";
    else
    	sUrl += "?";
    
    sUrl += "method=window&windowUrl=" + url;
    
 	var winOptions = "toolbar=no,location=yes,directories=no,status=no,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,width=" + width +",height=" + height + ",top=10,left=100";
	window.open(sUrl,name,winOptions);
}
/*End of TS KrisShop purpose script*/

function openDisplayETWindow(url){
    var sProtocol = self.location.protocol;
    var sHost     = self.location.host;
    var sPath     = self.location.pathname;
    var aUrl      = sPath.split("/");
    //var surl = "http: + // + lapsxd30:8881 + / + saatest/ + en_UK"
    var sFullPath =sProtocol+"//"+sHost+aUrl[0]+"/"+aUrl[1]+"/"+aUrl[2]+url;
 	var winOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=700,height=300,top=150,left=100";
	window.open(sFullPath,"popupWindow",winOptions);
}
/*Start of Global Open URL script*/
function openURL(url, name,height, width){
window.open(url,"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
}
/*End of Global Open URL script*/


SetCookieValue('cookieValueCheck','True','','/','','');

function GetCookieValue() {	
	
		var strName = "cookieValueCheck";
		if (document.cookie.indexOf(strName) == -1)
		{
			return false;
		}
		else
		{
		cookieStart = document.cookie.indexOf(strName);
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		}
		if (cookieValue = "True")
		{
			SetCookieValue('cookieValueCheck','false','','/','','');
			return true;
		}
	}
function SetCookieValue(name,value,expires,path,domain,secure)
	{
		var strDNS = GetDNSValue();
	    	document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        	( (path) ? ";path=" + path : "") +
	        //( (domain) ? ";domain=" + domain : "") +
        	( (domain) ? ";domain=" + strDNS : "") +
	        ( (secure) ? ";secure" : "");
		    return true
	}
function GetDNSValue()
	{
		cookieDomain = document.location.hostname;
	}
function GetCookie() {
	//alert("in GetCookie");
		var strName = "MYIMAGE";
		if (document.cookie.indexOf(strName) == -1)
		{
   			return false;
		}
		else
		{
		cookieStart = document.cookie.indexOf(strName);
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		}
		//alert("in GetCookie"+cookieValue);
			return true;

	}


function CheckCookiesEnabled()        
{			//	alert("in CheckCookiesEnabled");
	
	var images = new Array(3);
		images[0] = "first_01.jpg";
		images[1] = "first_02.jpg";
		images[2] = "first_03.jpg";

		if (GetCookie() ){			
		cookieStart = document.cookie.indexOf("MYIMAGE");
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		//4("cookieValue is "+cookieValue);
		if(cookieValue == images[0])
			{
			//document.getElementById("imagesetup1").className="image2";
			SetCookie('MYIMAGE','first_02.jpg','','/','','');
			}
			if(cookieValue == images[1])
			{
		//	document.getElementById("imagesetup1").className="image3"
			SetCookie('MYIMAGE','first_03.jpg','','/','','');
			}
			if(cookieValue == images[2])
			{
		//	document.getElementById("imagesetup1").className="image1"
			SetCookie('MYIMAGE','first_01.jpg','','/','','');
			}
		}
		 else {	
			// document.getElementById("imagesetup1").className="image1"
			SetCookie('MYIMAGE','first_01.jpg','','/','','');
   			return false;	
   		}	
}  

function SetCookie(name,value,expires,path,domain,secure)
	{
		//alert("in SetCookie");
		var strDNS = GetDNS();
	    	document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        	( (path) ? ";path=" + path : "") +
	        //( (domain) ? ";domain=" + domain : "") +
        	( (domain) ? ";domain=" + strDNS : "") +
	        ( (secure) ? ";secure" : "");
		    return true
	}
		function GetDNS()
	{
		cookieDomain = document.location.hostname;
	}	
/*By nitin*/
function setSelectedMenu(selectedMenuID)
{
    setMenu(selectedMenuID);
 
//   var strVal = selectedMenuID;//getObj('selectedMenu').value;
//    if (getObj('navItem' +strVal)){
//    	var objNavSelected = getObj('navItem' +strVal);
//        setMenu(strVal);
//        alert( objNavSelected.className );
//        if(objNavSelected.className != objNavSelected.className+"On")
//            objNavSelected.className = objNavSelected.className + "On";
//        showElement( 'menuItem'+strVal);
//    }
//    currentlyHovering = true;
}

function setSubMenu(subMenuID)
{
    var span = document.getElementById('span'+subMenuID );
    if( span )
        span.className='subnavItemSelected';
}

/*This function is used for setting status of menu*/
/*Args - comma seperated array of menuids */
function setHMenuStatus( menuIDs)
{
    var menuIDs = menuIDs.split(",");
    var mainMenuIdIndex = getHMenuIndexByMenuID( menuIDs[1] );  //2;//getObj('selectedMenu').value;
    var subMenuIDIndex= menuIDs[2]; //1;
    
    if (getObj(HmenuPrefix+'navItem' +mainMenuIdIndex))
    {
        var objNavSelected = getObj(HmenuPrefix+'navItem' +mainMenuIdIndex);
        setMenu(mainMenuIdIndex);
        
        if(objNavSelected.className != objNavSelected.className+"On")
            objNavSelected.className = objNavSelected.className + "On";
        showElement( 'menuItem'+mainMenuIdIndex);
    }
    currentlyHovering = true;
    setSubMenu(subMenuIDIndex);
    var imgGen 
    var inc;
    for( inc=3 ; inc < menuIDs.length;inc++)
    {
        if( menuIDs[inc] == 0 ) continue;
        
        anchrTag = document.getElementById("vlnk"+menuIDs[inc]);
        
        if( inc !=5 && anchrTag )
        {
            //alert('clicking '+ anchrTag.id );
            if((anchrTag.href.toUpperCase() == window.location.href.toUpperCase() )|| (anchrTag.href.toUpperCase()+"#" == window.location.href.toUpperCase() ) )
            {
                 expandCollapseTbl("imgVSubMenu"+menuIDs[inc], "vSubMenu"+menuIDs[inc], 'show');
            }
            else
            {
                anchrTag.style.color="#cc0000";
                anchrTag.click();
            }
        }
        else if( inc == 5 && anchrTag ) //i.e. leaf menu with href
        {
            if( (anchrTag.href.toUpperCase() == window.location.href.toUpperCase() )|| (anchrTag.href.toUpperCase()+"#" == window.location.href.toUpperCase() ) )
            {
//                anchrTag.style.color="#cc0000";
//                img.src = "../images/collapse.gif";
//                img.offsetParent.childNodes[0].style.color="#cc0000";
                 //expandCollapseTbl(imgname, tblID, action )
                 expandCollapseTbl("imgVSubMenu"+menuIDs[inc], "vSubMenu"+menuIDs[inc], 'show');
            }
            else
            {
                anchrTag.click();
            }
        }
        
//        if( menuIDs[inc] == 0 ) continue;
//        imgGen = document.getElementById("imgVSubMenu"+menuIDs[inc]);
//        alert( imgGen  );
//        if( imgGen )
//            imgGen.click();
//        else    //it means its link not expand and collapse menu but link
//        {
//            
//        }
    }
}
function getHMenuIndexByMenuID(menuID)
{
    var inc;
    for( inc=0; inc < MainHMenuIDs.length; inc++)
    {   
        if( MainHMenuIDs[inc] == menuID)
        {
            return inc+1;
        }
    }
}