if (window.focus) { self.focus() }

if (typeof(document.images['butData'])=='undefined') {
	bHasData=false;
} else {
	bHasData=true;

}

function ChangeTimeframes(sChartName) {
	if (bYieldCurveIsSelected()) {
		//Yield Curve is active
		if (bHasData) {
			document.images['butData'].alt="Download Yield Curve data Series in Excel-compatible file (CSV)";
		}

		for (i=0; i < document.images.length; i++) {
			//remove Active chart marker
			if (document.images[i].src.toLowerCase()=="http://www.thefinancials.com/images/activechart.gif") {
				document.images[i].src = "http://www.theFinancials.com/images/blank.gif";
				break
			}
		}

		var sChartFileName=document.forms[document.forms.length-1].optTimeframe[nCheckedControlIDX].value.split(/-/);
		var sChartFileName=sChartFileName[0] + 'p.jpg'
		document.images[sChartName].src='http://www.theFinancials.com/Samples/' + sChartFileName
	} else {
		if (bHasData) {
			document.images['butData'].alt="Download 3-Year Data Series in Excel-compatible file (CSV)"
		}
		document.images[sChartName].src='http://www.theFinancials.com/Samples/' + asChart1Props[nTimeFrameIndex] + 'p.jpg'
		//if yield curve is available, add back Active chart marker
		if (typeof(sLastLocation)!='undefined') {
			movePageMarker(sLastLocation.split(/_/)[0],sLastLocation)
		}
	}
}

function LoadThumbnail(sChartName_w, sChartName_m, sChartName_y, sChartName_3y, sNewLocation) {
	for (i=0; i < document.forms[document.forms.length-1].optTimeframe.length; i++) {
		if (document.forms[document.forms.length-1].optTimeframe[i].checked) {
			var sTimeframe=document.forms[document.forms.length-1].optTimeframe[i].value.split(/-/);
			var sTimeframe=sTimeframe[0]
			break;
		}
	}
	switch (sTimeframe.toUpperCase()){
		case "W" : 
			sChartName=sChartName_w;
			break;		
		case "Y" : 
			sChartName=sChartName_y;
			break;		
		case "Y3" : 
			sChartName=sChartName_3y;
			break;		
		case "M" : 
			sChartName=sChartName_m;
			break;		
		default : 
			sChartName=sChartName_m;
			for (i=0; i < document.forms[document.forms.length-1].optTimeframe.length; i++) {
				nTimeFrameName=document.forms[document.forms.length-1].optTimeframe[i].value.split(/-/);
				nTimeFrameName=nTimeFrameName[0];
				if (nTimeFrameName=="M") {
					document.forms[document.forms.length-1].optTimeframe[i].checked=true
					break;
				}
			}
			break;		
	}

	sChart1Props=sChartName_w+"_"+sChartName_m+"_"+sChartName_y+"_"+sChartName_3y;
	sChartContainerName=sNewLocation.split(/_/);
	document.images[sChartContainerName[0]].src='http://www.theFinancials.com/Samples/' + sChartName + 'p.jpg'
	
	for (i=0; i < document.forms[document.forms.length-1].optTimeframe.length; i++) {
		if (document.forms[document.forms.length-1].optTimeframe[i].checked) {
			nTimeFrameIndex=document.forms[document.forms.length-1].optTimeframe[i].value.split(/-/);
			nTimeFrameIndex=nTimeFrameIndex[1];
			break;
		}
	}

	if (sNewLocation) {
		movePageMarker(sChartContainerName[0],sNewLocation) 
	}
}

function LoadThumbnail_Full(sChartName_w, sChartName_m, sChartName_y, sNewLocation) {
	for (i=0; i < document.forms['TFC_MFR_Form'].optTimeframe.length; i++) {
		if (document.forms['TFC_MFR_Form'].optTimeframe[i].checked) {
			var sTimeframe=document.forms['TFC_MFR_Form'].optTimeframe[i].value;
			break;
		}
	}
	switch (sTimeframe.toUpperCase()){
		case "W" : 
			sChartName=sChartName_w;
			break;		
		case "Y" : 
			sChartName=sChartName_y;
			break;		
		default : 
			sChartName=sChartName_m;
			break;		
	}
	sChart1Props=sChartName_w+"_"+sChartName_m+"_"+sChartName_y;
	sChartContainerName=sNewLocation.split(/_/);
	document.images[sChartContainerName[0]].src='http://www.theFinancials.com/Samples/' + sChartName + 'p.jpg'
	if (sNewLocation) {
		movePageMarker(sChartContainerName[0],sNewLocation) 
	}
}

function ZoomThumbnail(sDir, sThumbChartName, sTarget) {
	if (typeof(sTarget)=='undefined') {
		sTarget="_top";
	} else {
		if (!sTarget) {
			sTarget="_top";
		}
	}
	var nCurChartID=new String(document[sThumbChartName].src);
	var nCurChartIDList=nCurChartID.split('/');
	var nCurChartID=nCurChartIDList[nCurChartIDList.length-1];
	var nCurChartID=nCurChartID.substring(1,7) 
	window.open("http://www.theFinancials.com/Default.aspx?SubSectionID=homesumm&ChartID=" + nCurChartID);
}

function movePageMarker(sChartContainerName,sNewLocation) {
	sNameToMatch=String(sChartContainerName+"_ChartInd_");
	for (i=0; i < document.images.length; i++) {
		sImageName=String(document.images[i].name);
		if (sImageName.substr(0,sNameToMatch.length)==sNameToMatch) {
			if (sImageName == sNewLocation) {
				document.images[sNewLocation].src="http://www.theFinancials.com/images/ActiveChart.gif";			
			} else {
				document.images[i].src = "http://www.theFinancials.com/images/blank.gif";
			}
		}
	}
	return null;
}

function drpGoToPage(drpDown) {
	var sTarget=drpDown.options[drpDown.selectedIndex].value; 
	if (sTarget=='') {
		drpDown.selectedIndex=0;
	} else {
		document.location=sTarget;
 	} 
	return true;
} 


function bYieldCurveIsSelected() {
	for (i=0; i < document.forms[document.forms.length-1].optTimeframe.length; i++) {
		if (document.forms[document.forms.length-1].optTimeframe[i].checked) {
			nTimeFrameIndex=document.forms[document.forms.length-1].optTimeframe[i].value.split(/-/);
			nTimeFrameIndex=nTimeFrameIndex[1];
			nCheckedControlIDX=i;
			break;
		}
	}

	if (typeof(sChart1Props)=='undefined') {
		asChart1Props=initChart1Props.split(/_/);
	} else {
		asChart1Props=sChart1Props.split(/_/);
	}

	if (typeof(asChart1Props[nTimeFrameIndex])=='undefined') {
		return true;
	} else {
		return false;
	}

}
