
/* ---------------------------------------------------------
  /public/sandbox/js/sandbox.js  
--------------------------------------------------------- */


var imgLine = "";
var isCorp = false;
var isMyAcc = false;
var strHostName = document.location.hostname;

var getScrollingNews = false;
function getSandbox() {
	var i, sHtml = "", error = "";	
	
	
	if (fncGetSiteClass() == "corporate") isCorp = true;
	if (fncGetSiteClass() == "myaccount") isMyAcc = true;	
	
	if (LeftAryTitle != "promo") {	// flash promo does not require any javascript	
			
		if ((LeftAryTitle == "") || (MidLeftAryTitle == "") || (MidRightAryTitle == "") || (RightAryTitle == "")) {
			sHtml = ""; 			
		} else {
			var LeftResult = makeSandbox('Left', LeftAryTitle, LeftArySummary, LeftAryHref, LeftAryImg, LeftAryLink);

			/* ----- Trail Commissions Sandbox ---- removed per Robert on 1-31 ----			
			if (top.hasTrailComm) {
				MidLeftAryTitle = new Array("Trail Commissions");
				MidLeftArySummary = new Array("View your trails online. Click on the link under Premium Services!");
				MidLeftAryHref = new Array("javascript:top.hidden.getTrails();");
				MidLeftAryImg = new Array("/public/sandbox/images/sandbox_trails.jpg");				
				MidLeftAryLink = new Array("More"); 
			}
			*/			
			
			var MidLeftResult = makeSandbox('MidLeft', MidLeftAryTitle, MidLeftArySummary, MidLeftAryHref, MidLeftAryImg, MidLeftAryLink);			
			var MidRightResult = makeSandbox('MidRight', MidRightAryTitle, MidRightArySummary, MidRightAryHref, MidRightAryImg, MidRightAryLink);
			var RightResult = "";
			
			// If the scrolling news sandbox is to be used, the right sandbox will contain the title 'GETSCROLLINGNEWS'. 
			for (i=0; i<RightAryTitle.length; i++) {
				if (RightAryTitle[i].indexOf('GETSCROLLINGNEWS') != -1)
					getScrollingNews = true;			
			}
									
			if (getScrollingNews == true)
				RightResult = "";				
			else 
				RightResult = makeSandbox('Right', RightAryTitle, RightArySummary, RightAryHref, RightAryImg, RightAryLink);			

			
			// corporate full width sandboxes						
			sHtml = "<table cellpadding=0 cellspacing=0 border=0 bgcolor='E3F5FF'>" +
					"<tr>" + 
					"<td valign='top'>" + LeftResult + "</td>" +					
					"<td valign='top'>" + MidLeftResult + "</td>" +
					"<td valign='top'>" + MidRightResult + "</td>" +  
					"<td valign='top' id='idSandboxRight'>" + RightResult + "</td>" +
					"</tr>" + 					
					"</table>"									
					 

			// SAVE broker only news sandbox		
			//if (RightResult != "") sHtml += RightResult;
			
			document.write(sHtml);											
		}	
	}	
}


function makeSandbox(position, Title, Summary, Href, Img, Link) {			
	 
	var resultHTML = "", strTitle, strSummary, strHref, strPlacement, strImg, strLink, rNum;;
	rNum = Math.floor(Math.random() * Title.length);	
	
	resultHTML = "<table cellpadding=0 cellspacing=0 border=0 height=220>" +
				  "<tr>" +
				  "<td background='/images/homepage/blue_table_bg.gif' width=";

	if (isCorp) resultHTML += "182"; 				  
	else if(isMyAcc) resultHTML += "145"; 
	else if(position == 'Right') resultHTML += "148";	// first position on broker is 1px smaller
	else resultHTML += "149";	  	
				  
	resultHTML += " height="; 
	
	if (ie) resultHTML += "46"; // adjust height of title bar
	else resultHTML += "45";	 			  				  				  
				  
	resultHTML += " align=center>" +
		  		  "		<table border=0 cellspacing=0 cellpadding=0>" +
				  "  	<tr>" +
				  "		<td width=";
				  
	if (isCorp) resultHTML += "127"; 				  
	//else if(isMyAcc) resultHTML += "115";
	else resultHTML += "115"; 				  				  	
				  
	resultHTML += " class='LifeSubHeaders'>" + Title[rNum] + "</td>" +
				  "		<td width=1><img src='/images/templates/spacer.gif' width=1 height=1></td>" +				  
				  "	 	<td valign=middle><a href=\"" + Href[rNum] + "\"><img src='/images/homepage/go_blue.gif' width=27 height=22 border=0 hspace=4></a></td>" +
				  " 	</tr>" +
				  "		</table>" +
		  		  "</td>" +
				  "<td width=1><img src='/images/templates/spacer.gif' width=1 height=1></td>" +
				  "</tr>" +
				  "<tr>" +
				  "<td bgcolor='E3F5FF' align=center valign=top height=173><br>" +
				  "		<table width=";

	if (isCorp) resultHTML += "146>"; 				  
	//else if(isMyAcc) resultHTML += "140>";				  				  				  			  
	else resultHTML += "140>"; 	

	resultHTML += "		<tr>" +
				  "		<td align=center>";

	// check to see if we have flash - not valid on corporate sites
	// new look currently only allows the image to be replaced with flash, the button is not included
	if (Img[rNum].toLowerCase().indexOf(".swf") != -1 && !isCorp) {
		resultHTML += "<OBJECT WIDTH=\"124\" HEIGHT=\"87\" CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" CODEBASE=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\">" + 
					  "<PARAM NAME=\"movie\" VALUE=\"" + Img[rNum] + "\">" + 
					  "<PARAM NAME=\"quality\" VALUE=\"high\">" + 
					  "<PARAM NAME=\"LOOP\" VALUE=\"true\">" + 
					  "<EMBED TYPE=\"application/x-shockwave-flash\" WIDTH=\"124\" HEIGHT=\"87\" SRC=\"" + Img[rNum] + "\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" LOOP=\"false\">" + 
					  "</OBJECT>";
					  
	// check to see if we have the count down sandbox
	// "<IMAGE url=countdown>" will be placed in the xml file and a 
	// <COUNTDOWN enddate=[]> tag will be added to the frameset html. 					  
	} else if (Img[rNum].toLowerCase().indexOf("countdown") != -1) {	

		// day 0 or less we will create a static portfolio manager sandbox instead				
		if (top.sweepDays < 1) { 
			var tempTitle = new Array("Portfolio Managers");
			var tempSumm = new Array("Find out about the money managers.");
			var tempHref = new Array("/public/portfolios_and_managers/pmgr_index.html");			
			var tempImg = new Array("/public/sandbox/images/img_portfolio_mgrs.jpg");			
			var tempLink = new Array("More");
			return makeSandbox(position, tempTitle, tempSumm, tempHref, tempImg, tempLink);				
		
		// last day replace number with message			
		} else if (top.sweepDays == 1) { 
		 	resultHTML += "<div class=countLastDay>" +					  		
						  "Last Day!<br><span class=countLastDayNum>1</span>" + 
						  "</div>";			
		
		// write out number of day left						  
		} else { 
		 	resultHTML += "<div class=countdown>" +					  		
						  top.sweepDays + 
						  "</div>";		
		}
		
	} else {
		resultHTML += "<a href=\"" + Href[rNum] + "\"><img src=\"" + Img[rNum] + "\" border=\"0\" width=\"124\" height=\"87\"></a>";	//added to make the image linkable	
	}	
		
	resultHTML += "		</td>" +
			 	  "		</tr>" +
				  "		<tr>" +
				  "		<td class=\"lifeSecondaryText\">" + Summary[rNum] + " <span class=\"sideLink\"><a class=\"sideLink\" href=\"" + Href[rNum] + "\">"+ Link[rNum] +"</A></span></td>" +
				  "		</tr>" +
				  "		</table>" +					  
				  "</td>";
				  
	
	if (position == "Right") // no border needed to right on last sandbox 				  
		resultHTML += "<td width=1>";
	else	
		resultHTML += "<td width=1 bgcolor='#3399CC'>";				  
				  

	resultHTML += "<img src='/images/templates/spacer.gif' width=1 height=1></td>" +
				  "</tr>" +
				  "</table>";		
	
	if (resultHTML != "") {
		return resultHTML;				
	}					
}



/* -----------------------------------------
	News Sandbox (Broker)
	Right position for Annuities broker site
----------------------------------------- */

function getNewsSandBox() { // called from homepage div id IDNEWSCONTAINER

	if (getScrollingNews == true) {
		var retval = "";
		var strNews = document.getElementById('IDNEWSCONTAINER').innerHTML;		 	
				 
		retval = "<table cellpadding=0 cellspacing=0 border=0 height=220>" +
				  "<tr>" +
				  "<td background='/images/homepage/blue_table_bg.gif' width='148' height=";	
	
		if (ie) retval += "46"; 
		else retval += "45";	 			  				  				  
				  
		retval += " align=center>" +
		  		  "		<table border=0 cellspacing=0 cellpadding=0>" +
				  "  	<tr>" +
				  "		<td width='115' class='LifeSubHeaders'>News Center</td>" +
				  "	 	<td valign=middle><a href='javascript:toggleList();'><img src='/images/homepage/go_blue.gif' width=27 height=22 border=0 hspace=4></a></td>" +
				  " 	</tr>" +
				  "		</table>" +
		  		  "</td>" +
				  "<td width=1><img src='/images/templates/spacer.gif' width=1 height=1></td>" +
				  "</tr>" +
				  "<tr>" +
				  "<td bgcolor='E3F5FF' align=center valign=top height=173><br>" +
				  "		<table width='140'>" +
				  "		<tr><td align=center>" + strNews +"</td></tr>" +
				  "		</table>" +					  
				  "</td><td width=1>";	  
 				  "<img src='/images/templates/spacer.gif' width=1 height=1></td>" +
				  "</tr>" +
				  "</table>";	

		document.getElementById('idSandboxRight').innerHTML = retval;
	}
}

function toggleList() {
	var objFeatures = document.getElementById('idFeatures');
	var objMoreInfo = document.getElementById('IDMOREINFO');
	var objDivScroll = document.getElementById('IDDIVSCROLL');
	
	if (objFeatures.style.display == "block") {
		objFeatures.style.display = 'none';
		objMoreInfo.style.display = 'block';
		objDivScroll.style.backgroundImage = 'url(/public/sandbox/images/news/scroll_back2.gif)';		
	} else {
		objFeatures.style.display = 'block';
		objMoreInfo.style.display = 'none';	
		objDivScroll.style.backgroundImage = 'url(/public/sandbox/images/news/scroll_back.gif)';		
	}		
}

