
	
	// Toggle Arrows in Collapsible Containers -- BEGIN 	
	var a1 = 0;
	var a2 = 0;
	var a3 = 0;
	var a4 = 0;
	var a5 = 0;
	
	function toggleArrow(elem,id,downImage,upImage){
		var arrow = document.getElementById(elem);
		
		switch(id){
			case 'a1':
				if(a1 == 0){
					arrow.src = downImage;
					a1 = 1;
				}else if(a1 == 1){
					arrow.src = upImage;
					a1 = 0;
				}
				break;
			case 'a2':
				if(a2 == 0){
					arrow.src = downImage;
					a2 = 1;
				}else if(a2 == 1){
					arrow.src = upImage;
					a2 = 0;
				}
				break;
			case 'a3':
				if(a3 == 0){
					arrow.src = downImage;
					a3 = 1;
				}else if(a3 == 1){
					arrow.src = upImage;
					a3 = 0;
				}
				break;
			case 'a4':
				if(a4 == 0){
					arrow.src = downImage;
					a4 = 1;
				}else if(a4 == 1){
					arrow.src = upImage;
					a4 = 0;
				}
				break;
			case 'a5':
				if(a5 == 0){
					arrow.src = downImage;
					a5 = 1;
				}else if(a5 == 1){
					arrow.src = upImage;
					a5 = 0;
				}
				break;
			default:
				break;
		}
	}	
	// Toggle Arrows in Collapsible Containers -- END
	
	
	// Display Login Overlay -- BEGIN 	
	function LoginOverlay(elem,login) {
		scroll(0,0);
		document.getElementById('Overlay').style.display = 'block';
		document.getElementById(elem).style.display = 'block';
		
		if(elem == 'LoggedIn'){
			 //setTimeout("window.location='home_page_logged_in.html'",7000);	
		}
		
		var selectBoxes = document.getElementsByTagName('select');
		
		for(i=0;i<selectBoxes.length;i++){
			selectBoxes[i].style.display = 'none';
		}
		
		if(login == true){
			document.getElementById('Register').style.display = 'none';
			document.getElementById('Premium').style.display = 'none';
		}
		
	}	
	// Display Login Overlay -- END 
	
	// Close Overlay -- BEGIN 	
	function CloseOverlay(id) {
		document.getElementById('Overlay').style.display = 'none';
		document.getElementById(id).style.display = 'none';
		
		
		var selectBoxes = document.getElementsByTagName('select');
		
		for(i=0;i<selectBoxes.length;i++){
			selectBoxes[i].style.display = '';
		}
	}
	// Close Overlay -- END
	
	// Logoff -- BEGIN 
	function LogOff() {
		window.location = 'home_page.html';	
	}
	// Logoff -- END
	
	
	// Login Form Submission on Enter KeyPress -- BEGIN
	
	function loginFormKeyPress(e,id) { // ID is matched with <form id>
		var keycode;
		if (window.event) {
		   keycode = window.event.keyCode
		} else if (e) {
		   keycode = e.which;
		}
		if (keycode == 13) {   // If Key Pressed is the Enter Key, then submit form
		   document.getElementById(id).click();
		}
	}

	// Login Form Submission on Enter KeyPress -- END
	
	// Activates L1 tab on Rollover (allows L1 nav to remain white until L2 nav is rolled off) -- BEGIN
	function ActiveTab(id){
		var mainNavTabs = document.getElementById('TopNav').getElementsByTagName('a');
		var skipItem = id.charAt(3);
		
		for(i=0;i<mainNavTabs.length;i++){
			
			if(i != skipItem){
				if(document.getElementById('Nav'+i).className == 'end active' || document.getElementById('Nav'+i).className == 'end'){
					document.getElementById('Nav'+i).className = 'end'
				}else if(document.getElementById('Nav'+i).className == 'start active' || document.getElementById('Nav'+i).className == 'start'){
					document.getElementById('Nav'+i).className = 'start';
				}else if(document.getElementById('Nav'+i).className == 'CurrentPage'){
					null;
				}else{
					document.getElementById('Nav'+i).className = '';
				}
				
			}
		}
		
		if(document.getElementById(id).className == 'end'){
			
			document.getElementById(id).className = 'end active';
		}else if(document.getElementById(id).className == 'start'){
			document.getElementById(id).className = 'start active';
		}else if(document.getElementById(id).className == 'end active' || document.getElementById(id).className == 'start active' || document.getElementById(id).className == 'active'){
			null
		}else{
			document.getElementById(id).className = 'active';
		}
	}
	// Activates L1 tab on Rollover (allows L1 nav to remain white until L2 nav is rolled off) -- END
	
	// Displays L2 nav on L1 nav rollover -- BEGIN 
	function showSubMenu(id){
		ActiveTab('TopNav');
		var bottomNav;
		var subMenus;
		bottomNav = document.getElementById('BottomNav')
		subMenus = bottomNav.getElementsByTagName('ul');
		
		for(i=0;i<subMenus.length;i++){
			subMenus[i].style.display = 'none';	
		}
		
		bottomNav.style.display = 'block';
		document.getElementById('SubMenu'+id).style.display = 'block';
	}
	// Displays L2 nav on L1 nav rollover -- END
	
	
	// Clears L2 Nav -- BEGIN 
	function clearSubMenu(){
		ActiveTab('TopNav');
		var bottomNav;
		var subMenus;
		bottomNav = document.getElementById('BottomNav')
		subMenus = bottomNav.getElementsByTagName('ul');
		
		for(i=0;i<subMenus.length;i++){
			subMenus[i].style.display = 'none';	
		}	
		
		bottomNav.style.display = 'none';
	}
	// Clears L2 Nav -- END
	
	
	// Activates and De-activates Tabs -- BEGIN
	function SwapTabs(id,elem,count) {
		var ElementPrefix = id.slice(0, -1);
		
		
		for(i=0;i<count;i++){
			if(document.getElementById('SelectedArrow'+i)){ // Arrow Tab Display for HomePage Media Box -- Currently Not being used -- Let's keep just in case
				document.getElementById('SelectedArrow'+i).style.display = 'none';
			}
			document.getElementById(ElementPrefix+i).className = '';
			document.getElementById(ElementPrefix+'Content'+i).style.display = 'none';
			
			
		}
		if(document.getElementById('SelectedArrow'+elem)){ // Arrow Tab Display for HomePage Media Box -- Currently Not being used -- Let's keep just in case
			document.getElementById('SelectedArrow'+elem).style.display = 'block';
		}
		document.getElementById(id).className = 'Active';
		document.getElementById(ElementPrefix+'Content'+elem).style.display = 'block';
		document.getElementById(ElementPrefix+'Content'+elem).style.visibility = 'visible';
		
		
	}
	// Activates and De-activates Tabs -- END
	
	
	// Alert confirmation when logging out -- BEGIN
	function LogoffAlert() {

		var msg= confirm("Are you sure you want to logoff?");
		if (msg== true){
			document.getElementById('logoffForm').submit();
		}else{
			null;
		}
	}
	// Alert confirmation when logging out -- END
	
	
	// Alert confirmation when navigating away from a registration page (alerts only if a form element was edited) -- BEGIN
	var formChanged = false;
	var browser=navigator.appName;
	
	function FormChanged(bool){
			formChanged = true;
		}
		
		function FormEdited() {
			  if (formChanged == true) {
				    var msg= confirm("You have entered information on this page, are you sure you wish to navigate away?");
				    if (msg== true) {
						 return true;
				    } else {
						 return false;
				    }
			  } else {
		
				    return true;
			  }
		}

 


	// Alert confirmation when navigating away from a registration page (alerts only if a form element was edited) -- END
	
	
	// Alert confirmation on terms and conditions (alerts only if the user declines) -- BEGIN
		var termsAccepted = null;
		
		function TermsAccepted(bool) {
			  termsAccepted = bool;
		}
		function AcceptDecline(cancelButton) {
			  if (termsAccepted == false) {
				 var msg = confirm("By declining the terms and conditions, you will not be able to continue the registration process.");
				    if (msg == true) {
						 cancelButton.click();
				    }
				    return false;        
			  } else {
				 // Note - return true even if termsAccepted is null, so Struts validation can
		
				 // display an error message that one of the radio buttons must be selected.
				    return true;
			  }             
		}


	// Alert confirmation on terms and conditions (alerts only if the user declines) -- END
	
	
	// Toggles between dropdown and open text field for dealer on registration page (broker/dealer only) -- BEGIN
	function DealerNameToggle() {
	    if (document.getElementById('DealerName') != null) {
		    var dealer = document.getElementById('DealerName').value;
		    if(dealer == 'Other') {
			
			    if(browser == 'Netscape') {
				    document.getElementById('ManualDealer').style.display = 'table-row';
			    } else {
				    document.getElementById('ManualDealer').style.display = 'block';
			    }
		    } else { 
			    document.getElementById('ManualDealer').style.display = 'none';
		    }
		}
	}
	// Toggles between dropdown and open text field for dealer on registration page -- END
	
	
	// Sets all Highlight Tabls -- BEGIN
		
	function setTableHighlight(val) {
		for(i=0;i<val;i++){
			initTableHighlight('TableHighlight_'+i);
		}
	}
	// Sets all Highlight Tabls -- END
	
	
	// Highlights Table Data (column and row) -- BEGIN
	function initTableHighlight(id) {
	    var table=document.getElementById(id);

    function highlight(row, col, state)	{
        for(var i=0; i<table.rows.length; i++){
            if(state=='off'){
                for(var j=0; j<table.rows[i].cells.length; j++){
					
                    
					 table.rows[i].cells[j].style.backgroundColor='#ffffff';
					
                }
            }

            if(state=='on'){
					
                	
					table.rows[i].cells[col].style.backgroundColor ='#d7d1b6';
			}
			
        }

        for(var i=0; i<table.rows[row].cells.length; i++){
            if(state=='on'){
               
                table.rows[row].cells[i].style.backgroundColor ='#d7d1b6';
				table.rows[row].cells[col].style.backgroundColor='#ffffff';
            }
        }
    }
    
    // Detects Cursor Position in Table
    for(var i=0; i<table.rows.length; i++){
        table.rows[i].row_index=i;
        for(var j=0; j<table.rows[i].cells.length; j++){
            table.rows[i].cells[j].column_index=j;
            table.rows[i].cells[j].onmouseover=function(){
                highlight(this.parentNode.row_index, this.column_index, 'on');
            }
            table.rows[i].cells[j].onmouseout=function(){
                highlight(this.parentNode.row_index, this.column_index, 'off');
            }
        }
    }
}
// Highlights Table Data (column and row) -- END


// Swap to Divs from display -- BEGIN

	function swapDivDisplay(id1,id2) {
		document.getElementById(id1).style.display = 'none';
		document.getElementById(id2).style.display = 'block';
	}

// Swap to Divs from display -- END


// HomePage Init. Detects whether the user will be logging in -- BEGIN

function loginDetect(){

	var login = GetArgsFromHref('login');
	
	if(login == 'regular'){
		LoginOverlay('Register',false);
	}else if(login == 'premium'){
		LoginOverlay('Premium',false);
	}else if(login == 'ai'){
		LoginOverlay('LoggedIn',false);
	}
}


// HomePage Init. Detects whether the user will be logging in -- END
	
// Strips Arguments From url -- BEGIN 

function GetArgsFromHref(sArgName){
	var url=document.location.href
	var args  = url.split("?");
	var retval = "";
	
	if(args[0] == url) {
		 return retval; 
	}  
	var str = args[1];
	args = str.split("&");
	for(var i = 0; i < args.length; i ++) {
		str = args[i];
		var arg = str.split("=");
		if(arg.length <= 1) continue;
		if(arg[0] == sArgName) retval = arg[1]; 
	}
	return retval;
}

// Strips Arguments From url -- END

// Adjusts HomePage login box on error message -- BEGIN
	function boxHeightAdjustment(id,val) {
		document.getElementById(id).style.height = val+'px';
	}
// Adjusts HomePage login box on error message -- END



// Checks to see if cookies are enabled -- BEGIN
var cookieEnabled = false;
if (typeof document.cookie == "string") {
   if (document.cookie.length == 0) {
     document.cookie = "test";
     cookieEnabled = (document.cookie == "test");
     document.cookie = "";
   }else{
     cookieEnabled = true;
   }
} 
// Checks to see if cookies are enabled -- END


// Alert cookie enabling -- BEGIN

function cookiesEnabled(){ // this is currently used in the Fund Watch page.  Let's keep it until everything is finished.  We will be using the function below from now on
	alert("Your system is not set up to accept cookies. The Fund Watch feature will not work without cookies. Please adjust your settings and try again.");
}

function cookiesEnabledMessaging(val){	
	alert(val);
}
// Alert cookie enabling -- END


// Alert confirmation on terms and conditions (alerts only if the user declines) -- BEGIN
	
	var fundSelection = false;
	
	function checkFundAction(name,val){
		
		fundSelection= false;
		
		var fundCheck = document.getElementsByName(name);
		
		for(i=0;i<fundCheck.length;i++){
			
			if(fundCheck[i].checked == true){
				fundSelection = true;
			}else{
				null;
			}
		}
		
		if(val == 'watch'){
		
			if(fundSelection == false){
				alert("Please select a fund or funds using the check boxes and then add to fund watch.");
			}else{
				watchFunds(val, fundCheck);
				//overlay('FundWatchThankYou');
			}
		}
		else if(val == 'delete'){
		
			if(fundSelection == false){
				alert("Please select a fund or funds using the check boxes and then delete from Fund Watch.");
			}else{
				watchFunds(val, fundCheck);
			}
		}
		
		
	}
	// Alert confirmation on terms and conditions (alerts only if the user declines) -- END
	
// Fund Watch Thank You Overlay -- BEGIN 

	function overlay(id) {
		scroll(0,0);
		document.getElementById('Overlay').style.display = 'block';
		document.getElementById(id).style.display = 'block';
		
		var selectBoxes = document.getElementsByTagName('select');
		
		for(i=0;i<selectBoxes.length;i++){
			selectBoxes[i].style.display = 'none';
		}
	}
// Fund Watch Thank You Overlay -- END


// Fund Watch Form Element Display -- BEGIN

	function displayFormElements(val) {
		if(val!= 0) {
			document.getElementById('ShareClassSelect').disabled = false;
			document.getElementById('AddFund').className = 'CustomButton';
			document.getElementById('AddFund').style.display = '';
		}else {
			document.getElementById('ShareClassSelect').disabled = true;
			document.getElementById('AddFund').className = 'CustomButton';
			document.getElementById('AddFund').style.display = 'none';
		}
	}

// Fund Watch Form Element Display -- END


// Get Elements By Class - BEGIN
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) 
			retnode.push(elem[i]);
		}
		return retnode;
	}; 
// Get Elements By Class - END


// Advances to tab on page load (mutual funds) -- BEGIN

	function mutualFundsInit() {
			if(GetArgsFromHref('tab') == 'documents'){
				SwapTabs('FundSummaryLayoutSect4Tab2',2,4); // advances to documents & literature tab	
			}
	}
// Advances to tab on page load (mutual funds) -- END


// Initialize String truncation -- BEGIN 

	function EllipsisInit() {
		$(document).ready(function() {
			$(".Teaser").autoEllipsis();
			
        	});
	}

// Initialize String truncation -- END


// Truncate long string.  Automatic Ellipsis -- BEGIN

jQuery.fn.autoEllipsis = function(options) {
    var get_AutoEllipsisScroller = function(id) {
        var aeScrollerId = "EllipsisString" + id
        if (!document.getElementById(aeScrollerId)) {
            var div = document.createElement("div");
            div.id = aeScrollerId + "_Container";
            div.innerHTML = "<span id=\"" + aeScrollerId + "\" style=\"overflow: visible; position: absolute; top: -2000px; left: -900px; color: orange\"></span>";
            document.body.appendChild(div);
        }
        return document.getElementById(aeScrollerId);
    };

    var StringEllipsesByMaxLetters = function(element, originalText, maxLettersAllowed) {
        
        var text = originalText;
	   
        if (text == null || text == "") text = element.innerHTML;
        var maxAllowedLatterIndex = text.length - maxLettersAllowed;
	   
	   
	   if (element.firstChild.nodeType == 3) {   // must be a text node
		   if (maxAllowedLatterIndex > 0) {
			 
			  if (originalText == null)
			  	
				 originalText = text;
			  element.innerHTML = text.substr(0, maxLettersAllowed - 2) + "&hellip;";
		   } else {
			  
			  element.innerHTML = text;
		   }
	   }
    };

    var _this = this;

    var settings = jQuery.extend({}, options);
    this.each(function(i) {
        var aeScroller = get_AutoEllipsisScroller(i);
        saeScroller = $(aeScroller);
        sthis = $(this);
        saeScroller.text(sthis.text());

        var origText = sthis.html();

        var element = this;
        var elementBounds = { width: element.offsetWidth, height: element.offsetHeight };

        var jAeScroller = $(aeScroller);
        var jElement = $(element);

        var props = ["font-size", "font-weight", "font-family", "font-style", "padding"];

        for (var i = 0; i < props.length; i++) {
            try {
                jAeScroller.css(props[i], jElement.css(props[i]));
            } catch (ex) { }
        }
        jElement.css("overflow", "visible");


        jAeScroller.width(jElement.width());

        var isIe = (document.all != undefined);
        var scrollerWidth = jAeScroller.width();
        var scrollerHeight = jAeScroller.height();
        var fitText = saeScroller.text();

        while (scrollerHeight > elementBounds.height && fitText != "") {
            fitText = fitText.substr(0, fitText.length - 2);
            var autoScrollerInnerHTML = fitText + "&hellip;";
            saeScroller.html(autoScrollerInnerHTML);
            scrollerHeight = jAeScroller.height();
        }
        if (fitText == "") {
            fitText = origText;
            saeScroller.html(fitText);
            jElement.css("whiteSpace", "nowrap");
            jAeScroller.width("");
            var scrollerWidth = jAeScroller.width();
        }

        while (scrollerWidth > elementBounds.width && fitText != "") {
            fitText = fitText.substr(0, fitText.length - 2);
            var autoScrollerInnerHTML = fitText + "&hellip;";
            saeScroller.html(autoScrollerInnerHTML);
            scrollerWidth = jAeScroller.width();
        }

		if(scrollerHeight < elementBounds.height && fitText != ""){
			element.style.height = scrollerHeight + 'px';
			
		}
        var scrollerHeight = aeScroller.offsetHeight;
        var r = (Math.ceil(elementBounds.height / scrollerHeight) - 1);
        r += (r == 0) ? 1 : 0;
        var maxLettersAllowed = fitText.length * r;

        StringEllipsesByMaxLetters(element, origText, maxLettersAllowed + (r + 1));
        
    });
    // Used for demo/prototype
    if(document.getElementById('MultiMediaTabContent1')){
	    document.getElementById('MultiMediaTabContent1').style.display = 'none';
	    document.getElementById('MultiMediaTabContent2').style.display = 'none';
	    document.getElementById('MultiMediaTabContent3').style.display = 'none';
	    document.getElementById('MultiMediaTabContent4').style.display = 'none';
    }
   /* if(document.getElementById('FundSummaryLayoutSect4TabContent1')){
		document.getElementById('FundSummaryLayoutSect4TabContent1').style.display = 'none';
		document.getElementById('FundSummaryLayoutSect4TabContent2').style.display = 'none';
		document.getElementById('FundSummaryLayoutSect4TabContent3').style.display = 'none';
	}*/
}

// Truncate long string.  Automatic Ellipsis -- END


// Hide Select Boxes for IE6 Layering Issue (Flyout Menu) -- BEGIN


function hideSelectBoxes() {
	
	if (document.all && !window.opera && !window.XMLHttpRequest) {
		var selectBoxes = document.getElementsByTagName('select');

		for(i=0;i<selectBoxes.length;i++){
			selectBoxes[i].style.visibility = 'hidden';
		}
	}
	}
function showSelectBoxes() {
	
	if (document.all && !window.opera && !window.XMLHttpRequest) {
		var selectBoxes = document.getElementsByTagName('select');

		for(i=0;i<selectBoxes.length;i++){
			selectBoxes[i].style.visibility = 'visible';
		}
	}
	}
	
		
// Hide Select Boxes for IE6 Layering Issue (Flyout Menu) -- END


// Expandable/Collapsible Menu Fix with Flyouts for IE 7 -- BEGIN

var currentHeight; // get's current height of div
var startInitialHeight=new Array(); // sets the initial stored heights of divs
var startingHeight=new Array(); // sets the starting height of div for the first action
var FlyOutValue;


function CollapsibleMenusInit(val,val2) {  // collects all heights of collapsible divs (B+number)
	FlyOutValue = val2;
	for(i=1;i<val;i++){
		if(document.getElementById('B'+i)){
     		startingHeight[i] = document.getElementById('B'+i).offsetHeight;
	 		startInitialHeight[i] = document.getElementById('B'+i).offsetHeight;
		}
	 }
 }
 
function ExpandCollapse(val) { // chooses whether the div will collapse or expand depending on the currentHeight
	
	currentHeight = val;
	if(startingHeight[val] > 0){
		expand = setInterval(Collapse, 1)
	}else if(startingHeight[val] <= 0){
		expand = setInterval(Expand, 1)
	}
}
 
function Collapse() { // Collapses div
	startingHeight[currentHeight] = startingHeight[currentHeight] - 10;		
	
	document.getElementById("B"+currentHeight).style.overflow = 'hidden';
	document.getElementById("B"+currentHeight).style.height = startingHeight[currentHeight]+'px';
	
	
	if(elementExists('FlyOutMenu3')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] < document.getElementById("FlyOutMenu3").offsetTop){				
				document.getElementById("FlyOutMenu3").style.visibility = 'hidden'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible
		}
	}
	
	if(elementExists('FlyOutMenu2')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] < document.getElementById("FlyOutMenu2").offsetTop){		
				document.getElementById("FlyOutMenu2").style.visibility = 'hidden'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible
		}
	}
	if(elementExists('FlyOutMenu1')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] < document.getElementById("FlyOutMenu1").offsetTop){			
			document.getElementById("FlyOutMenu1").style.visibility = 'hidden'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible
		}
	}
	
	if(startingHeight[currentHeight] <= 0){
		clearInterval(expand);
		
		startingHeight[currentHeight] = 0;
	}			
}

function Expand() { // expands div
	startingHeight[currentHeight] = startingHeight[currentHeight] + 10;		
	
	document.getElementById("B"+currentHeight).style.height = startingHeight[currentHeight]+'px';
	
	if(elementExists('FlyOutMenu1')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] > document.getElementById("FlyOutMenu1").offsetTop){	
				document.getElementById("FlyOutMenu1").style.visibility = 'visible'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible		
		}
	}
	
	if(elementExists('FlyOutMenu2')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] > document.getElementById("FlyOutMenu2").offsetTop){
			
			
				document.getElementById("FlyOutMenu2").style.visibility = 'visible'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible
		}
	}
	
	if(elementExists('FlyOutMenu3')){ // Fix for DEFECT 2163 -- check for existance of element and retrieve its position programatically
		if(currentHeight == FlyOutValue && startingHeight[currentHeight] > document.getElementById("FlyOutMenu3").offsetTop){				
					document.getElementById("FlyOutMenu3").style.visibility = 'visible'; // there is an instance where a flyout menu is used -- this is a fix for IE -- we must make the menu invisible
			}
	}
	
	
	
	if(startingHeight[currentHeight] >= startInitialHeight[currentHeight]){
		clearInterval(expand);
		startingHeight[currentHeight] = startInitialHeight[currentHeight];
		document.getElementById("B"+currentHeight).style.overflow = 'visible';  
	}
}

// Expandable/Collapsible Menu with Flyouts Fix for IE 7 -- END

function elementExists(id) {
	if(document.getElementById(id)){
		return true;					  
	}
}

// Swap Edit/View Literature Tab for Edit Profile -- BEGIN

	function editViewLiterature(viewTab,hideTab) {		
		document.getElementById(viewTab).style.display = 'block';	
		document.getElementById(hideTab).style.display = 'none';	
	}
	
	function insertData() {
		var form = document.forms['editLiterature'];
		
		for(i=0;i<form.elements.length;i++){
			alert(form[i].value);	
			
			if(i <= 12){
				document.getElementById('d'+i).innerHTML = form[i].value;
			}
			if(i >= 0 && i <= 3){
				if(form[i].checked == true){
					
					document.getElementById('d0').innerHTML = form[i].value;	
				}
			}
			
		}
	}
// Swap Edit/View Literature Tab for Edit Profile -- END


// SignUp / OptOut Content Confirmation/Swapping -- BEGIN
	
	function signUpOptOutConfirmation(val){	
		
		if(val == 'signup') {
			alert("Thank you for signing up.");
			editViewLiterature('OptOutContent','SignUpContent');
		}
		
		if(val == 'optout') {
			var msg= confirm("Are you sure you wish to be removed from our mailing list?");
			if (msg== true){
				editViewLiterature('SignUpContent','OptOutContent');
			}else{
				null;
			}	
		}
	}

// SignUp / OptOut Content Confirmation/Swapping -- END


// Toggling of the Plus and Minus Images used on Expandable Boxes in Forms and Applications -- BEGIN
// This can be used for toggling any two images as long as guidelines are followed
// Guidelines:
// The two images need to have the same Name prefix followed by a '0' and '1'. 
// The source directory may need to be adjusted depending on where your images are located.  Here I'm using a directory called 'images/'
/*
function toggleImage(elem){
	
	var ElementPrefix = elem.src;
	
	ElementPrefix = ElementPrefix.replace(/\\/g,"\\");
	ElementPrefix = ElementPrefix.replace(/\//g,"\\");
	
	var value = ElementPrefix.slice(ElementPrefix.length-5, ElementPrefix.length-4);
		
	begin = ElementPrefix.lastIndexOf(".");
	
	start = ElementPrefix.lastIndexOf("\\"); 
	end = ElementPrefix.lastIndexOf("."); 
	ElementPrefix = ElementPrefix.substring(start + 1, end-1);
	
	if(value == 0){
		elem.src = "images/" + ElementPrefix + "1.jpg";
	}else if (value == 1){
		elem.src = "images/" + ElementPrefix + "0.jpg";
	}
}
*/

// Rewrite of above to reflect image's original location- Kessel
function toggleImage(elem){
	var imgSrc = elem.src;
	
	if (imgSrc.search(/\_1\.jpg$/) > -1) {
		elem.src = imgSrc.replace(/\_1\.jpg$/, "_0.jpg");
	}
	else if (imgSrc.search(/\_0\.jpg$/) > -1) {
		elem.src = imgSrc.replace(/\_0\.jpg$/, "_1.jpg");
	}
}

// Toggling of the Plus and Minus Images used on Expandable Boxes in Forms and Applications -- END


// Visiblity Swap of two Elements -- BEGIN
function showHide(elem) { // Decided not to use this -- HOLD FOR NOW
	var elem = document.getElementById(elem);
	if(elem.style.display == 'block' || !elem.style.display){
		elem.style.display = 'none';	
	}else{
		elem.style.display = 'block'
	}
}
// Visiblity Swap of two Elements -- END



// Multimedia Component Tab Advance (slideshow) -- BEGIN */
var advanceMediaStartTab = 0;

function advanceMediaBoxInit() {
	
	advanceMedia = setInterval(advanceMultimediaBoxTabs, 8000);
	
	function advanceMultimediaBoxTabs() {
	
		
		SwapTabs('MultiMediaTab'+advanceMediaStartTab,advanceMediaStartTab,5);
		//document.getElementById('SelectedArrow'+advanceMediaStartTab).style.display = 'block';
		
		if(advanceMediaStartTab != 0){
		//	document.getElementById('SelectedArrow'+advanceMediaStartTab-1).style.display = 'none';
		}
		
		
		advanceMediaStartTab++;
		
		if(advanceMediaStartTab > 4){
			advanceMediaStartTab = 0;
		}
		
	}
}

function clearAdvanceMediaBox (id,val,val2) {
	clearInterval(advanceMedia);
	SwapTabs(id,val,val2);	
	advanceMediaStartTab = val;
	advanceMediaBoxInit();
}

function ImageBorderHighlight (elem,bool){  // Highlights Multimedia Box Image at the moment.  We can also sub out color to work with other Items in the future.
	if(bool == true){
		document.getElementById(elem).style.border = '1px solid #d45717';		
	}else if(bool == false){
		document.getElementById(elem).style.border = '1px solid #f3f3f3';
	}
}



// Multimedia Component Tab Advance (slideshow) -- END */

// Detect Browser for specific CSS (needed for MAC) -- BEGIN */

function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

// Detect Browser for specific CSS (needed for MAC) -- END */


