// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MMCD_swapImgRestore() { //v3.0
  var i,x,a=document.MMCD_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//this mod adds the functionality to switch out the old button (used on Choosing TESI page)
function MMCD_swapImage() { //v3.0
  MMCD_swapImgRestore();
  var i,j=0,x,a=MMCD_swapImage.arguments; document.MMCD_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MMCD_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//this mod 
function MMXX_swapImage() { //v3.0
  		var i,j=0,x,a=MMXX_swapImage.arguments; document.MMXX_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MMXX_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MMXX_swapImgRestore() { //v3.0
  var i,x,a=document.MMXX_sr;
  //alert(current + " " + rolled);
  if (current != rolled){
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showtime(){
   var now = new Date()
   var hours = now.getHours()
   var minutes = now.getMinutes()
   //var seconds = now.getSeconds()
   var day = now.getDate()
   var year = now.getYear()
   var month = now.getMonth() + 1
   var timeValue = month + "-" + day + "-" + year
   timeValue += " " + ((hours > 12) ? hours - 12 : hours)
   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
   //timeValue += ((seconds < 10) ? ":0" : ":") + seconds
   timeValue += (hours >= 12) ? " PM" : " AM"
   document.write(timeValue)
   //document.clock.face.value = timeValue
   //timerID = setTimeout( "showtime()" ,2000)
   //timerRunning = true
}

// MARKET FUNDAMENTALS FUNCTIONS
function pop_history (market) {
	var history_win = window.open('/Marketfund/marketfund_hist_pop.aspx?market=' + market,'history_win','location=no,resizable=no,width=750,height=440');
	history_win.focus();
}


function setImageOn(id) {
	eval ("document." + id + ".src = " + id + "_on.src;");
}

function setImageOff(id) {
	eval ("document." + id + ".src = " + id + "_off.src;");
	
}

function restoreAll() {
	for(i = 0; i < arguments.length; i++) {
		setImageOff(arguments[i]);
	}
}

function preloadAll() {
	
	for(i = 0; i < arguments.length; i++) {
		eval(arguments[i] + "_on = new Image();");
		eval(arguments[i] + "_off = new Image();");
		eval(arguments[i] + "_on.src = '/images/" + arguments[i] + "_on.gif';");
		eval(arguments[i] + "_off.src = '/images/" + arguments[i] + "_off.gif';");
	}

}

function swapReportType (targetIframe) {
	//Determine timeinterval
	var timeInterval = document.histdataform.timeInterval.value;
	//Load data
	generateUrl(targetIframe, timeInterval);

}

function loadHistoryData(tabName, targetIframe, timeInterval) {
	//Reset all Tabs
	restoreAll('tab_hist_daily','tab_hist_weekly', 'tab_hist_monthly'); 
	//Set current Tab on
	setImageOn(tabName)
	//Generate URL
	generateUrl(targetIframe, timeInterval);
	
}

function generateUrl (targetIframe, timeInterval) {
	//Determine market
	var market = document.histdataform.market.value;
	var reportType = "RT";
	if (market != "ercot") {
		//Determine report type
		for(i = 0; i < document.histdataform.reportType.length; i++) {
			if ((document.histdataform.reportType[i].checked == "yes")||(document.histdataform.reportType[i].checked == true)) {
				reportType = document.histdataform.reportType[i].value;
			}
		}
	}
	//Set Time interval as hidden field
	document.histdataform.timeInterval.value = timeInterval;
	//Load proper page on historical data window
	var url = "/Marketfund/ifr_histdata.aspx?market=" + market + "&reportType=" + reportType + "&timeInterval=" + timeInterval;
	window.open(url, targetIframe);
	//Load proper download window
	var dlUrl = "/Marketfund/ifr_dl_" + market + "_" + timeInterval + "_" + reportType + ".htm";
	window.open(dlUrl, 'hist_download');
}

//********************************************
//PRODUCTS & SERVICES PAGES
//********************************************
var xx = null
var yy = null
var zz = null
var lll = null
var mmm = null
var nnn = null

function swap_text(x) {
  var targetElement;
  //alert("here");
  
  if (document.all && !(document.getElementById)) {
      targetElement = x.id
	  if (document.all[targetElement].style.display == "none"){
	  
	  }

 } else if (document.getElementById) {
     targetElement = eval("document.getElementById('" + x + "')");
	 //alert(targetElement.id);
	 if (targetElement.id == "risk_content_et") {
	    targetElement.style.display = "block";
		document.getElementById('risk_content_etplus').style.display = "none"
		document.getElementById('risk_content_pt').style.display = "none"
		document.getElementById('risk_content_mt').style.display = "none"
		document.getElementById('risk_content_dt').style.display = "none"
		MM_swapImage('button_et','','../images/risk_button_et_on.gif',1);
		MM_swapImage('button_etplus','','../images/risk_button_etplus.gif',1);
		MM_swapImage('button_pt','','../images/risk_button_pt.gif',1);
		MM_swapImage('button_dt','','../images/risk_button_dt.gif',1);
		MM_swapImage('button_mt','','../images/risk_button_mt.gif',1);
		
	 } else if (targetElement.id == "risk_content_etplus") {
	    targetElement.style.display = "block"
		document.getElementById('risk_content_et').style.display = "none"
		document.getElementById('risk_content_pt').style.display = "none"
		document.getElementById('risk_content_mt').style.display = "none"
		document.getElementById('risk_content_dt').style.display = "none"
		MM_swapImage('button_et','','../images/risk_button_et.gif',1);
		MM_swapImage('button_etplus','','../images/risk_button_etplus_on.gif',1);
		MM_swapImage('button_pt','','../images/risk_button_pt.gif',1);
		MM_swapImage('button_dt','','../images/risk_button_dt.gif',1);
		MM_swapImage('button_mt','','../images/risk_button_mt.gif',1);
	  } else if (targetElement.id == "risk_content_pt") {
	    targetElement.style.display = "block"
		document.getElementById('risk_content_et').style.display = "none"
		document.getElementById('risk_content_etplus').style.display = "none"
		document.getElementById('risk_content_mt').style.display = "none"
		document.getElementById('risk_content_dt').style.display = "none"
		MM_swapImage('button_et','','../images/risk_button_et.gif',1);
		MM_swapImage('button_etplus','','../images/risk_button_etplus.gif',1);
		MM_swapImage('button_pt','','../images/risk_button_pt_on.gif',1);
		MM_swapImage('button_dt','','../images/risk_button_dt.gif',1);
		MM_swapImage('button_mt','','../images/risk_button_mt.gif',1);
		} else if (targetElement.id == "risk_content_dt") {
	    targetElement.style.display = "block"
		document.getElementById('risk_content_et').style.display = "none"
		document.getElementById('risk_content_etplus').style.display = "none"
		document.getElementById('risk_content_pt').style.display = "none"
		document.getElementById('risk_content_mt').style.display = "none"
		MM_swapImage('button_et','','../images/risk_button_et.gif',1);
		MM_swapImage('button_etplus','','../images/risk_button_etplus.gif',1);
		MM_swapImage('button_pt','','../images/risk_button_pt.gif',1);
		MM_swapImage('button_dt','','../images/risk_button_dt_on.gif',1);
		MM_swapImage('button_mt','','../images/risk_button_mt.gif',1);
		} else if (targetElement.id == "risk_content_mt") {
	    targetElement.style.display = "block"
		document.getElementById('risk_content_et').style.display = "none"
		document.getElementById('risk_content_etplus').style.display = "none"
		document.getElementById('risk_content_pt').style.display = "none"
		document.getElementById('risk_content_dt').style.display = "none"
		MM_swapImage('button_et','','../images/risk_button_et.gif',1);
		MM_swapImage('button_etplus','','../images/risk_button_etplus.gif',1);
		MM_swapImage('button_pt','','../images/risk_button_pt.gif',1);
		MM_swapImage('button_dt','','../images/risk_button_dt.gif',1);
		MM_swapImage('button_mt','','../images/risk_button_mt_on.gif',1);
	  }
  }
}

function swap_timer() {
 
 xx = setTimeout("swap_text('risk_content_et')",2500)
 yy = setTimeout("swap_text('risk_content_etplus')",7500)
 zz = setTimeout("swap_text('risk_content_pt')",12500)
 lll = setTimeout("swap_text('risk_content_dt')",17500)
 mmm = setTimeout("swap_text('risk_content_mt')",22500)
 nnn = setTimeout("swap_timer()",25000)
 
}

function stop_timer() {
 window.clearTimeout(xx);
 window.clearTimeout(yy);
 window.clearTimeout(zz);
 window.clearTimeout(lll);
 window.clearTimeout(mmm);
 window.clearTimeout(nnn);
}


//
//-->
