/*
* Last edited by:  $Author: miazh $
*             on:  $Date: 2009/11/24 15:40:01 $
*       Filename:  $RCSfile: custom.js,v $
*       Revision:  $Revision: 1.4 $
*/
/*
* Last edited by:  $Author: miazh $
*             on:  $Date: 2009/11/24 15:40:01 $
*       Filename:  $RCSfile: custom.js,v $
*       Revision:  $Revision: 1.4 $
*/

/*global document, window, navigator, escape, unescape */

// ************************************************************************************************
// begin custom.js
// ************************************************************************************************

// ************************************************************************************************
// begin custom functions and variables
// ************************************************************************************************
var LINEHEIGHT = 25;
var IFRAMEWIDTH = 168 + 'px';

var LINEHEIGHT_C = 16;
var IFRAMEWIDTH_C = 122 + 'px';

var sfHover = function() 
{
	if(document.getElementById("nav") == undefined)
	{
		return;
	}
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		
	for (var i=0; i<sfEls.length; i++) 
	{
		sfEls[i].onmouseover=function() 
		{
			this.className+=" sfhover";
			if(this.parentNode.id == 'nav') 
			{
				numLIs = this.getElementsByTagName('li').length;
				// LINEHEIGHT includes the border-bottom of each li
				// However, the last li does not have a border, we need to subtract 1
				// 
				this.getElementsByTagName('iframe')[0].style.height = (LINEHEIGHT * numLIs - 1) + 'px';
				this.getElementsByTagName('iframe')[0].style.width = IFRAMEWIDTH;
				this.getElementsByTagName('iframe')[0].style.display = 'block';
			}
		};
		sfEls[i].onmouseout=function() 
		{
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
			if(this.parentNode.id == 'nav') 
			{
				this.getElementsByTagName('iframe')[0].style.display = 'none';
			}
		};
	}
}; // end var sfHover = function()

if(window.attachEvent) 
{
    window.attachEvent("onload", sfHover);
}

var sfHover2 = function(test) 
{
	var sfEls = test.getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) 
	{
		sfEls[i].onmouseover=function() 
		{
			this.className+=" sfhover";
			if(this.parentNode.className == 'nav') 
			{
				numLIs = this.getElementsByTagName('li').length;
				this.getElementsByTagName('iframe')[0].style.height = (LINEHEIGHT_C * numLIs) + 'px';
				this.getElementsByTagName('iframe')[0].style.width = IFRAMEWIDTH_C;
				this.getElementsByTagName('iframe')[0].style.display = 'block';
			}
		};
		sfEls[i].onmouseout=function() 
		{
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
			if(this.parentNode.className == 'nav') 
			{
				this.getElementsByTagName('iframe')[0].style.display = 'none';
			}
		};
	}
}; //end var sfHover2 = function(test)
	
function init() 
{
	temp = getElementsByClassName(document, 'nav');
	for(var i=0; i<temp.length; i++)
	{
		sfHover2(temp[i]);
	}
	/* Tab initialization */
	allTabs = getElementsByClassName(document, 'anchors');
	for(k=0; k < allTabs.length; k++) 
	{
		if(allTabs[k].id) 
		{
			$.tabs(allTabs[k].parentNode.id, parseInt(allTabs[k].id, 10));
		} 
		else 
		{
			$.tabs(allTabs[k].parentNode.id);
		}
	}		
} // end function init()
	
/*SIMILAR TO getElementById()*/
function getElementsByClassName(node, classname)
{
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	{
		if(re.test(els[i].className))
		{
		    a.push(els[i]);
		}
    }
	return a;
} // end function getElementsByClassName(node, classname)

if(window.attachEvent)
{
    window.attachEvent("onload", init);
}

/* resize margin-bottom for main */

/* Returns the height of the current window, handles different ways the browsers handle this */
function getWindowHeight() 
{
	var windowHeight = 0;
	if(typeof(window.innerHeight) == 'number') 
	{
	    // FireFox, Safari and who knows what else?
		windowHeight = window.innerHeight;
	}
	else 
	{
		if(document.documentElement && document.documentElement.clientHeight) 
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else 
		{
			if(document.body && document.body.clientHeight) 
			{
				// Internet Explorer wobbles down to here
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
} // end function getWindowHeight()

/* Positions the footer at the bottom of the page, or the bottom of the screen if content is short */
function positionFooter() 
{
	if(document.getElementById) 
	{
		var windowHeight = getWindowHeight();
		if(windowHeight > 0) 
		{
		    // The 'content height' is a combination of the heights of several div tags (which may or may not be present)
		    var totalContentHeight = 0;
		    
		    var mastheadHeight = document.getElementById('mastheadWrapper').offsetHeight;
		    if(mastheadHeight) 
		    {
		        totalContentHeight = totalContentHeight + mastheadHeight;
		    }
		    
		    var topNavWrapperGlobalHeight = document.getElementById('topNavWrapperGlobal').offsetHeight;
		    if(topNavWrapperGlobalHeight)
		    {
		        totalContentHeight = totalContentHeight + topNavWrapperGlobalHeight;
		    }
		    
		    // Reset the height so resizing works
		    var mainDiv = document.getElementById('main');
		    mainDiv.style.height = 0;
		    
		    var mainHeight = mainDiv.offsetHeight;
		    if(mainHeight == 0)
		    {
		        mainHeight = mainDiv.parentNode.offsetHeight - mainDiv.offsetTop;
		    }
	        totalContentHeight = totalContentHeight + mainHeight;
					    
			var footerElement = document.getElementById('footerWrapper');
			var footerHeight = footerElement.offsetHeight;
			
			var windowOffset = windowHeight - (totalContentHeight + footerHeight);
//			alert ('window height: ' + windowHeight + '; masthead height: ' + mastheadHeight + '; topNavWrapperGlobal Height: ' + topNavWrapperGlobalHeight + '; main height: ' + mainHeight + '; total height: ' + totalContentHeight + '; footer height: ' + footerHeight + '; offset: ' + windowOffset);
			if(windowOffset >= 0) 
			{
			    if(typeof(window.innerHeight) == 'number') 
			    {
			    	// Non-IE
			    	mainDiv.style.height = mainHeight;	
			    	mainDiv.style.paddingBottom = windowOffset + 'px';
			    }
			    else 
			    {
			    	// IE
			    	mainDiv.style.marginBottom = windowOffset + 'px';
			    }
			}
		}
	}
} // end function positionFooter()

function checkHeight(layout)
{
	positionFooter();
} // end function checkHeight(layout)

function changeHeight(layout)
{
	positionFooter();
} // end function changeHeight(layout)

function interceptOnLoad(layout) 
{
    var is_mac = (navigator.userAgent.indexOf("Mac") != -1);
    if(document.all && !is_mac) 
    {
        fnInit();
    }
    checkHeight(3);
} // end function interceptOnLoad(layout) 

/*
function getElementsByClassName(node, classname) 
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
    {
        if(re.test(els[i].className))
        {
            a.push(els[i]);
        }
    }
    return a;
}
*/

// Used for alternating/highlighting tables  
// when the page loads it sees how each table is tagged and then gives
// it the appropriate highlighting/alternating colors...
// for example: 
//			table class='tableLines' id='tableShade' = alternating tr colors
//			table class='tableLines' id='tableHighlight' = mouseover highlighting of trs
//			table class='tableLines' id='' = no tr colors, no highlighting
//			table class='tableAllLines' id='tableShade' = alternating tr colors
//			table class='tableAllLines' id='tableHighlight' = mouseover highlighting of trs
function alternate()
{
	// ALL TABLES W/ CLASS tableLines ----------------------
	tables = getElementsByClassName(document, 'tableLines');
	for(i = 0; i<tables.length; i++)
	{
	// sets array of all trs within tables with className tableLines
	trs = tables[i].getElementsByTagName('tr');
		// CLASS = tableLines ---- ID = 'tableShade'
		if(tables[i].id == 'tableShade')
		{
			reverseShade = 1;
			
			for(k = 0; k < trs.length; k++)
			{
				if(trs[k].getElementsByTagName('th').length > 0)
				{
					reverseShade = 1;
				} 
				else 
				{
					reverseShade = 0;
				}
			if(reverseShade == 1) 
			{
				if(k != 0) 
				{
					if((k%2) == 0)
					{
						trs[k].className = "odd";
					} 
					else 
					{
						trs[k].className = "even";
					}
				}
			} else {
				if(k != 0) {
					if((k%2) == 0)
					{
						trs[k].className = "even";
					} 
					else 
					{
						trs[k].className = "odd";
					}
				}
			}
			}
		} 
		// CLASS = tableLines ---- ID = 'tableHighlight'
		else if(tables[i].id == 'tableHighlight')
		{
			for(k = 0; k < trs.length; k++)
			{
				if(k != 0) {
					if(trs[k].className == "") {
						trs[k].onmouseover = function()
						{
							this.className = "even";
						};
						trs[k].onmouseout = function()
						{
							this.className = "odd";
						};
					}
				}
			}
		}
	}
	
	// ALL TABLES W/ CLASS tableAllLines ----------------------
	tableAlls = getElementsByClassName(document, 'tableAllLines');
	for(l = 0; l<tableAlls.length; l++)
	{
		// sets array of all trs within tables with className = 'tableAllLines'
		trsAll = tableAlls[l].getElementsByTagName('tr');
		// CLASS = tableAllLines ---- ID = 'tableShade'
		if(tableAlls[l].id == 'tableShade')
		{
			reverseShade = 1;
			for(m = 0; m < trsAll.length; m++)
			{
				if(trsAll[m].getElementsByTagName('th').length > 0)
				{
					reverseShade = 1;
				} 
				else 
				{
					reverseShade = 0;
				}
			if(reverseShade == 1) {
				if(m != 0) {
					if((m%2) == 0)
					{
						trsAll[m].className = "even";
					} 
					else 
					{
						trsAll[m].className = "odd";
					}
				}
			} else {
					if(m != 0) {
						if((m%2) == 0)
						{
							trsAll[m].className = "odd";
						} 
						else 
						{
							trsAll[m].className = "even";
						}
					}
				}
			}
		}
		// CLASS = tableAllLines ---- ID = 'tableHighlight'
		else if(tableAlls[l].id == 'tableHighlight')
		{
			for(m = 0; m < trsAll.length; m++)
			{
				if(m != 0) {
					if(trsAll[m].className == "") {
						trsAll[m].onmouseover = function()
						{
							this.className = "even";
						};
						trsAll[m].onmouseout = function()
						{
							this.className = "odd";
						};
					}
				}
			}
		}
	}
} // end function alternate()

// Toggles Font-Size and Line-Height on content pages.
function changeLabel(toggle)
{
	if(document.getElementById("puText"))
	{
		// Number of <li> tags in the document, as well as an array containing references
		var LI_length = document.getElementById("columnMain").getElementsByTagName("li").length;
		var LI_arr = document.getElementById("columnMain").getElementsByTagName("li");
		
		// Number of <p> tags in the document, with an array of references
		var P_length = document.getElementById("columnMain").getElementsByTagName("p").length;
		var P_arr = document.getElementById("columnMain").getElementsByTagName("p");
		
		// Toggles the Text Size Icon and resizes text
		if(toggle == 'large')
		{
			document.getElementById("puText").className = "iconTextEnlarge";
			document.getElementById("puText").innerHTML = "smaller type";
			document.getElementById("puText").href = "javascript:changeLabel('small');";
			// Change all <li>s lineHeight to greater percentage
				for(k = 0; k < LI_length; k++)
				{ 
					if(LI_arr[k].className == 'anchors') 
					{
						LI_arr[k].style.lineHeight = "150%";
						LI_arr[k].style.fontSize = "110%";
					}
				}
			// Change all <p>s lineHeight to greater percentage
				for(j = 0; j < P_length; j++)
				{ 
					P_arr[j].style.lineHeight = "150%";
					P_arr[j].style.fontSize = "110%";
				}
			createCookie('textSize', 'large', 30);
		} 
		else 
		{
			document.getElementById("puText").className = "iconTextEnlarge";
			document.getElementById("puText").innerHTML = "larger type";
			document.getElementById("puText").href = "javascript:changeLabel('large');";
			document.getElementById("columnMain").style.fontSize = "";
			// Change all <li>s back to default lineHeight
			for(k = 0; k < LI_length; k++)
			{ 
				LI_arr[k].style.lineHeight = ""; 
				LI_arr[k].style.fontSize= ""; 
			}
			// Change all <p>s back to default lineHeight
			for(j = 0; j < P_length; j++)
			{ 
				P_arr[j].style.lineHeight = ""; 
				P_arr[j].style.fontSize = ""; 
			}
			createCookie('textSize', 'small', 30);
		}
	}
} // end function changeLabel(toggle)

// Used to set a cookie with the user's font-size preference
function createCookie(name,value,days)
{
    var expires;
	if(days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else 
	{
	    expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
	//alert('Cookie\n' + name + '\ncreated with a value ' + value);
} // end function createCookie(name,value,days)

// Returns the cookie value
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') 
		{
		    c = c.substring(1,c.length);
		}
		if(c.indexOf(nameEQ) == 0) 
		{
		    return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
} // end function readCookie(name)

// Used onLoad to set document text size
function userTextSize()
{
	size = readCookie('textSize'); 
	changeLabel(size);
} // end function userTextSize()

// Select Box Links
// Purpose: To make the option values in a select menu links.
// Useage: 	Place 'onchange="selectLinks('parent',this,0)' in the <select> tag
//			and give each <option> a value parameter which will serve as the link
// Example:
//		<select style="width: 100%;" onchange="selectLinks('parent',this,0)">
//			<option selected>Select Prospectus</option>
//			<option value="http://www.ml.com">ML Large Cap Core Fund</option>
//			<option value="http://www.website.org">ML Bond Fund - Core Bond Portfolio</option>
//			<option value="http://www.website.com">ML Low Duration Fund </option>
//		</select>
function selectLinks(targ,selObj,restore)
{
	//alert('hi');
	//selObj.options[selObj.selectedIndex].value += "&cmty=" + community;
	//alert(selObj.options[selObj.selectedIndex].value);
	ddvalue = (selObj.options[selObj.selectedIndex].value)
	
	if(ddvalue == '') 
	{
		return;
	}
	else 
	{
	    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value + "'");
	    if(restore) 
	    {
	        selObj.selectedIndex = 0;
	    }
	}
} // end function selectLinks(targ,selObj,restore)

/* Cookie Redirect functions */

function goBlkSite(siteName, setCookie)
{
    if(typeof setCookie != 'undefined' && setCookie != null) 
    {
        rememberLocation(siteName);
    }

    window.document.location.href=siteName;
} // end function goBlkSite(siteName, setCookie)

function doRedirect(okSendGlobal) 
{
    var knownSite = getCookie('globalRedirectSite');

    if(knownSite != null && knownSite != 'null')
        goBlkSite(knownSite, true);

    else if(okSendGlobal)
        window.document.location.href="/global/home/index.htm";
} // end function doRedirect(okSendGlobal)

function rememberLocation(siteName)
{
    if(siteName != null && siteName != '')
    {
        setCookie('globalRedirectSite', siteName, 364, '/');
    }
    return 1;
} // end function rememberLocation(siteName)

function setCookie( name, value, expires, path, domain, secure ) 
{
    var today = new Date();
    today.setTime(today.getTime());

    if(expires) 
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }

    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
        (expires? ";expires=" + expires_date.toGMTString() : "" ) +
        (path? ";path=" + path : "" ) +
        (domain? ";domain=" + domain : "" ) +
        (secure? ";secure" : "" );
} // end function setCookie( name, value, expires, path, domain, secure ) 

function getCookie(name)
{
    var start = document.cookie.indexOf(name+"=");
    var len = start + name.length + 1;

    if(!start && name != document.cookie.substring(0,name.length))
        return null;

    if(start == -1)
        return null;

    var end = document.cookie.indexOf(";", len );

    if(end == -1)
        end = document.cookie.length;

    return unescape(document.cookie.substring(len, end));
} // end function getCookie(name)

/* End of Cookie Redirect function */
// ************************************************************************************************
// end custom functions and variables
// ************************************************************************************************

// ************************************************************************************************
// begin utility functions from common.js
// ************************************************************************************************
var g_listeners = [];

function setupEventListenersCleaner()
{
	if(typeof window.attachEvent !== "undefined")
	{
		window.attachEvent("onunload", function()
		{
			var len = g_listeners.length;
			//alert("listeners len before: " + g_listeners.length);
			for(var i = len - 1; i >= 0; --i)
			{
				g_listeners[i][0].detachEvent(g_listeners[i][1], g_listeners[i][2]);
			}
			g_listeners = [];
		});
	}
} // end function cleanupEventListeners()

setupEventListenersCleaner();

function addLoadListener(fn)
{
	if(typeof window.addEventListener !== "undefined")
	{
		window.addEventListener("load", fn, false);
	}
	else if(typeof document.addEventListener !== "undefined")
	{
        document.addEventListener("load", fn, false);
	}
	else if(typeof window.attachEvent !== "undefined")
	{
		window.attachEvent("onload", fn);
        g_listeners[g_listeners.length] = [window, "onload", fn];
	}
	else
	{
		var oldFn = window.onload;
		if(typeof window.onload !== "function")
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldFn();
				fn();
			};
		}
	}
} // end function addLoadListener(fn)

function randomBetween(min, max)
{
	return min + Math.floor(Math.random() * (max - min + 1));
} // end function randomBetween(min, max)

function getEventTarget(event)
{
	var targetElement = null;
	if(typeof event === "undefined")
	{
		event = window.event;
	}
	if(typeof event.target !== "undefined")
	{
		targetElement = event.target;
	}
	else
	{
		targetElement = event.srcElement;
	}
	while(targetElement.nodeType === 3 && targetElement.parentNode !== null)
	{
		targetElement = targetElement.parentNode;
	}
	return targetElement;
} // end function getEventTarget(event)

function getScrollingPosition()
{
	var scrollingPosition = [0, 0];
	
	if(typeof window.pageYOffset !== "undefined")
	{
		// ff
		//alert("ff");
		scrollingPosition = [window.pageXOffset, window.pageYOffset];
	}
	else if(typeof document.documentElement.scrollTop !== "undefined")
	{
		// ie
		//alert("ie documentelement");
		scrollingPosition = [document.documentElement.scrollLeft, document.documentElement.scrollTop];
	}
	else if(typeof document.body.scrollTop !== "undefined")
	{
		// ie
		//alert("ie body");
		scrollingPosition = [document.body.scrollLeft, document.body.scrollTop];
	}
	//alert("(" + scrollingPosition[0] + "," + scrollingPosition[0] + ")");
	return scrollingPosition;
} // end function getScrollingPosition()

function getCursorPosition(event)
{
	if(typeof event === "undefined")
	{
		event = window.event;
	}
	
	var scrollingPosition = getScrollingPosition();
	var cursorPosition = [0, 0];
	if(typeof event.pageX !== "undefined" &&
		typeof event.x !== "undefined")
	{
		cursorPosition[0] = event.pageX;
		cursorPosition[1] = event.pageY;
	}
	else
	{
		cursorPosition[0] = event.clientX + scrollingPosition[0];
		cursorPosition[1] = event.clientY + scrollingPosition[1];
	}
	return cursorPosition;
} // end function getCursorPosition(event)

function getViewportSize()
{
	var size = [0, 0];
	if(typeof window.innerWidth !== "undefined")
	{
		size = [window.innerWidth, window.innerHeight];
	}
	else if(typeof document.documentElement !== "undefined" && 
		typeof document.documentElement.clientWidth !== "undefined" && 
		document.documentElement.clientWidth !== 0)
	{
		size = [document.documentElement.clientWidth, document.documentElement.clientHeight];		
	}
	else
	{
		size = [document.getElementsByTagName("body")[0].clientWidth, 
			document.getElementsByTagName("body")[0].clientHeight];
	}
	return size;
} // end function getViewportSize()

function getPosition(theElement)
{
	var positionX = 0;
	var positionY = 0;
	while(theElement !== null)
	{
		positionX += theElement.offsetLeft;
		positionY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}
	return [positionX, positionY];
} // end function getPosition(theElement)

function getPageDimensions()
{
	var body = document.getElementsByTagName("body")[0];
	var bodyOffsetWidth = 0;
	var bodyOffsetHeight = 0;
	var bodyScrollWidth = 0;
	var bodyScrollHeight = 0;
	var pageDimensions = [0, 0];

	if(typeof document.documentElement !== "undefined" &&
		typeof document.documentElement.scrollWidth !== "undefined")
	{
		pageDimensions[0] = document.documentElement.scrollWidth;
		pageDimensions[1] = document.documentElement.scrollHeight;
	}
	bodyOffsetWidth = body.offsetWidth;
	bodyOffsetHeight = body.offsetHeight;
	bodyScrollWidth = body.scrollWidth;
	bodyScrollHeight = body.scrollHeight;
	if(bodyOffsetWidth > pageDimensions[0])
	{
		pageDimensions[0] = bodyOffsetWidth;
	}
	if(bodyOffsetHeight > pageDimensions[1])
	{
		pageDimensions[1] = bodyOffsetHeight;
	}
	if(bodyScrollWidth > pageDimensions[0])
	{
		pageDimensions[0] = bodyScrollWidth;
	}
	if(bodyScrollHeight > pageDimensions[1])
	{
		pageDimensions[1] = bodyScrollHeight;
	}
	return pageDimensions;
} // end function getPageDimensions()

function findClass(target, classValue)
{
	var className = target.className;
	var pattern = new RegExp("(^| )" + classValue + "( |$)");
	if(pattern.test(className))
	{
		return true;
	}
	return false;
} // end function findClass(target, classValue)

// ************************************************************************************************
// end utility functions from common.js
// ************************************************************************************************

// ************************************************************************************************
// begin namespace
// ************************************************************************************************
if(typeof BLK === "undefined")
{
	var BLK = {};
	BLK.EBIZ = {};
	BLK.BRS = {};
}
// ************************************************************************************************
// end namespace
// ************************************************************************************************

// ************************************************************************************************
// begin modal dialog
// ************************************************************************************************

/*global BLK, document, getElementsByClassName, getEventTarget, getPageDimensions, 
getScrollingPosition, getViewportSize, window , findClass, navigator*/

BLK.EBIZ.ModalDialog3 = function ()
{
	var that = this;
	this.configuration = {"width":700, "height":300, "minWidth":128, "minHeight":128, "maxWidth":1024, "maxHeight":768};
	this.setup = function ()
	{
        var i = 0;
        var j = 0;
        var k = 0;
		var modalDialogDatumRef = null;
		var modalDialogLinkList = getElementsByClassName(document.body, "modalDialogLink");
		for(i = 0; i < modalDialogLinkList.length; i++)
		{
		    // validate links and associated data blocks
		    if(modalDialogLinkList[i].nodeName.toLowerCase() !== "a")
		    {
		        //window.alert("is not <a>");
		        continue;
		    }
		    if(modalDialogLinkList[i].rel === "")
		    {
		        //window.alert("rel is empty");
		        continue;
		    }
		    modalDialogDatumRef = document.getElementById(modalDialogLinkList[i].rel);
		    if(modalDialogDatumRef === null)
		    {
		        //window.alert("invalid rel");
		        continue;
		    }
		    if(modalDialogDatumRef.nodeName.toLowerCase() !== "div")
		    {
		        //window.alert("datum is not <div>");
		        continue;
		    }
		    if(!findClass(modalDialogDatumRef, "modalDialogDatum"))
		    {
		        //window.alert("datum is wrong class");
		        continue;
		    }
		    
		    // create modal dialog handler
		    modalDialogLinkList[i].onclick = function (modalDialogDatumRef, configuration)
		    {
		        return function (event)
		        {
				    var isIe = false;
				    if(typeof event === "undefined")
				    {
					    isIe = true;
					    event = window.event;
				    }
				    var targetElement = getEventTarget(event);

                    // validate dimensions
                    var width = 0;
                    var height = 0;
                    var dimensionArray = [];
                    if(this.rev === "")
                    {
                        //width = configuration.width;
                        //height = configuration.height;
                        width = -1;
                        height = -1;
                    }
                    else
                    {
                        dimensionArray = this.rev.split(",");
                        if(dimensionArray.length === 2)
                        {
                            if(isNaN(parseInt(dimensionArray[0], 10)) || isNaN(parseInt(dimensionArray[1], 10)))
                            {
                                //width = configuration.width;
                                //height = configuration.height;
                                width = -1;
                                height = -1;
                            }
                            else
                            {
                                width = parseInt(dimensionArray[0], 10);
                                height = parseInt(dimensionArray[1], 10);
                            
                                if(width < configuration.minWidth || height < configuration.minHeight)
                                {
                                    //width = configuration.width;
                                    //height = configuration.height;
                                    width = -1;
                                    height = -1;
                                }
                                else if(width > configuration.maxWidth || height > configuration.maxHeight)
                                {
                                    //width = configuration.width;
                                    //height = configuration.height;
                                    width = -1;
                                    height = -1;
                                }
                                else
                                {
                                    width = parseInt(dimensionArray[0], 10);
                                    height = parseInt(dimensionArray[1], 10);
                                }
                            }
                        }
                        else
                        {
                            //width = configuration.width;
                            //height = configuration.height;
                            width = -1;
                            height = -1;
                        }
                    }
                    var title = this.title;
                    
					that.createDialog(modalDialogDatumRef, isIe, width, height, title);
                    
                    return false;		    
		        }; // end return function (event)
		    }(modalDialogDatumRef, this.configuration);
		} // end for(i = 0; i < modalDialogLinkList.length; i++)
		
		// scroll/resize event handler
		var fxn = function (event)
		{
			if(typeof event === "undefined")
			{
				event = window.event;
			}

			try
			{
		        var containerList = getElementsByClassName(document.body, "modalDialogGadgetContainer");
		        var dropSheetRef = document.getElementById("modalDialogGadgetDropSheet");

		        if(containerList.length < 1)
		        {
		            return false;
		        }
		        if(dropSheetRef === null)
		        {
		            return false;
		        }

                var containerRef = containerList[0];
                var pageDimensions = getPageDimensions();
		        var viewportSize = getViewportSize();
		        var scrollingPosition = getScrollingPosition();
		        var containerHeight = containerRef.offsetHeight;
		        var containerWidth = containerRef.offsetWidth;

		        //document.title = getScrollingPosition() + "||" + getViewportSize() + "||" + "(" + containerWidth + "," + containerHeight + ")";

		        var offsetLeft = scrollingPosition[0] + (viewportSize[0] / 2) - (containerRef.offsetWidth / 2);
		        var offsetTop = scrollingPosition[1] + (viewportSize[1] / 2) - (containerRef.offsetHeight / 2);

		        // position popup
		        containerRef.style.left = offsetLeft + "px";
		        containerRef.style.top = offsetTop + "px";

                // resize drop sheet
                dropSheetRef.style.width = pageDimensions[0] + "px";
                dropSheetRef.style.height = pageDimensions[1] + "px";
		    }
		    catch(ex)
		    {
		        var message = "";
		        for(var i in ex)
		        {
		            message += i + ": " + ex[i]+ "\n";
		        }
		        //window.alert("An exception occurred.\n\n" + "Name: " + ex.name + "Message: " + ex.message);
		        window(message);
		    }
		    return true;
		}; // end var fxn = function (event)
		
	    var isIE = (typeof document.all !== "undefined" && typeof window.opera === "undefined" && navigator.vendor !== "KDE");
	    if(isIE)
	    {
	        // ie7
            document.body.onscroll = fxn;
            // ie6
            window.onscroll = fxn;
            
            document.body.onresize = fxn;
	    }
	    else
	    {
            window.onscroll = fxn;
            window.onresize = fxn;
	    }
		
		return true;
    }; // end this.setup = function ()
    
	this.createDialog = function (modalDialogGadgetRef, isIe, width, height, title)
	{
		var that = this;
		var bodyRef = document.getElementsByTagName("body")[0];

        var showTitle = findClass(modalDialogGadgetRef, "modalDialogGadgetShowTitle");
        var showCloseButton = findClass(modalDialogGadgetRef, "modalDialogGadgetShowCloseButton");
        var showFooter = findClass(modalDialogGadgetRef, "modalDialogGadgetShowFooter");

		// disable <select> drop downs
		// b/c ie bug
		
		//var selectList = document.getElementsByTagName("select");
		//for(var i = 0; i < selectList.length; i++)
		//{
		//	selectList[i].disabled = "disabled";
		//}
		
		var scrollingPosition = [0,0];
		var widthOfBalloon = 0;
		var heightOfBalloon = 0;
		
		var pageDimensions = getPageDimensions();
		var viewportSize = getViewportSize();
		
		if(viewportSize[1] > pageDimensions[1])
		{
			pageDimensions[1] = viewportSize[1];
		}

        var MIN_ZINDEX = 99997;
		
		// ****************************************************************************************
		// begin prepare dropsheet
		// ****************************************************************************************
		var dropSheet = document.createElement("div");
		dropSheet.onclick = function (event)
		{
			if(typeof event === "undefined")
			{
				event = window.event;
			}
			var target = getEventTarget(event);
			that.closeDialog();
			return false;
		}; // end dropSheet.onclick = function (event)

		dropSheet.onkeyup = function (event)
		{
			if(typeof event === "undefined")
			{
				event = window.event;
			}
			var target = getEventTarget(event);
			var key;
			if(event.keyCode)
			{
				key = event.keyCode;
			}
			else
			{
				key = event.which;
			}	
			if(key === 27)
			{
				// esc
				that.closeDialog();
				return false;
			}
			else
			{
				return true;
			}
		}; // end dropSheet.onkeyup = function (event)

		dropSheet.setAttribute("id", "modalDialogGadgetDropSheet");
		dropSheet.style.position = "absolute";
		dropSheet.style.left = "0";
		dropSheet.style.top = "0";
		
		dropSheet.style.width = pageDimensions[0] + "px";
		dropSheet.style.height = pageDimensions[1] + "px";
		
		dropSheet.style.zIndex = MIN_ZINDEX;
		bodyRef.appendChild(dropSheet);
		// ****************************************************************************************
		// end prepare dropsheet
		// ****************************************************************************************

		var div = null;
		var a = null;
		var text = null;
		var ul = null;
		var li = null;
		var input = null;
		var button = null;
		var label = null;
		var span = null;
		var table = null;
		var tr = null;
		var td = null;
		
		var iframe;
		var divContainer;
		
		var divBody;
		var divHeader;
		var divFooter;
		var divAction;
		var divClear;
		var divLeft;
		var divRight;

		var iFrame_zIndex = MIN_ZINDEX + 1;
		// ****************************************************************************************
		// create iframe to combat ie z-index problem
		
		if(isIe)
		{
			iframe = document.createElement("iframe");
			iframe.style.position = "absolute";
			iframe.style.border = "0";
			iframe.style.zIndex = iFrame_zIndex;
			iframe.style.backgroundColor = "lime";
			iframe.style.opacity = "1";
			iframe.style.filter = "alpha(opacity=100)";
			iframe.style.filter = "mask()";
			iframe.className = "modalDialogGadgetIFrame";
		}
		
		// ****************************************************************************************

		// container
		divContainer = document.createElement("div");
		divContainer.className = "modalDialogGadgetContainer";
		divContainer.style.position = "absolute";
		divContainer.style.visibility = "hidden";
		divContainer.style.zIndex = MIN_ZINDEX + 2;
		
		
        if(modalDialogGadgetRef.title !== "")
        {
            if(document.getElementById(modalDialogGadgetRef.title) !== null)
            {
                divContainer.id = modalDialogGadgetRef.title + "Container";
            }
        }
		
		//window.alert(width);
		// set width with css
		if(width > 0)
		{
		    divContainer.style.width = width + "px";
		}
		
		// ****************************************************************************************
		// header begin
		// ****************************************************************************************
		if(showTitle || showCloseButton)
		{
		    divHeader = document.createElement("div");
		    divHeader.className = "modalDialogGadgetContainerHeader";
		    
		    
            if(modalDialogGadgetRef.title !== "")
            {
                if(document.getElementById(modalDialogGadgetRef.title) !== null)
                {
                    divHeader.id = modalDialogGadgetRef.title + "ContainerHeader";
                }
            }
		    

            // title
            if(showTitle)
            {
		        divLeft = document.createElement("div");
		        divLeft.className = "modalDialogGadgetContainerHeaderLeft";

		        span = document.createElement("span");
		        span.className = "modalDialogGadgetContainerHeaderTitle";

	            text = document.createTextNode(title);
		        span.appendChild(text);

		        divLeft.appendChild(span);
		        divHeader.appendChild(divLeft);
		    } // end if(showTitle)
		    
		    // close button
		    if(showCloseButton)
		    {
		        divRight = document.createElement("div");
		        divRight.className = "modalDialogGadgetContainerHeaderRight";

		        a = document.createElement("a");
		        a.href = "#nogo";
		        a.className = "modalDialogGadgetContainerHeaderCloseButton";
		        a.title = "Close";
		        a.onclick = function (event)
		        {
			        if(typeof event === "undefined")
			        {
				        event = window.event;
			        }
			        var target = getEventTarget(event);
			
			        that.closeDialog();
			
			        return false;
                }; // end input.onclick = function (event)

		        divRight.appendChild(a);
		        divHeader.appendChild(divRight);
		    } // end if(showCloseButton)


		    divClear = document.createElement("div");
		    divClear.style.clear = "both";

		    divHeader.appendChild(divClear);
		} // end if(showTitle || showCloseButton)

		// ****************************************************************************************
		// header end
		// ****************************************************************************************

		// ****************************************************************************************
		// body begin
		// ****************************************************************************************
		divBody = document.createElement("div");
		divBody.className = "modalDialogGadgetContainerBody";
		
		
		// set height with css
		if(height > 0)
		{
		    divBody.style.height = height + "px";
		}
		
		
		var modalDialogGadgetBodyList = modalDialogGadgetRef;
		var innerHTML = "";
        
        innerHTML = modalDialogGadgetRef.innerHTML;
        
        //window.alert(modalDialogGadgetRef.title);
        if(modalDialogGadgetRef.title !== "")
        {
            if(document.getElementById(modalDialogGadgetRef.title) !== null)
            {
                divBody.id = modalDialogGadgetRef.title + "ContainerBody";
            }
        }
        
		divBody.innerHTML = innerHTML;
		// ****************************************************************************************
		// body end
		// ****************************************************************************************

		// ****************************************************************************************
		// footer begin
		// ****************************************************************************************
		if(showFooter)
		{
		    divFooter = document.createElement("div");
		    divFooter.className = "modalDialogGadgetContainerFooter";
		    //divFooter.cssFloat = "left";


            if(modalDialogGadgetRef.title !== "")
            {
                if(document.getElementById(modalDialogGadgetRef.title) !== null)
                {
                    divFooter.id = modalDialogGadgetRef.title + "ContainerFooter";
                }
            }


		    // previous button
		    /*
		    input = document.createElement("input");
		    input.setAttribute("type", "button");
		    input.className = "modalDialogGadgetContainerFooterPreviousButton";
		    input.setAttribute("value", "<< Previous");
		    input.title = "Previous. . .";
		    input.onclick = function (event)
		    {
			    if(typeof event === "undefined")
			    {
				    event = window.event;
			    }
			    var target = getEventTarget(event);
			
			    window.alert("Previous. . .");
			
			    return false;
		    };
		    divFooter.appendChild(input);
		    */

		    // next button
		    /*
		    input = document.createElement("input");
		    input.setAttribute("type", "button");
		    input.className = "modalDialogGadgetContainerFooterNextButton";
		    input.setAttribute("value", "Next >>");
		    input.title = "Next. . .";
		    input.onclick = function (event)
		    {
			    if(typeof event === "undefined")
			    {
				    event = window.event;
			    }
			    var target = getEventTarget(event);
			
			    window.alert("Next. . .");
			
			    return false;
		    };
		    divFooter.appendChild(input);
		    */

		    // close button
		    /*
		    input = document.createElement("input");
		    input.setAttribute("type", "button");
		    input.className = "modalDialogGadgetContainerFooterCloseButton";
		    input.setAttribute("value", "Close");
		    input.title = "Close";
		    input.onclick = function (event)
		    {
			    if(typeof event === "undefined")
			    {
				    event = window.event;
			    }
			    var target = getEventTarget(event);
			
			    that.closeDialog();
			
			    return false;
		    };
		    divFooter.appendChild(input);
            */		    
		    
		    
		    a = document.createElement("a");
		    a.href = "#nogo";
		    text = document.createTextNode("Close");
		    a.appendChild(text);
		    a.className = "modalDialogGadgetContainerFooterCloseButton";
		    a.title = "Close";
		    a.onclick = function (event)
		    {
			    if(typeof event === "undefined")
			    {
				    event = window.event;
			    }
			    var target = getEventTarget(event);
			
			    that.closeDialog();
			
			    return false;
		    }; // end a.onclick = function (event)
		    divFooter.appendChild(a);
		} // end if(showFooter)
		// ****************************************************************************************
		// footer end
		// ****************************************************************************************
		
		if(showTitle || showCloseButton)
		{
		    divContainer.appendChild(divHeader);
		}
		divContainer.appendChild(divBody);
		if(showFooter)
		{
		    divContainer.appendChild(divFooter);
		}
		

		bodyRef.appendChild(divContainer);
		
		scrollingPosition = getScrollingPosition();
		viewportSize = getViewportSize();
		
		// make visible to obtain height and width
		divContainer.style.visibility = "visible";
		//divGadget.style.display = "block";
		
		//divContainer.style.width = that.configuration.width + "px";
		//divContainer.style.height = that.configuration.height + "px";
        
        var offsetWidth = parseInt(divContainer.offsetWidth, 10);
        var offsetHeight = parseInt(divContainer.offsetHeight, 10);
        
        // make hidden to set position
		divContainer.style.visibility = "hidden";
		//divGadget.style.display = "none";
        
        //document.title = "width:" + widthOfBalloon + "|"+ "height:" + heightOfBalloon;
		
		var offsetLeft = scrollingPosition[0] + (viewportSize[0] / 2) - (offsetWidth / 2);
		var offsetTop = scrollingPosition[1] + (viewportSize[1] / 2) - (offsetHeight / 2);

		// position popup
		divContainer.style.left = offsetLeft + "px";
		divContainer.style.top = offsetTop + "px";
			
			
		// ****************************************************************************************
		// position and size iframe
		
		if(isIe)
		{
			iframe.style.top    = offsetTop + "px";
			iframe.style.left   = offsetLeft + "px";
			iframe.style.width  = offsetWidth + "px";
			iframe.style.height = offsetHeight + "px";
			
			divContainer.parentNode.insertBefore(iframe, divContainer);
		}
		
		// ****************************************************************************************
			
		// make popup visible			
		divContainer.style.visibility = "visible";
		//divGadget.style.display = "block";
	}; // end this.createDialog = function (modalDialogGadgetRef, isIe)
	
	this.closeDialog = function ()
	{
		var dialogGadgetList = getElementsByClassName(document.body, "modalDialogGadgetContainer");
		var parentNode = null;
		var i = 0;
		for(i = 0; i < dialogGadgetList.length; i++)
		{
			parentNode = dialogGadgetList[i].parentNode;
			parentNode.removeChild(dialogGadgetList[i]);
		}

		var dialogGadgetIFrameList = getElementsByClassName(document.body, "modalDialogGadgetIFrame");
		for(i = 0; i < dialogGadgetIFrameList.length; i++)
		{
			parentNode = dialogGadgetIFrameList[i].parentNode;
			parentNode.removeChild(dialogGadgetIFrameList[i]);
		}
		
		var dropSheetRef = document.getElementById("modalDialogGadgetDropSheet");
		dropSheetRef.parentNode.removeChild(dropSheetRef);
		
		// re-enable <select> drop downs
		// b/c ie bug
		//var selectList = document.getElementsByTagName("select");
		//for(i = 0; i < selectList.length; i++)
		//{
		//	selectList[i].disabled = "";
		//}
		
		//window.alert("on close. . .");
	};
    
	this.setup();
}; // end BLK.EBIZ.ModalDialog3 = function ()

function initModalDialog()
{
    if(typeof BLK.EBIZ.ModalDialog3 !== "undefined")
    {
        var dlg = new BLK.EBIZ.ModalDialog3();
    }
} // end function initModalDialog()
addLoadListener(initModalDialog);
// ************************************************************************************************
// end modal dialog
// ************************************************************************************************

function hideExpand(var1,var2) 
	{
			document.getElementById(var1).style.display = "none";
			document.getElementById(var2).style.display = "block";
	}

// ************************************************************************************************
// end custom.js
// ************************************************************************************************
