function popUp(url) {
	sealWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";}

//Added for advisor and investor account pages
function imageMMOn(psImage) {
	if (document.images) {
		document.images['menudescription'].src = "Img/Menu/" + psImage + "On.gif";
	}

	return changeStatus(psImage);	
}

function imageMMOff() {
	if (document.images) {
		document.images['menudescription'].src = "Img/Spacer.gif";
	}

	return changeStatus('');	
}	

function chg_status(pTxt)
{
	return changeStatus(pTxt);
}

function imageSwap(psImageName, psImagePath) {
var loImage;

	if (document.images) {

		loImage = eval("document.images['" + psImageName + "']");
		loImage.src = psImagePath;
	}
	return changeStatus(psImageName);	
}

function toggleIntegrationsVis(psSectionName) {
var imgToggleSection;
var imgPlus = 'Img/ExpandSection.gif';
var imgMinus = 'Img/ContractSection.gif';
var frm = document.frmMG;
var bExplodeViewTopLevel;
var bExplodeViewLowerLevel;
var lsAllTags;
var laSectionName = new Array();

  laSectionName = psSectionName.split('~');

  for (var llSectionNumber = 0; llSectionNumber < laSectionName.length; llSectionNumber++) { 
		imgToggleSection = eval("document.images['imgToggle" + laSectionName[llSectionNumber] + "']");

		if (llSectionNumber <= 0) {
		  if (imgToggleSection) {
	      bExplodeViewTopLevel = imgToggleSection.src.indexOf(imgPlus) >= 0;
	      imgToggleSection.src = bExplodeViewTopLevel ? imgMinus : imgPlus;
		  }
		}	
		else {
		  if (imgToggleSection) {
	      bExplodeViewLowerLevel = imgToggleSection.src.indexOf(imgPlus) >= 0;
		  }
		  
		  lsAllTags = document.getElementsByName(laSectionName[llSectionNumber - 1]);
		  
		  if (lsAllTags.length > 0) {
		
			  for (i=0; i < lsAllTags.length; i++) {
			    if (bExplodeViewLowerLevel) {
			      if (laSectionName[llSectionNumber - 1].indexOf('HDR') >= 0) {
	            defaultVisGeneric(laSectionName[llSectionNumber - 1], true);   
			      }
			    }
		    } 
	    }
		}
	}
	if (!bExplodeViewTopLevel) {
      defaultVisGeneric(psSectionName, false);         
  }
}

function swapText(psSectionName) {
var llSectionNumber = stripNonDigits(psSectionName);
var lsSectionName = "mouseout" + llSectionNumber;
var lsHoverSectionName = "mouseover" + llSectionNumber;
 
   if (psSectionName.indexOf("mouseover") != -1) {  
    defaultVisGeneric(lsSectionName, false);
    defaultVisGeneric(lsHoverSectionName, true);
   }
   else {
    defaultVisGeneric(lsSectionName, true);
    defaultVisGeneric(lsHoverSectionName, false);
   }
}

/* Start Refer-A-Friend */
var mlLastInsertedName = 0;

function insertName() {
var frm = document.frmMG;
var lsTemplate = frm.txtTemplate.value;
var lsYourName = frm.txtYourName.value;
var llIndexNumber;
  
  llIndexNumber = parseInt(lsTemplate.length) - parseInt(mlLastInsertedName);
  lsTemplate = lsTemplate.substring(0, parseInt(llIndexNumber));
  
  if (mlLastInsertedName > 0)
    frm.txtTemplate.value = lsTemplate + lsYourName;  
  else
    frm.txtTemplate.value = lsTemplate + "\n" + lsYourName;
    
  mlLastInsertedName = lsYourName.length;
}

function valName(poControl) {
  poControl.value = stripInitialWhitespace(poControl.value);
	
  if (isEmpty(poControl.value)) {
	  alert ("Please enter your name.");
	  poControl.focus();
	  poControl.select();
	  return false;	
  }
  return true;
}

function valEmailTo(poControl) {
  var laEmail = new Array();
  var lsEmail = stripInitialWhitespace(poControl.value);
  var lsIndivEmailAddress;
  
  lsEmail = ((lsEmail.charAt(lsEmail.length - 1,1) == ";") ? lsEmail.substring(0,lsEmail.length - 1) : lsEmail);
  laEmail = lsEmail.split(';');

  for (var i=0; i < laEmail.length; i++) {
    lsIndivEmailAddress = stripInitialWhitespace(laEmail[i]);
    
    if (lsIndivEmailAddress.search(/^\w+((-\w+)|(\.\w+)|(\'\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
	    alert ('Please enter a valid email address "' + lsIndivEmailAddress + '" is not a valid email address.');
	    poControl.focus();
	    poControl.select();
	    return false;
    }
  }	 
  return true;
}

function valCreateEmail() {
var frm = document.frmMG;
var lbFieldOK;

  lbFieldOK = true;  
  lbFieldOK = valName(frm.txtYourName);
  lbFieldOK = lbFieldOK && valEmailTo(frm.txtEmailTo);
  
  if (lbFieldOK)   //'MoneyGuidePro Refer-A-Friend Program'
    sendEmail(frm.txtEmailTo.value, 'An Interesting Webinar', frm.txtTemplate.value);
}
/* End Refer-A-Friend */