/*
----------------------------------------------------------------------
util.js
----------------------------------------------------------------------
*/

function getParentByClassName(element, className)
{
    var parent = element;

    if (className)
    {
        while (parent && parent.className != className)
        {
            parent = parent.parentNode;
        }
    }

    return parent;
}

function getFirstChildByClassRegex(element, tagName, classRegex, stopClassRegex)
{
    var match;
    var child = element.firstChild;

    while (child != null && (!child.className || !child.className.match(stopClassRegex)))
    {
        if (child.tagName && child.tagName == tagName && child.className && child.className.match(classRegex))
        {
            match = child;
            break;
        }
        else
        {
            match = getFirstChildByClassRegex(child, tagName, classRegex, stopClassRegex);

            if (match)
            {
                break;
            }
        }

        child = child.nextSibling;
    }

    return match;
}

function getChildrenByClassRegex(root, classRegexes, tagName, matches)
{
    matches = (matches ? matches : new Array());

    if (root)
    {
        var child = root.firstChild;

        while (child)
        {
            if (!tagName || child.tagName == tagName)
            {
                for (index in classRegexes)
                {
                    if (child.className && child.className.match(classRegexes[index]))
                    {
                        matches[matches.length] = child;
                    }
                }
            }

            getChildrenByClassRegex(child, classRegexes, tagName, matches);
            child = child.nextSibling;
        }
    }

    return matches;
}

function addEventToElement(target, eventType, func, useCapture)
{
    var result = false;

    if (target.addEventListener)
    {
        target.addEventListener(eventType, func, useCapture);
        result = true;
    }
    else if (target.attachEvent)
    {
        result = target.attachEvent("on" + eventType, func);
    }
    else
    {
        alert("Handler could not be attached");
    }

    return result;
}

function addEventToElements(targets, eventType, func, useCapture)
{
    var result = true;

    for (var i = 0; i < targets.length; i++)
    {
        result &= addEventToElement(targets[i], eventType, func, useCapture);
    }

    return result;
}

function removeEventFromElement(target, eventType, func, useCapture)
{
    var result = false;

    if (target.removeEventListener)
    {
        target.removeEventListener(eventType, func, useCapture);
        result = true;
    }
    else if (target.detachEvent)
    {
        result = target.detachEvent("on" + eventType, func);
    }
    else
    {
        window.alert("Handler could not be removed");
    }

    return result;
}

function removeEventFromElements(targets, eventType, func, useCapture)
{
    var result = true;

    for (var i = 0; i < targets.length; i++)
    {
        result &= removeEventFromElement(targets[i], eventType, func, useCapture);
    }

    return result;
}

function getEvent(event)
{
    var evt = event;

    if (!evt)
    {
        evt = window.event;
    }

    return evt;
}

function getEventSource(event)
{
    var source;

    if (event && event.srcElement)
    {
        source = event.srcElement;
    }
    else if (event && event.currentTarget)
    {
        source = event.currentTarget;
    }
    else
    {
        window.alert("Event source not found!");
    }

    return source;
}

function getClickableImageEventSource(source)
{
    // If IE, the original source will be the image being clicked instead of the parent element that generated the event
    if (source && source.src)
    {
        source = source.parentNode;
    }

    return source;
}

/**
 * @deprecated
 */
var console = (beaPortalConsole ? beaPortalConsole : new Console());

/**
 * @deprecated
 */
function Console()
{
    this.canvas = null;
    this.println = consolePrintln;
    this.show = consoleShow;
}

/**
 * @deprecated
 */
function consolePrintln(object)
{
    if (!this.canvas)
    {
        this.canvas = window.open("about:blank", "Console", "toolbar = no, width = 640, height = 480, directories = no, status = no, scrollbars = yes, resize = no, menubar = no");
    }

    this.canvas.document.write(object);
    this.canvas.document.write("<br/>");
}

/**
 * @deprecated
 */
function consoleShow(object)
{
    this.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

    for (property in object)
    {
        this.println(property + " = " + eval("object." + property));
    }

    this.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
}

/**
 * Submits a form  when the enter key is used
 */
function submitOnEnter(theForm) 
{
  if (window.event && window.event.keyCode == 13) theForm.submit();
  else return true;
}
/**
 * For hiding and showing div or any html element with id
 */
function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function timedMsg(d)
{
var h = "HideContent('"+d+"')";
var t=setTimeout(h,10);

}
function abc(){
	document.getElementById('pages5').style.display = "none";
}
function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
	//Modified by Venkata Sarvabatla for Defect #323  
    /*if(navigator.appName == "Microsoft Internet Explorer"){
		document.getElementById(d).style.margin = "0px -120px -120px -120px";
	}else{
		document.getElementById(d).style.margin = "0% -5.3% -5.3% -5.3%";
	}*/
	//Modifications end for Defect #323
	
	document.getElementById(d).style.width="170px";
	document.getElementById(d).style.right="20px";
	//Modified and defect #490 fixed.
	
}
function clickContent(d) {
	if(d.length < 1) { return; }
	if (document.getElementById(d).style.display == "none"){
		document.getElementById(d).style.display = "block";
		}
	if (document.getElementById(d).style.display == "block"){
		document.getElementById(d).style.display = "none";
		}
} 

function ShowContentMMO(d,obj) {
	var x = findPosX(obj);
	var y = findPosY(obj);
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
	document.getElementById(d).style.left = x+obj.offsetWidth-2;
	document.getElementById(d).style.top = y;

}
function delayHideContent(d){
	setTimeout("HideContent(d)",10000);
}
function ShowContentId(d,id) {
	var obj = document.getElementById(id);
	var x = findPosX(obj);
	var y = findPosY(obj);
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
	document.getElementById(d).style.left = x+obj.offsetWidth-2;
	document.getElementById(d).style.top = y;
}
function ToggleContent(d,obj) {
	var x = findPosX(obj);
	var y = findPosY(obj);
	if(d.length < 1) { return; }

	if(document.getElementById(d).style.display=="block"){
		document.getElementById(d).style.display = "none";
	}else {
		document.getElementById(d).style.display = "block";
		document.getElementById(d).style.left = x+obj.offsetWidth-2;
		document.getElementById(d).style.top = y;	
	}

}
  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x; 
        
    return curleft; 
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

  
/*
----------------------------------------------------------------------
skin.js
----------------------------------------------------------------------
*/

function initSkin()
{
    initDynamicMenus();
    initRolloverMenus();
    initPortletDeleteButtons();
    // See the comments in float.js about this function...
    //initPortletFloatButtons();
}

/*
----------------------------------------------------------------------
delete.js
----------------------------------------------------------------------
*/
function showDialogBoxNS(evt)
{
    var name = confirm("Are you sure you want to delete this portlet?")
    if(name == true)
    {
        var source = getEventSource(evt);
        var url = source.href;
        source.href = url+"&__deletePermanently=false";
        return true;
    }
    return false;
}

function showMultipleChoiceDialogBoxNS(evt)
{
    var name = confirm("Are you sure you want to delete this portlet?")
    var name1 = false;
    if(name == true)
    {
        var source = getEventSource(evt);
        var url = source.href;
        name1 = confirm("Press OK to delete permanently \nor Cancel to only delete from this session.\n");
        if(name1 == true)
        {
            source.href = url+"&__deletePermanently=true";
        }
        else
        {
            source.href = url+"&__deletePermanently=false";
        }
        return true;
    }
    return false;
}


function showDialogBoxIE()
{
    var name = confirm("Are you sure you want to delete this portlet?")
    if(name == true)
    {
        var source;
        var event = window.event;
        if(event != null)
        {
            source = event.srcElement;
        }
        var parent = source.parentNode;
        var url = parent.href;
        parent.href = url+"&__deletePermanently=false";
    }
    else
    {
        var event = window.event;
        if(event != null)
        {
            event.returnValue = false;
        }
    }
}

function showMultipleChoiceDialogBoxIE()
{
    var name = confirm("Are you sure you want to delete this portlet?")
    var name1 = false;
    if(name == true)
    {
        var source;
        var event = window.event;
        if(event != null)
        {
            source = event.srcElement;
        }
        var parent = source.parentNode;
        var url = parent.href;
        name1 = confirm("Press OK to delete permanently \nor Cancel to only delete from this session.\n");
        if(name1 == true)
        {
            parent.href = url+"&__deletePermanently=true";
        }
        else
        {
            parent.href = url+"&__deletePermanently=false";
        }
    }
    else
    {
        var event = window.event;
        if(event != null)
        {
            event.returnValue = false;
        }
    }
}

function detectNetscape()
{
    var n=navigator.appName
    if(n == "Netscape")
    {
        return true;
    }
    else
    {
        return false;
    }
}

function initPortletDeleteButtons()
{
    var portletDeleteButtonsSpanned = getSpannedDeleteButtons();
    var portletDeleteButtonsNonSpanned = getNonSpannedDeleteButtons();
    if(detectNetscape() == true)
    {
        for(var i = 0; i < portletDeleteButtonsSpanned.length; i++)
        {
            portletDeleteButtonsSpanned[i].onclick = showMultipleChoiceDialogBoxNS;
        }
        for(var i = 0; i < portletDeleteButtonsNonSpanned.length; i++)
        {
            portletDeleteButtonsNonSpanned[i].onclick = showDialogBoxNS;
        }
    }
    else
    {
        for(var i = 0; i < portletDeleteButtonsSpanned.length; i++)
        {
            portletDeleteButtonsSpanned[i].onclick = showMultipleChoiceDialogBoxIE;
        }
        for(var i = 0; i < portletDeleteButtonsNonSpanned.length; i++)
        {
            portletDeleteButtonsNonSpanned[i].onclick = showDialogBoxIE;
        }
    }
}

function getSpannedDeleteButtons()
{
    var anchors = document.getElementsByTagName("a");
    var spannedDeletes = new Array(0);
    var j = -1;
    for (var i = 0; i < anchors.length; i++)
    {
        var _className = anchors[i].className;
        if((_className == "bea-portal-button-delete") &&
           (anchors[i].parentNode.tagName == "span" || anchors[i].parentNode.tagName == "SPAN"))
        {
            j++;
            spannedDeletes[j] = anchors[i];
        }
    }
    return spannedDeletes;
}

function getNonSpannedDeleteButtons()
{
    var anchors = document.getElementsByTagName("a");
    var nonSpannedDeletes = new Array(0);
    var j = -1;
    for (var i = 0; i < anchors.length; i++)
    {
        var _className = anchors[i].className;
        if((_className == "bea-portal-button-delete") &&
           (anchors[i].parentNode.tagName != "span" && anchors[i].parentNode.tagName != "SPAN"))
        {
            j++;
            nonSpannedDeletes[j] = anchors[i];
        }
    }
    return nonSpannedDeletes;
}

/*
----------------------------------------------------------------------
float.js
----------------------------------------------------------------------
*/

/*
 * This file illustrates one way to customize floating popup portlets.  However, it is not enabled by default.
 * To enable this javascript functionality, uncomment the call to "initPortletFloatButtons()" in skin.js.
 */

function initPortletFloatButtons()
{
    var links = document.getElementsByTagName("a");

    for (var i = 0; i < links.length; i++)
    {
        if (links[i].className && links[i].className == "bea-portal-button-float")
        {
            initPortletFloatButton(links[i]);
        }
    }
}

function initPortletFloatButton(link)
{
    link.onclick = floatPortlet;
}

function floatPortlet(event)
{
    var href = getEventAnchorHref(getEvent(event));
    var target = getEventAnchorTarget(getEvent(event));
    // This is the interesting line for customization purposes:
    window.open(href, target, "toolbar = no, width = 320, height = 240, directories = no, status = no, scrollbars = yes, resize = yes, menubar = no");
    // Returning false keeps the browser from submitting this button click to the server.
    return false;
}

function getEventAnchorHref(event)
{
    var source = getEventSource(event);
    // Correct source for IE
    source = getClickableImageEventSource(source);
    return (source && source.href ? source.href : "about:blank");
}

function getEventAnchorTarget(event)
{
    var source = getEventSource(event);
    // Correct source for IE
    source = getClickableImageEventSource(source);
    return (source && source.target ? source.target : "_blank");
}

//Portal ITG 41872 Starts

////////////////////////////////////////////////////////////////////////////////////
//
//    ATTENTION NETSCAPE NAVIGATOR 3.0 USERS!!!
//
//    If you see this text while using the site and you did NOT click on
//    View -> Source, you're using a buggy browser.
//
//    FOLLOW THESE STEPS
//
//    Read through these two steps before doing them.
//    1. Press your BACK BUTTON.
//    2. Click on REFRESH or RELOAD.
//
//    You should now be able to use the site without seeing this message.
//    This problem can however return if your browser does not cache this
//    document correctly.
//
//    UPGRADE YOUR BROWSER
//
//    Upgrade your browser to Netscape's latest and you will not have this
//    problem any more.
//
//    Netscape browsers can be found at https://home.netscape.com/
//
////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////
//  overLIB 2.22  --  Please leave this notice.
//
//  By Erik Bosrup (erik@bosrup.com)  Last modified 1999-03-31
//  Portions by Dan Steinman, Landon Bradshaw and Gnowknayme.
//
//  Get the latest version at https://www.bosrup.com/web/overlib/
//
//  This script library was created for my personal usage from the start
//  but then it became so popular I made an easy to use version. It's that
//  version you're using now. Since this is free please don't try to sell
//  this solution to a company claiming it is yours. Give me credit where
//  credit is due and I'll be happy. And I'd love to see any changes you've
//  done to the code. Free to use - don't abuse.
////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

// Main background color (the large area)
// Usually a bright color (white, yellow etc)
	if (typeof fcolor == 'undefined') { var fcolor = "#EEEEEE";}

// Border color and color of caption
// Usually a dark color (black, brown etc)
	if (typeof backcolor == 'undefined') { var backcolor = "#333399";}


// Text color
// Usually a dark color
	if (typeof textcolor == 'undefined') { var textcolor = "#000000";}

// Color of the caption text
// Usually a bright color
	if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}

// Color of "Close" when using Sticky
// Usually a semi-bright color
	if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}


// Width of the popups in pixels
// 100-300 pixels is typical
	if (typeof width == 'undefined') { var width = "200";}

// How thick the border should be in pixels
// 1-3 pixels is typical
	if (typeof border == 'undefined') { var border = "1";}


// How many pixels to the right/left of the cursor to show the popup
// Values between 3 and 12 are best
	if (typeof offsetx == 'undefined') { var offsetx = 10;}

// How many pixels to the below the cursor to show the popup
// Values between 3 and 12 are best
	if (typeof offsety == 'undefined') { var offsety = 10;}

////////////////////////////////////////////////////////////////////////////////////
// END CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
mz5 = (document.getElementById && !document.all);


// Microsoft Stupidity Check.
if (ie4) {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	} else {
		ie5 = false; }
} else {
	ie5 = false;
}

var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr = 1;
var over = 0;

if ( (ns4) || mz5 || (ie4) ) {
//	if (ns4) over = document.overDiv
//	if (ie4) over = overDiv.style
	document.onmousemove = mouseMove
	if (ns4 || mz5) document.captureEvents(Event.MOUSEMOVE)
}

//initialise function for Netscape problem
function NSInit()
{
	//alert('NSInit');
	if ( (ns4) || (mz5) || (ie4) ) {
		if (ns4) over = document.overDiv;
		if (ie4 || mz5) {
			try{
				over = overDiv.style;
			}catch(err){//alert(err);
				over = document.getElementById("overDiv").style;
				//alert("overDiv"+over);
			}
		}			
		document.onmousemove = mouseMove;
		if (ns4 || mz5) document.captureEvents(Event.MOUSEMOVE);
	}
	//alert('Getobject:'+over);
}

// Public functions to be used on pages.

// Simple popup right
function drs(text) {
	dts(1,text);
}

// Caption popup right
function drc(text, title) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}

	dtc(1,text,title);
}

// Sticky caption right
function src(text,title) {
	stc(1,text,title);
}

// Simple popup left
function dls(text) {
	dts(0,text);
}

// Caption popup left
function dlc(text, title) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}

	dtc(0,text,title);
}

// Sticky caption left
function slc(text,title) {
	stc(0,text,title);
}

// Simple popup center
function dcs(text) {
	dts(2,text);
}

// Caption popup center
function dcc(text, title) {
	dtc(2,text,title);
}


// Sticky caption center
function scc(ship,survey) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	stc(2,ship,survey);
}

/*****************************************************************************
to be used when both Survey and Recommendations are to be shown in the pop-up

// Sticky caption center
function scc(ship,text1,link1,text2,link2) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	stc(2,ship,text1,link1,text2,link2);
}
******************************************************************************/

// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) || (mz5) ) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// Non public functions. These are called by other functions etc.

// Simple popup
function dts(d,text) {
	
	// Applying CSS Styles 6/9/2008 Bijesh
	//txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT FACE=\"Verdana\" COLOR=\""+textcolor+"\" SIZE=\"-2\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	//alert(1);
	txt = "<TABLE class='tableforms popup'><TR class='fieldcontent'><TD>"+text+"</TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Caption popup
function dtc(d,text, title) {
	// Applying CSS Styles 6/9/2008 Bijesh
	//alert(2);
	txt = "<TABLE class='tableforms popup'><TR class='tableheader'><TD style='text-align:left'><SPAN ID=\"PTT\" ALT=\""+ title +"\">"+title+"</SPAN></TD></TR><TR class='fieldcontent'><TD><SPAN ID=\"PST\" ALT=\""+ text +"\">"+ text +"<SPAN></TD></TR></TABLE>";
	//txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+ text +"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Sticky
function stc(d,ship,survey) {
	var width=250
	sw = 1;
	cnt = 0;
//	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><FONT COLOR=\""+capcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"

	//alert(3);
// Applying CSS Styles 6/9/2008 Bijesh
//	txt = "<A HREF=\"\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=javascript:onClick=openFromPopup()>"+survey+ "<A>" +"</FONT></SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	txt = "<A HREF=\"\" onMouseover=\"over.visibility='visible'\" onMouseout=\"over.visibility='hidden';\"><TABLE class='tableforms popup'><TR class='tableheader'><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\" title=\""+ ship +"\">"+ ship +"</SPAN></DIV></TD></TR><TR class='fieldcontent'><TD><DIV><SPAN ID=\"PTT\"><A HREF=javascript:onClick=openFromPopup() title=\""+ survey +"\">"+survey+ "<A></SPAN></DIV></TD></TR></TABLE></A>"

	layerWrite(txt);
	dir = d;
	//alert(24);
	disp();
	snow = 0;
	//alert(29);
}

//#41881
function stc_status(ship,survey) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	var width=250
	sw = 1;
	cnt = 0;
	txt = "<TABLE class='tableforms popup'><TR class='tableheader'><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\" title=\""+ ship +"\">"+ ship +"</SPAN></DIV></TD></TR><TR class='fieldcontent'><TD><DIV><SPAN ID=\"PTT\">"+survey+ "</SPAN></DIV></TD></TR></TABLE>"

	layerWrite(txt);
	//alert('layerWrite');
	dir = 2;
	//alert(24);
	disp();
	snow = 0;
}

/*****************************************************************************
to be used when both Survey and Recommendations are to be shown in the pop-up

// Sticky
function stc(d,ship,text1,link1,text2,link2) {
	var width=250
	sw = 1;
	cnt = 0;
//	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><FONT COLOR=\""+capcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	if(text1=='#')
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PST\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	else if(text2=='#')
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	else
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PST\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	layerWrite(txt);
	dir = d;
	disp();
	snow = 0;
}
*****************************************************************************/

// Common calls
function disp() {
			//alert('dir:2: x:'+x+' : scrollLeft: '+document.body.scrollLeft);
			//alert('dir:2: y:'+y+' : scrollTop: '+document.body.scrollTop);
			//alert('disp');
			//alert('mz5:'+mz5);
		//alert(document.body.scrollLeft);
		if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		    //IE6 standards compliant mode
		    scrollTop = document.documentElement.scrollTop;
		    scrollLeft = document.documentElement.scrollLeft;
			//alert('IE scrollLeft1: '+scrollLeft);
			//alert('IE scrollTop1: '+scrollLeft);
		  }
		else
		{
			scrollLeft = document.body.scrollLeft;
			scrollTop = document.body.scrollTop;
		}
		
		if(mz5)
		{
			scrollLeft = 0;
			scrollTop = 0;
		}
		
	if ( (ns4) || (mz5) || (ie4) ) {
			//alert('snow='+snow+' dir='+dir);
		if (snow == 0) 	{
			if (dir == 2) { // Center
				//moveTo(over,x+offsetx-(width/2),y+offsety);
				moveTo(over,x-10+ scrollLeft,y+ scrollTop);
				//moveTo(over,x-10,y);
			}
			if (dir == 1) { // Right
				moveTo(over,x+offsetx+ scrollLeft,y+offsety+ scrollTop);
			}
			if (dir == 0) { // Left
				moveTo(over,x-offsetx-width+ scrollLeft,y+offsety+ scrollTop);
			}
			//alert('moved');
			showObject(over);
			snow = 1;
		}
		//alert('show');
	}
// Here you can make the text goto the statusbar.
}

// Moves the layer
function mouseMove(e) {

	if (ns4 || mz5) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
//	if (mz5) {x=e.screenX; y=e.screenY;}
	
/*	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (snow) {
		if (dir == 2) { // Center
			//moveTo(over,x+offsetx-(width/2),y+offsety);
			moveTo(over,x+offsetx-(width/2),y);
		}
		if (dir == 1) { // Right
			moveTo(over,x+offsetx,y+offsety);
		}
		if (dir == 0) { // Left
			moveTo(over,x-offsetx-width,y+offsety);
		}
	}*/
}

// The Close onMouseOver function for Sticky
function cClick() {
	hideObject(over);
	sw=0;
}

// Writes to a layer
function layerWrite(txt){
		//alert('writing');
		if (ns4){
				var lyr = document.overDiv.document;
                lyr.write(txt);
                lyr.close();
                //alert('write:'+txt);
        }
        else if (ie4 || mz5) 
        {
        	try{
        		document.all["overDiv"].innerHTML = txt;
        		//alert("innerHTML"+document.all["overDiv"].innerHTML);
        	}catch(err)
        	{
        		//alert("Error:"+err);
        		document.getElementById("overDiv").innerHTML = txt;
        		//alert("document.overDiv:"+document.getElementById("overDiv").innerHTML);
        	}
        }
		if (tr) { trk(); }
		//alert('wrote');
}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4 || ie5) obj.visibility = "visible"
        else if ( mz5) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4 || ie5) obj.visibility = "hidden"
        else if (mz5) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
		//alert('moveto:'+obj);
		//alert('obj:'+obj);
		//alert('frmleft:'+obj.left);
		//alert('frmtop:'+obj.top);
		//alert('toleft:'+xL);
		//alert('totop:'+yL);
        obj.left = xL+'px';
        obj.top = yL+'px';
		//alert('currleft:'+obj.left);
		//alert('currleft:'+obj.top);
}



function trk() 
{
/*
	if ( (ns4) || (ie4) ) 
	{
		nt=new Image(32,32); nt.src="https://www.nedstat.nl/cgi-bin/nedstat.gif?name=ol2t";
		bt=new Image(1,1); bt.src="https://www.bosrup.com/web/overlib/o2/tr.gif";
		refnd=new Image(1,1); refnd.src="https://www.nedstat.nl/cgi-bin/referstat.gif?name=ol2t&refer="+escape(top.document.referrer);

	}
*/	
	tr = 0;
}

//added by Suvodip
function validDate(dd,mm,yy)
{
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  if(yy < year)
  {
    vd = false;
  }
  else if(yy == year)
  {
        if(mm < month)
        {
          vd = false;
        }
        else if(mm == month)
        {
		if(dd < day)
		{
		  vd = false;
		}
		else if(dd == day)
		{
		  vd = true;
		}
        }
  }
  return vd;
}

//This function checks if Start Date Year yy is less than or equal to current Year
function validIACSStartDate(dd,mm,yy)
{
  ////alert("Res-image-soverlib.js : validIACSStartDate");
  
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  
  if(yy > year)
  {
    vd = false;
  }
  
  return vd;

}

//This function checks if (Start Date)dd1,mm1,yy1 is less than (End Date)dd2,mm2,yy2
function compareDate(dd1,mm1,yy1,dd2,mm2,yy2)
{
  ////alert("Res-images-overlib.js : compareDate");

   var yearFlag = true;
   
   if(yy1 <= yy2)
   {
   	if(mm1 <= mm2)
   	{
   	      if(dd1 >= dd2)
   	      {
   	      	yearFlag = false;
   	      }
   	}
   	else
   	{
   	   yearFlag = false;
   	}
   }
   else
   {
   	yearFlag = false;
   }
   
   return yearFlag;
}

/*Date is less than equal to current date*/
function validDateBefore(dd,mm,yy)
{
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  if(yy > year)
  {
    vd = false;
  }
  else if(yy == year)
      {
        if(mm > month)
        {
          vd = false;
        }
        else if(mm == month)
              {
                if(dd > day)
                {
                  vd = false;
                }
                else if(dd == day)
                      {
                        vd = true;
                      }
                }
    }
    return vd;
}

/*Date is greater than current date*/
function validDateAfter(dd,mm,yy,sdd,smm,syy)
{
  var Today = new Date();

  var year = syy;	    // Returns year
  var month = smm;    // Returns month (0-11)
  //month = month + 1;
  var day = sdd;    // Returns day (1-31)

  var vd = true;
  if(yy < year)
  {
    vd = false;
  }
  else if(yy == year)
      {
        if(mm < month)
        {
          vd = false;
        }
        else if(mm == month)
              {
                if(dd < day)
                {
                  vd = false;
                }
                else if(dd == day)
                      {
                        vd = false;
                      }
                }
    }
    return vd;
}

/*Sorting code has been merged since the use of two SRC in Javascript
tag is creating problems in IE5.5*/

/*************Swapping starts***************/

Imagepath = "/common";
flag = new Array;
for(var i=0;i<12;i++)
{
  flag[i]=0;
}

imagename = new Array;
imagename[0]='randimg1';
imagename[1]='randimg2';
imagename[2]='randimg3';
imagename[3]='randimg4';
imagename[4]='randimg5';
imagename[5]='randimg6';
imagename[6]='randimg7';
imagename[7]='randimg8';
imagename[8]='randimg9';
imagename[9]='randimg10';
imagename[10]='randimg11';
imagename[11]='randimg12';

images = new Array;
images[0] = new Image();
images[0].src = Imagepath+"/images/down.gif";
images[1] = new Image();
images[1].src = Imagepath+"/images/up.gif";

calledFlag=0;

function changeFlag(index)
{
  if(calledFlag==0)
  {
    calledFlag=1;
    flag[index]=1;
  } 
 
}

function swapPic(picname)
{
  var loc;
  for(var i=0;i<12;i++)
  {
    if(picname.name==imagename[i])
    {
      if(flag[i]==0)
      {
        flag[i]=1;
        loc = flag[i];
        break;
      }
      else
      {
        flag[i]=0;
        loc = flag[i];
        break;
      }
    }
  }
  
  picname.src=images[loc].src;
}

/*************Swapping ends***************/

/*************Sorting starts***************/

function createRowsArray (table) {
  var rows = new Array();
  var r = 0;
  if (table.tHead == null)
    for (var r1 = 0; r1 < table.rows.length; r1++, r++)
      rows[r] = table.rows[r1];
  else
    for (var t = 0; t < table.tBodies.length; t++)
      for (var r1 = 0; r1 < table.tBodies[t].rows.length; r1++, r++)
        rows[r] = table.tBodies[t].rows[r1];


  return rows;
}

function insertSortedRows(table, rows) {
var rowcolorflag=0;
  if (document.all) var rowsCopy = new Array(rows.length)
  for (var r = 0; r < rows.length; r++) {
    if (document.all) rowsCopy[r] = rows[r].cloneNode(true);
    table.deleteRow(rows[r].rowIndex);
  }
  
  var tableSection = table.tBodies[table.tBodies.length - 1];
  for (var r = 0; r < rows.length; r++) {
    var row = document.all ? rowsCopy[r] : rows[r];
    if(rowcolorflag==0){  
          row.bgColor="e5e9ed";
          rowcolorflag=1;
        }else{
          row.bgColor="e5e9ed";
          rowcolorflag=0;
    }
    tableSection.appendChild(row);
    
}
      
}

function sortTable (table, sortFun) {


  var rows = createRowsArray(table);

  if (rows.length > 0) {
    rows.sort(sortFun);
    insertSortedRows(table, rows);
  }
}

function sortRowsAlphaDesc (row1 , row2) {
  var column = sortRowsAlphaDesc.col;
  var cell1 = row1.cells[column].firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.nodeValue;
  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}
function sortRowsAlphaAsc (row1 , row2) {
  var column = sortRowsAlphaAsc.col;
  var cell1 = row1.cells[column].firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.nodeValue;
  return cell1 < cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsNumber (row1 , row2) {
  var column = sortRowsNumber.col;
  var cell1 = parseFloat(row1.cells[column].firstChild.nodeValue);
  var cell2 = parseFloat(row2.cells[column].firstChild.nodeValue);
  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsLinkDesc (row1 , row2) {
  var column = sortRowsLinkDesc.col;
//var cell1 = findFirstLinkChild(row1.cells[column]).href;
//var cell2 = findFirstLinkChild(row2.cells[column]).href;
  var cell1 = row1.cells[column].firstChild.firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.firstChild.nodeValue;

  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsLinkAsc (row1 , row2) {
  var column = sortRowsLinkAsc.col;
//var cell1 = findFirstLinkChild(row1.cells[column]).href;
//var cell2 = findFirstLinkChild(row2.cells[column]).href;
  var cell1 = row1.cells[column].firstChild.firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.firstChild.nodeValue;

  return cell1 < cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}
function findFirstLinkChild (el) {
  var child = el.firstChild;
  while (child.tagName != 'A')
    child = child.nextSibling;
  return child;
}

function testSortTable(table, col) {
//    sortRowsAlphaDesc.col = col;
//    sortTable(table, sortRowsAlphaDesc);
    
if(flag[col]==0)
  {
    sortRowsAlphaDesc.col = col;
    sortTable(table, sortRowsAlphaDesc);
  }
  else
  {
    sortRowsAlphaAsc.col = col;
    sortTable(table, sortRowsAlphaAsc);
  }
}


function testSortTableNumerical (table, col) {
  sortRowsNumber.col = col;
  sortTable(table, sortRowsNumber);
}

function testSortTableLinks (table, col) {
//  sortRowsLinkDesc.col = col;
//  sortTable(table, sortRowsLinkDesc);

if(flag[col]==0)
{
  sortRowsLinkDesc.col = col;
  sortTable(table,sortRowsLinkDesc);
}
else
{
  sortRowsLinkAsc.col = col;
  sortTable(table,sortRowsLinkAsc);
 }
} 
 function findTableParent (node) {
  while (node.tagName.toUpperCase() != 'TABLE')
    node = node.parentNode;
  return node;
}

function openSurveyPopUp(hyperlink){
	var url = hyperlink.href;
	//hyperlink.href = "#";
	//alert(url);
	
}
//Portal ITG 41872 Ends


/*
----------------------------------------------------------------------
menu.js
----------------------------------------------------------------------
*/


// @todo Re-evaluate need for IDs

var tryClosePause = 1500;

var bookTag = "DIV";
var menuTag = "UL";
var menuItemTag = "LI";
var menuItemLinkTag = "A";
var menuHookTag = "DIV"

var bookClassRegex = new RegExp("bea-portal-book(?:-(primary))?$");
var menuClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu$");
var hookClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu-hook$");
var itemClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu-item(?:-(active))?$");
var linkClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu-item-link$");

var rootClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu-root$");
var nestedClassRegex = new RegExp("bea-portal-book(?:-(primary))?-menu-nested$");
var books = new Array();
var currentMenuItem;

function initDynamicMenus()
{
    initBooks();
    createMenus();
}

function initBooks()
{
    var bookCandidates = document.getElementsByTagName(bookTag);
	   for (var i = 0; i < bookCandidates.length; i++)
    {
  
        if (bookCandidates[i].tagName && bookCandidates[i].tagName == bookTag
            && bookCandidates[i].className && bookCandidates[i].className.match(bookClassRegex))
        {
            var book = initBook(bookCandidates[i]);
            if (book)
            {
                books[books.length] = book;
            }
        }
    }
}

function initBook(tag)
{
    var book;
    var menuInstance = getFirstChildByClassRegex(tag, menuTag, menuClassRegex, bookClassRegex);
    var hookInstance = getFirstChildByClassRegex(tag, menuHookTag, hookClassRegex, bookClassRegex);
    if (tag && menuInstance && hookInstance)
    {
    
        var menu = initMenu(menuInstance);
        var hook = initMenuHook(hookInstance);
        if (menu && hook)
        {
            book = new Book(tag, menu, hook);
        }
    }
    return book;
}

function initMenu(tag)
{
    if (!tag)
    {
        alert("No tag defined!");
    }

    tag.style.display = "none";
    var menuItems = new Array();
    var child = tag.firstChild;

    while (child != null)
    {
    
        if (child.tagName && child.tagName == menuItemTag && child.className.match(itemClassRegex))
        {
            var itemGroups = child.className ? child.className.match(itemClassRegex) : null;
			
            if (itemGroups && itemGroups.length >= 1)
            {
                var isActive = false;

                if ((itemGroups.length == 2 && itemGroups[1] == "active")
                    || (itemGroups.length == 3 && itemGroups[2] == "active"))
                {
                    isActive = true;
                }

                menuItems[menuItems.length] = initMenuItem(child, isActive);
            }
        }

        child = child.nextSibling;
    }


    var groups = tag.className.match(menuClassRegex);
    var bookClassQualifier = (groups && groups.length >= 2 && groups[1] == "primary" ? "-primary" : "");
    return new Menu(tag, menuItems, bookClassQualifier);
}

function initMenuHook(tag)
{
    return new MenuHook(tag);
}

function initMenuItem(tag, isActive)
{
    var link;
    var menu;
    var child = tag.firstChild;

    while (child != null)
    {
        if (child.tagName && child.tagName == menuItemLinkTag && child.className.match(linkClassRegex))
        {
            var label = (child.innerText ? child.innerText : child.text);
            link = new Link(child, label);
        }
        else if (child.tagName && child.tagName == menuTag)
        {
            menu = initMenu(child);
        }

        child = child.nextSibling;
    }
    return new MenuItem(tag, link, isActive, menu);
}

function createMenus()
{
    for (var i = 0; i < books.length; i++)
    {
        createRootMenu(books[i].menu, books[i].hook, i);
    }
}

function createRootMenu(menu, hook, menuId)
{
    var menuContext = document.createElement("UL");
    menuContext.className = "bea-portal-book" + menu.bookClassQualifier + "-menu-root";
    menuContext.id = "menu-" + menuId;
    hook.tag.appendChild(menuContext);
    var itemClassName = "bea-portal-book" + menu.bookClassQualifier + "-menu-root-item";
    for (var i = 0; i < menu.menuItems.length; i++)
    {
        createMenuItem(menu.menuItems[i], menuContext, itemClassName, i, "LI", true);
        
    }
}

function createSubMenu(menu, hook, contextId)
{
    var menuContext = document.createElement("div");
    menuContext.style.display = "none";
    menuContext.className = "bea-portal-book" + menu.bookClassQualifier + "-menu-nested";
    menuContext.id = contextId + "-menu";
    hook.tag.appendChild(menuContext);
    var itemClassName = "bea-portal-book" + menu.bookClassQualifier + "-menu-nested-item";
	
    for (var i = 0; i < menu.menuItems.length; i++)
    {
 
           createMenuItem(menu.menuItems[i], menuContext, itemClassName, i, "DIV", false);
    }      
    return menuContext;
}

function createblankSubMenu(menu, hook, contextId)
{
    var menuContext = document.createElement("div");
    menuContext.style.display = "none";
    menuContext.className = "bea-portal-book"  + "-menu-nested";
    menuContext.id = contextId + "-menu";
    hook.tag.appendChild(menuContext);
    var itemClassName = "bea-portal-book" +  "-menu-nested-item";
	
   
    return menuContext;
}

function createMenuItem(menuItem, menuContext, itemClassName, itemId, tagName, isRoot)
{
    var itemContext = document.createElement(tagName);
    if (!isRoot && menuItem.menu && menuContext.id != 'menu-0-item-6-menu')  {
    	itemClassName = "bea-portal-book-primary-menu-not-nested-item";
    }

    itemContext.className = itemClassName + (menuItem.isActive ? "-active" : "");
  
    menuContext.appendChild(itemContext);
    itemContext.id = menuContext.id + "-item-" + itemId;
    
	if (menuItem.link)
    {
    	var link = document.createElement("a");
  		//link.appendChild(document.createElement("span")); 
        link.href = menuItem.link.tag.href; 
               
        var label = document.createTextNode(menuItem.link.label);
        addEventToElement(link, "mouseover", menuItemHoverIn, false);
        addEventToElement(link, "mouseout", menuItemHoverOut, false);
       
        itemContext.appendChild(link);
        link.appendChild(label);
    }

    if (menuItem.menu)
    {
    	var subMenu = createSubMenu(menuItem.menu, new MenuHook(itemContext), itemContext.id);
        itemContext.appendChild(subMenu);
    }
	
	else {var blankMenu = createblankSubMenu(menuItem.menu, new MenuHook(itemContext), itemContext.id);
 	itemContext.appendChild(blankMenu);}
}

function menuItemHoverIn(evt)
{
    var event = getEvent(evt);
    var source = getEventSource(event);
    var parent = source.parentNode;
    currentMenuItem = parent;
    parent.renderedHeight = parent.offsetHeight;
    parent.renderedWidth = parent.offsetWidth;
    closeAll(parent);
    openPath(parent);
}

function menuItemHoverOut(evt)
{
    var event = getEvent(evt);
    
    var source = getEventSource(event);
    var parent = source.parentNode;
    currentMenuItem = null;
    tryClose(parent);
}

var tmpMenuItem;
function tryClose(menuItem)
{

    if (!currentMenuItem)
    {
        tmpMenuItem = menuItem;
        setTimeout("wlp_default_close(tmpMenuItem)", tryClosePause);
    }
}

function wlp_default_close(menuItem)
{
    if (menuItem && !currentMenuItem)
    {
        closeAll(menuItem);
    }
}

function getMenuChild(parent)
{
    var child = parent.firstChild;
    var done = false;
    

    while (!done && child)
    {
        if (child && child.className && child.className.match(nestedClassRegex))
        {
            done = true;

        }
        else
        {
            child = child.nextSibling;
           
        }
        
    }

    return child;
}

function openPath(menuItem)
{
    var path = new Array();
    var childMenu = getMenuChild(menuItem);
   

    if (childMenu)
    {
        path[path.length] = new Array();
        path[path.length - 1][0] = menuItem;
        path[path.length - 1][1] = childMenu;
    }

    var menu = menuItem.parentNode;

    while (menu && !menu.className.match(rootClassRegex))
    {
        menuItem = menu.parentNode;
        path[path.length] = new Array();
        path[path.length - 1][0] = menuItem;
        path[path.length - 1][1] = menu;
        menu = menuItem.parentNode;
    }

    for (var i = 0; i < path.length; i++)
    {
        openMenu(path[i][0], path[i][1], path.length - 1 - i);
    }
}

function openMenu(menuItem, menu, depth)
{
    var width = (menuItem.offsetWidth == 0 ? menuItem.renderedWidth : menuItem.offsetWidth);
    var pos = (depth == 0 ? 1 : getMenuItemPosition(menuItem));
    var height = (menuItem.offsetHeight == 0 ? menuItem.renderedHeight : menuItem.offsetHeight);
    
    var coords = (depth == 0 ? getDocumentOffset(menuItem) : [menuItem.offsetLeft, menuItem.offsetTop]);
   
    menu.style.position = "absolute";
    menu.style.display = "block";
    menu.style.left = coords[0] + (depth == 0 ? 0 : width) + "px";
    //Modified by Venkata Sarvabatla for Defect #324  
    if(navigator.appName=="Microsoft Internet Explorer"){
    	menu.style.top = coords[1] + (pos * height) + "px";
    }else{
    	menu.style.top = coords[1] + (pos * height) + "px";
    }
    //Modifications end for Defect #324
    
    openShim(menu,menuItem); 
}

function getDocumentOffset(object)
{
    var coords = new Array();
    coords[0] = object.offsetLeft;
    //Modified by Venkata Sarvabatla for Defect #324  
    if(navigator.appName=="Microsoft Internet Explorer"){
     coords[1] = object.offsetTop;
    }
	//Modifications end for Defect #324
    while((object = object.offsetParent) != null)
    {
        coords[0] += object.offsetLeft;
        //coords[1] += object.offsetTop;
        
        if(navigator.appName=="Microsoft Internet Explorer"){
     		coords[1] += object.offsetTop;
    	}
    	/*else{
     	//coords[1] = 23;
     		//alert(object.getNodeName());
     		//alert(object.nodeName);
     		if(object.nodeName != 'BODY' && object.nodeName != 'TABLE')
     			coords[1] += object.clientHeight;
     		//alert(coords[1]);
	    }
	    */
        
    }

    return coords;
}

function getMenuItemPosition(menuItem)
{
    var pos = 0;
    var parentMenu = menuItem.parentNode;
    var childMenuItem = parentMenu.firstChild;
    var hit = false;

    while (childMenuItem)
    {
        if (childMenuItem == menuItem)
        {
            hit = true;
            break;
        }

        pos++; 
        
        childMenuItem = childMenuItem.nextSibling;
    }

    if (!hit)
    {
        alert("Parent menu does not contain child menu item!");
    }

    return pos;
}

// @review Consider a closeAllBut(menuItem) that closes everything in the path above the menuItem for Mozilla
function closeAll(menuItem)
{
	var rootMenu = menuItem.parentNode;
    //Modified by Venkata Sarvabatla for Defect #324
    //if(navigator.appName=="Microsoft Internet Explorer"){
	    while (rootMenu && !rootMenu.className.match(rootClassRegex))
	   {
	     rootMenu = rootMenu.parentNode.parentNode;
	   }
     //}
     
     //Modifications end for Defect #324
    closeAllChildren(rootMenu);
}

function closeAllChildren(menu)
{
    var child = menu.firstChild;
	while (child)
    {
        var subMenu = getMenuChild(child);
        if (subMenu)
        {
            closeAllChildren(subMenu);
            subMenu.style.display = "none";
            closeShim(subMenu); 
        }

       child = child.nextSibling;
    }
}

function Book(tag, menu, hook)
{
    this.tag = tag;
    this.menu = menu;
    this.hook = hook;
}

function Menu(tag, menuItems, bookClassQualifier)
{
    this.tag = tag;
    this.menuItems = menuItems;
    this.bookClassQualifier = bookClassQualifier;
}

function MenuHook(tag)
{
    this.tag = tag;
}

function MenuItem(tag, link, isActive, menu)
{
    this.tag = tag;
    this.link = link;
    this.isActive = isActive;
    this.menu = menu;
}

function Link(tag, label)
{
    this.tag = tag;
    this.label = label;
}

//Fix for drop down issue

//Opens a shim, if no shim exists for the menu, one is created
function openShim(menu,menuItem)
{

    if (menu==null) return;
    var shim = getShim(menu);
    if (shim==null) shim = createMenuShim(menu,getShimId(menu));
    
    //Change menu zIndex so shim can work with it
    menu.style.zIndex = 100;
    
    var width = (menu.offsetWidth == 0 ? menuItem.renderedWidth : menu.offsetWidth);
    var height;
    
    if (menu.offsetHeight == 0)
    {
        var menus = getMenuItemCount(menu);
        height = menuItem.renderedHeight * menus;
    }
    else
    {
        var height = menu.offsetHeight;
    }
    
    shim.style.width = width;
    shim.style.height = height;
    shim.style.top = menu.style.top;
    shim.style.left = menu.style.left;
    shim.style.zIndex = menu.style.zIndex - 1;
    
    shim.style.position = "absolute";
    shim.style.display = "block";
}

//Closes the shim associated with the menu
function closeShim(menu)
{
    if (menu==null) return;
    var shim = getShim(menu);
    if (shim!=null) shim.style.display = "none";
}

//Creates a new shim for the menu
function createMenuShim(menu)
{
    if (menu==null) return null;

    //var shim = document.createElement("<div scrolling='no' frameborder='5'"+
    //                                  "style='position:absolute; top:0px;"+
    //                                  "left:0px; display:none'></div>"); 
    var shim = document.createElement("div");
    shim.name = getShimId(menu);
    shim.id = getShimId(menu);
    //Unremark this line if you need your menus to be transparent for some reason
    //shim.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";

    if (menu.offsetParent==null || menu.offsetParent.id=="") 
    {
        window.document.body.appendChild(shim);
    }
    else 
    {
        menu.offsetParent.appendChild(shim); 
    }
    return shim;
}

//Creates an id for the shim based on the menu id
function getShimId(menu)
{
    if (menu.id==null) return "__shim";
    return "__shim"+menu.id;
}

//Returns the shim for a specific menu
function getShim(menu)
{
    return document.getElementById(getShimId(menu));
}

function getMenuItemCount(menu)
{
    var count = 0;
    var child = menu.firstChild;

    while (child)
    {
        if (child.nodeName=="DIV") count = count + 1;
        child = child.nextSibling;
    }
    return count;    
}


function printPortlet(appPath)
{
   var pageString = appPath+'/print/printPage.faces';
   var printWindow = window.open(pageString, 'PrintPage', "toolbar=no,location=no,scrollbars=yes,resizable,width=800,height=650'");
   //printWindow.setTimeout("modifyPrint()",1000);
   printWindow.focus();
}

function modifyPrint(){
    var srcDocument =  self.opener.document.getElementById('printBodyID').cloneNode(true);
    //Convert Links to normal text.
    var links = srcDocument.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {
     	var linkNode = links[i];
      	linkNode.removeAttribute("href");
     	linkNode.removeAttribute("onclick");
    	linkNode.removeAttribute("title");
   		linkNode.setAttribute("class","nolink");
   }
    //Remove alt from images.
    var images = srcDocument.getElementsByTagName("img");
    for (var i = 0; i < images.length; i++) {
     	var theimg = images[i];
   		theimg.removeAttribute("alt");
    }
	
    //Remove link from span.
    var allspans = srcDocument.getElementsByTagName("span");
    for (var i = 0; i < allspans.length; i++) {
     	var spanNode = allspans[i];
     	if(spanNode.getAttribute("onclick")){
	     	spanNode.setAttribute("onmouseover","none");
	     	spanNode.removeAttribute("onmouseover");
	     	spanNode.removeAttribute("onmouseout");
	     	spanNode.removeAttribute("onclick");
	    	spanNode.removeAttribute("title");
	    	var theStyle = spanNode.getAttribute("style");
	    	if(theStyle){
	    		theStyle = theStyle.toString();
	    		var newStyle = theStyle.replace("pointer","auto");
		     	spanNode.setAttribute("style",newStyle);
	    	}
    	}
    }
	
	
	
   document.getElementById('portletHtml').innerHTML =   srcDocument.innerHTML;
   window.print();
}

function showPrintEmailIcons(){
	var printDiv = document.getElementById('printBodyID');
	if( document.getElementById('printBodyID') != null){
			if(document.getElementById('idPrintEmail'))
				document.getElementById('idPrintEmail').style.display='block';
			if(document.getElementById('idPrint'))
				document.getElementById('idPrint').style.display='block';
			if(document.getElementById('idEmail'))
				document.getElementById('idEmail').style.display='block';
	}
}

function showPrintIconsOnly(){
	var printDiv = document.getElementById('printBodyID');
	if( document.getElementById('printBodyID') != null){
			if(document.getElementById('idPrintEmail'))
				document.getElementById('idPrintEmail').style.display='block';
			if(document.getElementById('idPrint'))
				document.getElementById('idPrint').style.display='block';
	}
}

/*
----------------------------------------------------------------------
menufx.js
----------------------------------------------------------------------
*/

var menufx_menuClassRegex = new RegExp("bea-portal-book-primary-menu-single-item(?:-active)?$");

function initRolloverMenus()
{
    var listItems = document.getElementsByTagName('li');
    for (var i = 0; i < listItems.length; i++)
    {
        if (listItems[i].className && listItems[i].className.match(menufx_menuClassRegex))
        {
            initRolloverMenu(listItems[i]);
        }
    }
}

function initRolloverMenu(listItem)
{
    var image = getImage(listItem);

    if (image && image.src && image.longDesc)
    {
        image.rollOffSrc = image.src;
        image.rollOnSrc = image.longDesc;

        image.fxEnabled = true;
        addEventToElement(image, "mouseover", fxRollIn, true);
        addEventToElement(image, "mouseout", fxRollOut, true);
    }
}

function getImage(listItem)
{
    var image;
    var images = listItem.getElementsByTagName("img");
    if (images && images.length == 1)
    {
        image = images[0];
    }

    return image;
}

function fxRollIn(event)
{
    var image = getEventSource(getEvent(event));
    if (image && image.rollOnSrc && image.fxEnabled)
    {
        image.src = image.rollOnSrc;
    }
}

function fxRollOut(event)
{
    var image = getEventSource(getEvent(event));
    if (image && image.rollOffSrc && image.fxEnabled)
    {
        image.src = image.rollOffSrc;
    }
}


