var MORT_INCOME_FUND = "81"

function GoPDF (sPDF)
{
	popup('/Prospects/' + sPDF + '.pdf',600,500);
}

function GoS()
{
	var Custom, url;
	try {Custom = bCustom}
	catch(e){Custom = true;}

    url = 'SaverInterestRates.aspx?menutabtype=performance&back=' + escape(window.location.href);

	if (Custom)
		url += '&custom=1';
	if (bPublic)
		url += '&public=1';

	window.location.href = url;
}


function GoH (MainGroup, GroupID, ProductID)
{
	var Custom;
	try {Custom = bCustom}
	catch(e){Custom = true;}
	
	if (Custom)
	{
		if (bPublic)
			window.location.href = 'HistoricalUnitPrices.aspx?MainGroup=' + MainGroup + '&GroupID=' + GroupID + '&ProductID=' + ProductID + '&Public=1&FundTransfer=' + bFundTransfer + '&custom=1';
		else
			window.location.href = 'HistoricalUnitPrices.aspx?MainGroup=' + MainGroup + '&GroupID=' + GroupID + '&ProductID=' + ProductID + '&FundTransfer=' + bFundTransfer + '&custom=1';
	}
	else
	{
		if (bPublic)
			window.location.href = 'HistoricalUnitPrices.aspx?MainGroup=' + MainGroup + '&GroupID=' + GroupID + '&ProductID=' + ProductID + '&Public=1&FundTransfer=' + bFundTransfer;
		else
			window.location.href = 'HistoricalUnitPrices.aspx?MainGroup=' + MainGroup + '&GroupID=' + GroupID + '&ProductID=' + ProductID + '&FundTransfer=' + bFundTransfer;
	}
}

function GoDistribution()
{
	var Custom;
	try {Custom = bCustom}
	catch(e){Custom = false;}
	if (Custom)
	{
		if (bPublic) {
			window.location.href = 'distribution.aspx?menutabtype=performance&PaP=1&FundTransfer=' + bFundTransfer + '&Public=1&Custom=1';
		} else {
			if (SessionInfo_Get("userType") == "I")
				window.top.location.href = '/FirstNet/Investor.asp?MenuTabType=Performance&strPage=Distribution&PageType=aspx&PagePath=/price_performance/';
			else if (SessionInfo_Get("userType") == "A")
				window.top.location.href = '/FirstNet/adviser.asp?MenuTabType=Performance&strPage=Distribution&PageType=aspx&PagePath=/price_performance/';
			else
				window.location.href = 'distribution.aspx?menutabtype=performance&PaP=1&FundTransfer=' + bFundTransfer + '&Custom=1';
		}
	}
	else
	{
		if (bPublic) {
			window.location.href = 'distribution.aspx?menutabtype=performance&PaP=1&FundTransfer=' + bFundTransfer + '&Public=1';
		} else {
			if (SessionInfo_Get("userType") == "I")
				window.top.location.href = '/FirstNet/Investor.asp?MenuTabType=Performance&strPage=Distribution&PageType=aspx&PagePath=/price_performance/';
			else if (SessionInfo_Get("userType") == "A")
				window.top.location.href = '/FirstNet/adviser.asp?MenuTabType=Performance&strPage=Distribution&PageType=aspx&PagePath=/price_performance/';
			else
				window.location.href = 'distribution.aspx?menutabtype=performance&PaP=1&FundTransfer=' + bFundTransfer;
		}
	}
}


function GetFunds(productID, productName)
{
	document.getElementById(ctlID + "_hidFundProductID").value = productID;
	document.getElementById(ctlID + "_hidProductName").value = productName;
	document.getElementById("frmPage").submit();
}

function GetPerformance(productID, fundID, mainGroup, brandName, productName, fundName)
{
	//MIF excepption
	if (productID == MORT_INCOME_FUND)
		productName = "Managed Investment Funds";
	
	if (bPublic)
	{
		document.getElementById("hidFindFundProductID").value = productID;
		document.getElementById("hidFindFundID").value = fundID;
		document.getElementById("hidFindFundMainGroup").value = mainGroup;
		document.getElementById("hidFindFundBrandName").value = brandName;
	
		document.getElementById("hidFindFundName").value = fundName;
		document.getElementById("hidFindFundProductName").value = productName;
	
		document.getElementById("hidDefaultTab").value = "Performance";
	
		//document.getElementById("frmPage").action = "performanceNprice.aspx";
	
		document.getElementById("frmFund").submit();
	}
	else
	{
		
		var sQueryString = "?hidFindFundProductID=" + productID + "&hidFindFundID=" + fundID;
		sQueryString += "&hidFindFundMainGroup=" + mainGroup + "&hidFindFundBrandName=" + brandName;
		sQueryString += "&hidFindFundName=" + fundName + "&hidFindFundProductName=" + productName;
		sQueryString += "&hidDefaultTab=Performance";
		
		var sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=performanceNprice&PageType=aspx"
		sURL += escape(sQueryString) + "&PagePath=/Price_Performance/"
				
		window.top.location.href = sURL;
	}	
}

function GetUnitPrices(productID, fundID, mainGroup, brandName, productName, fundName)
{
	//MIF excepption
	if (productID == MORT_INCOME_FUND)
		productName = "Managed Investment Funds";
	
	if (bPublic)
	{
		document.getElementById("hidFindFundProductID").value = productID;
		document.getElementById("hidFindFundID").value = fundID;
		document.getElementById("hidFindFundMainGroup").value = mainGroup;
		document.getElementById("hidFindFundBrandName").value = brandName;
		
		document.getElementById("hidFindFundName").value = fundName;
		document.getElementById("hidFindFundProductName").value = productName;
		
		document.getElementById("hidDefaultTab").value = "UnitPrice";
		
		//document.getElementById("frmPage").action = "performanceNprice.aspx";
		
		document.getElementById("frmFund").submit();
	}
	else
	{
		var sQueryString = "?hidFindFundProductID=" + productID + "&hidFindFundID=" + fundID;
		sQueryString += "&hidFindFundMainGroup=" + mainGroup + "&hidFindFundBrandName=" + brandName;
		sQueryString += "&hidFindFundName=" + fundName + "&hidFindFundProductName=" + productName;
		sQueryString += "&hidDefaultTab=UnitPrice";
		
		var sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=performanceNprice&PageType=aspx"
		sURL += escape(sQueryString) + "&PagePath=/Price_Performance/"
				
		top.location.href = sURL;
	}
}

function Download()
{
	var sURL = "/Price_Performance/Download.aspx?"
	
	sURL += "hidDLProductIDs=" + document.getElementById("hidCritProductIDs").value + "&";
	sURL += "hidDLFundIDs=" + document.getElementById("hidCritFundIDs").value + "&";
	sURL += "hidDLFundName=" + document.getElementById("hidCritFundName").value + "&";
	sURL += "hidDLAPIRCode=" + document.getElementById("hidCritAPIRCode").value + "&";
	sURL += "hidDLAssetClasses=" + document.getElementById("hidCritAssetClasses").value + "&";
	sURL += "hidDLMainGroup=" + document.getElementById("hidCritMainGroup").value + "&";
	sURL += "hidDLBrandName=" + document.getElementById("hidCritBrandName").value + "&";
	
	if (document.getElementById("PerformanceImage").className == "performance-subTAB-blue")
		sURL += "hidDLTab=Performance";
	else
		sURL += "hidDLTab=UnitPrice";
		
	window.location.href = sURL;	
}

function DownloadCustom()
{
	var sURL = "/Price_Performance/Download.aspx?"
	
	if (document.getElementById("PerformanceImage").className == "performance-subTAB-blue")
		sURL += "hidDLTab=CustomPerformance";
	else
		sURL += "hidDLTab=CustomUnitPrice";
		
	window.location.href = sURL;	
}

function GoBack(refine)
{
	//debugger
	if (this.IsFindAFund)
	{
		if (bDirectAccess || bReferralPage)
		{
			window.history.go(-1);
			return;
		}	
		else
		{
			//hitting the refine search button
			if (refine)
				document.getElementById("hdRefne").value = "true";
		}
	}
	else 
	{
		try 
		{
			if (bFundTransfer) 
			{
				if (!bPublic)
				{
					var sQueryString = "?hdBck=true&hdBckPub=False";
					sQueryString += "&hdPaPBck=1&hdTrnFndPrdID=" + fundProdID;
					sQueryString += "&hdTrnFndPrdNm=" + fundProdName;
							
					var sURL = "/FirstNet/Investor.asp?MenuTabType=FindAFund&strPage=findFund&PageType=aspx"
					sURL += escape(sQueryString) + "&PagePath=/Price_Performance/"

				
				
					window.top.location.href = sURL;
					return;				
				}
				document.getElementById('frmBack').action = "findFund.aspx"	
			}
			else if (bCustom)
			{
				if (bPublic)
					window.location.href = "performanceNprice.aspx?menutabtype=performance&Public=1";
				else		
					window.location.href = "performanceNprice.aspx?menutabtype=performance";
				return;
			}
		}
		catch(e)
		{
		}		
	}
	
	if (window.location.href.indexOf("HistoricalUnitPrices") != -1) 
	{
		if ((bCustom)) 
		{
		    if (!bPublic) 
		        document.getElementById('frmBack').action = "performanceNPrice.aspx?menutabtype=performance";
		    else 
		    {
		        window.history.go(-1);
		        return;
		    }
		}
		if (fundTransfer) //move this here to get Find a Fund -> Performance -> History back buttons working in FNI only!!!
	    {
	        window.history.go(-1);
	        return;
	    }
	}
	
	document.getElementById('frmBack').submit();	
}

function GoCBack(isPublic)
{
	if (bFundTransfer)
	{
		if (!isPublic)
			window.location.href = "performanceNprice.aspx?" + sFindFundParam;
		else
			window.history.go(-1);
	}
	else
		window.location.href = "performanceNprice.aspx?hdHisBck=true&hdBckPub=" + isPublic;
}

function GoSaverInterestRates(tab)
{       
    var sURL;
	if (bPublic)
	{
	    sURL = "SaverInterestRates.aspx?MenuTabType=performance&Public=1";
		window.location.href = sURL;
	}
	else
	{
		sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=SaverInterestRates&PageType=aspx";
		sURL += "&PagePath=/Price_Performance/";
				
		window.top.location.href = sURL;
	}
}

function GoInvestInterestRates(tab) {
    var sURL;
    if (bPublic) {
        sURL = "IDInterestrates.aspx?MenuTabType=performance&Public=1";
        window.location.href = sURL;
    }
    else {
        sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=IDInterestrates&PageType=aspx";
        sURL += "&PagePath=/Price_Performance/";

        window.top.location.href = sURL;
    }
}

function GoSaverProductInfo(product)
{
    var url = '/prospects/FS';
    if (product == 91 || product == 51 || product == 11)
        url += '3705.pdf';
    else
        url += '3711.pdf';
	if (bPublic)
		window.location.href = url;
	else
		popup(url, 900, 500)

}
function GoInterestProductInfo(product) {
    var url = '/prospects/FS';
    if (product == 91 || product == 51 || product == 11)
        url += '4761.pdf';
    else
        url += '4733.pdf';
    if (bPublic)
        window.location.href = url;
    else
        popup(url, 900, 500)

}
function GoTDInterestRates()
{
    var sURL;
	if (bPublic)
	{
	    sURL = "TDInterestRates.aspx?MenuTabType=performance&Public=1";
		window.location.href = sURL;
	}
	else
	{
		sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=TDInterestRates&PageType=aspx";
		sURL += "&PagePath=/Price_Performance/";
				
		window.top.location.href = sURL;
	}
}

function GoTDProductInfo(product)
{
    var url = '/prospects/FS';
    if (product == 91 || product == 51 || product == 11)
        url += '4150.pdf';//Replace with Term Saver PDF for Wholesale
    else
        url += '4150.pdf';//Replace
	if (bPublic)
		window.location.href = url;
	else
		popup(url, 900, 500)

}

function GoMarginLendingRates()
{
	if (bPublic)
		window.location.href = "MarginLendingInterestRates.aspx?MenuTabType=performance&Public=1";
	else
	{
		var sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=MarginLendingInterestRates&PageType=aspx";
		sURL += "&PagePath=/Price_Performance/";
				
		window.top.location.href = sURL;
	}
}

function GoMarginLendingProductInfo()
{
	if (bPublic)
		window.location.href = "/producteducation/managedfunds/what_is_fc_margin_lending.aspx?menutabtype=pe";
	else
		popup('/producteducation/managedfunds/what_is_fc_margin_lending.aspx?menutabtype=pe', 900, 500)
}

function GoInterestRates()
{
	if (bPublic)
		window.location.href = "InterestRates.aspx?menutabtype=performance&public=1";
	else
	{
		var sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=InterestRates&PageType=aspx";
		sURL += "&PagePath=/Price_Performance/";
				
		window.top.location.href = sURL;
	}
}

function GoFirstRateInvestInterestRates() {
    if (bPublic)
        window.location.href = "HistoricalIDInterestRates.aspx?menutabtype=performance&public=1";
    else {
        var sURL = "/FirstNet/Investor.asp?MenuTabType=Performance&strPage=HistoricalIDInterestRates&PageType=aspx";
        sURL += "&PagePath=/Price_Performance/";

        window.top.location.href = sURL;
    }
}



function RenderBreadCrumb(parent,breadCrumbText) {

    
    if (parent != null && parent.window.displayBreadcrumb)
        parent.window.displayBreadcrumb(breadCrumbText);
    else if (parent != null)
        RenderBreadCrumb(parent.parent, breadCrumbText);
    
}
