// updates the entire page
function updatePage(site) {
	site=encodeURL(site);
	if(site.substring(0,3)=="NEW"){
		site=site.substring(3,site.length);
		window.open(site,"popup","width=650,height=680,scrollbars=yes,resizable=yes,fullscreen=no");
	}
	else if (site != "") {
	top.location.href=site; 
	//alert ("going to site:"+site);
	return true;
	}	
	else
	return false;
}

symbol='djia';

// updates the current frame
function updateFrame(site) {
	if (site != "") {
	window.location.href=site;
	return true;
	}	
	else
	return false;
}

function Details(URL) {
	URL=encodeURL(URL);
	window.open(URL,"popup","width=425,height=436,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBig(URL) {    window.open(URL,"popup1","width=460,height=516,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBigMarketIndex() {
	URL = 'http://custom.marketwatch.com/custom/epoch-com/interactive-chart.asp?symb=' + symbol;
	window.open(URL,"popup1","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBigMarketIndex2() {
	URL = '../../popups/fp_flip_' + symbol + '.html';
	window.open(URL,"popup1","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBigMarketIndex3() {
	URL = '../popups/fp_flip_' + symbol + '.html';
	window.open(URL,"popup1","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBigCustom(URL) {    window.open(URL,"popup2","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function DetailsBigCustom2(URL) {    URL = '../../popups/fp_flip_' + symbol + '.html';
	window.open(URL,"popup2","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function Glossary(URL,windowName ) {
	URL=encodeURL(URL);
	windowName=window.open(URL,windowName,"width=475,height=392,scrollbars=no,resizable=no,fullscreen=no,location=0,menubar=0");
}

function GlossaryP(URL,windowName ) {
	URL=encodeURL(URL);
	windowName=window.open(URL,windowName,"width=475,height=392,scrollbars=no,resizable=no,fullscreen=no,location=0,menubar=0");
}

function switchImg(Sym,ThisChart,NewPath){
	symbol = Sym;
	window.document.images[ThisChart].src = NewPath;
}

function popupPe(ticker){
	var URL = "http://birdie.firstcall.com/webtemp/epoch/pe/" + ticker + "_pe.html";
	window.open(URL,"popup2","width=468,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function popupInst(ticker){
	var URL = "http://birdie.firstcall.com/webtemp/epoch/inst/" + ticker + "_inst.html";
	window.open(URL,"popup2","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function popupInst2(URL){
	window.open(URL,"popup2","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function popupRev(ticker){
	var URL = "http://birdie.firstcall.com/webtemp/epoch/rev/" + ticker + "_rev.html";
	window.open(URL,"popup2","width=460,height=520,scrollbars=no,resizable=no,fullscreen=no");
}

function popupEdgar(ticker){
	var URL = "http://www.edgar-online.com/brand/epoch/search/?sym=" + ticker;
	window.open(URL,"popup4","width=480,height=605,scrollbars=yes,resizable=no,fullscreen=no");
}

function loadFrame(nav,newBody){
	nav="../../../navigation/registered/" + nav + ".html";
	nav=encodeURL(nav);
	newBody=encodeURL(newBody);
	top.header.document.location.href=nav
	top.main.document.location.href=newBody
}

function encodeURL(url){
	var currentUrl=top.location.href;
	var searchString=";$sessionid$"; 
	var srchQuery="?";
	var returnUrl="";
	var queryString="";
	
	if (url.indexOf(srchQuery)!=-1){
		var startAt=url.indexOf(srchQuery);
		returnUrl=url.substring(0,startAt);
		queryString=url.substring(startAt);
		//alert ("main url ="+returnUrl+" and query="+queryString);
	}
	else {returnUrl=url;}
	
	if (currentUrl.indexOf(searchString)!= -1){
		var startpos=currentUrl.indexOf(searchString);
		var endpos=currentUrl.indexOf("?");
		if (endpos == -1){endpos=currentUrl.length;}
		var sesId=currentUrl.substring(startpos,endpos);
		returnUrl+=sesId;
	}
	returnUrl+=queryString;
	return returnUrl;
}

function Email() {
	var currentURL=top.location.href;
	var destURL=currentURL;
	//need to remove the ;$sessionid$ value if it exists
	var searchString=";$sessionid$";
	if (currentURL.indexOf(searchString)!= -1){
		//grab first part of url upto ;$sessionId$
		destURL=currentURL.substring(0,currentURL.indexOf(searchString));
		//add query parameters, if any
		if (currentURL.indexOf("?")!= -1){
			destURL+=top.location.search;
		}
	}
	var URL="/account/email_page.jhtml?destURL="+escape(destURL);
	URL=encodeURL(URL);
	window.open(URL,"Email_This_Page","width=425,height=500,scrollbars=no,resizable=no,fullscreen=no");
}

function flipImage(tagName,imgName){
	document[tagName].src = eval(imgName + ".src");
}

function quickPopup(URL){
	window.open(URL,"popup01","width=520,height=448,scrollbars=no,resizable=no,fullscreen=no");
}


