var deliciousLink = "http://del.icio.us/post?v=4;url=" + encodeURIComponent(location.href);
deliciousLink+=";title=";
deliciousLink+=encodeURIComponent(document.title);

var emailPageLink = "http://www.principal.com/allweb/docs/corporate/emailthispage.htm?"+location.href;

var surveyLink = "paga_homesurvey_pop.htm?"+location.href;

var fastFactsImageArray = new Array ("images/principal_img_42pct.jpg","images/principal_img_49pct.jpg");
//    "images/principal_img_41pct.jpg","images/principal_img_62pct.jpg","images/principal_img_73pct.jpg","images/principal_img_47pct.jpg","images/principal_img_58pct.jpg"
var fastFactsCopy = new Array("Share of women over 62 who rely on Social Security for 90% of their income.",
			"Share of workers who personally own a life insurance policy on themselves - paying 100% of the premium.");			
//    "41% of American adults who save a portion of tax refunds, gifts, bonuses, or other financial windfalls",
//    "62% of Americans who say they have a "savings plan with specific goals",
//    "73% of Americans who say they spend less than their income and save the difference.",
//    "47% - Share of U.S. workers who have tried to calculate how much money they need to save for a comfortable retirement.",
//    "58% - Share of U.S. workers who say they have an emergency fund that can be tapped immediately to help cover unanticipated expenses."

var pdfArray = new Array ("pdfs/under35.pdf", "pdfs/35to50.pdf", "pdfs/over50.pdf");

rotateFastFacts();

function printPage()
{
	simplePopUp(location.href+"?print", 3);
}

function rotateFastFacts()
{

	var element = document.getElementById("fastFacts");
	if(element!=null && element!='undefined')
	{		
		var len = fastFactsImageArray.length;
		var imageIndex = Math.floor(((len)*2)*Math.random())%len;
		element.src = fastFactsImageArray[imageIndex];
		element.alt = fastFactsCopy[imageIndex];		
	}
}

function initPDFDownload()
{
	var pdfDownloadChoice = getPDFDownloadCookie();	
	var element = document.getElementById('pdfDownloadLink');
	if(pdfDownloadChoice==null)
	{
		YAHOO.namespace('paga');

		YAHOO.paga.pdfDownload =  new YAHOO.widget.SimpleDialog('homepop0805',
						{ width : "500px",
						fixedcenter : true,
						visible : false,
						close: false,
						draggable: false,
						modal: true,							
						constraintoviewport : false});

		YAHOO.util.Dom.setStyle(['homepop0805'], "display", "block");
		YAHOO.paga.pdfDownload.render();
		element.onclick=function () { showPDFDownload(); };
	}
	else
	{		
		//element.href=pdfArray[pdfDownloadChoice];		
	}
}

function executePDFDownload(object)
{
	var pdfButtonArray = document.getElementsByName("pdfButton");
	var index = 0;
	for(var i=0;i<pdfButtonArray.length;i++)
	{		
		if(pdfButtonArray[i].checked==true)
		{		
			index = i;
			i=pdfButtonArray.length;
		}
	}
	//document.getElementById('pdfDownloadLink').href=pdfArray[index];
	object.href=pdfArray[index];
	hidePDFDownload();
	setPDFDownloadCookie(index);
	return false;
}

function showPDFDownload()
{
	YAHOO.paga.pdfDownload.show();
}

function hidePDFDownload()
{
	YAHOO.paga.pdfDownload.hide();
}

function setPDFDownloadCookie(value)
{
	//YAHOO.util.Cookie.set('pagaPDFDownload', value, { expires: new Date("January 1, 2025") });
}

function getPDFDownloadCookie()
{
	return null;
	//return YAHOO.util.Cookie.get('pagaPDFDownload');
}

function translateQueryString() {
	var sQS	= unescape(location.search).substr(1);
	var oQS	= {};
	if (sQS.length) {
		var aQS_items	= sQS.split('&'), nQS_items = aQS_items.length, nQS_itemsIdx, aQS_keyValue, nQS_keyValue, nQS_keyValueIdx;
		for (nQS_itemsIdx = 0; nQS_itemsIdx < nQS_items; nQS_itemsIdx++) {
			aQS_keyValue	= aQS_items[nQS_itemsIdx].split('='), nQS_keyValue = aQS_keyValue.length;
			for (nQS_keyValueIdx = 0; nQS_keyValueIdx < nQS_keyValue; nQS_keyValueIdx++) oQS[aQS_keyValue[0]] = aQS_keyValue[1];
		}
	}
	return oQS;
}
var QueryString	= translateQueryString();
