
var oELwin = null; // explainLink uses this.
var g_1stUnitType = '';
    
function explainLink(strType) {
	if (oELwin != null && !oELwin.closed) oELwin.close();
	oELwin = oELwin = window.open('explainLink.aspx?explain=' + strType, 'ExplainLink', 'width=425,height=220,resizable=1,scrollbars=0');
}

function setSelect(sbox, value) {
	for (i = 0 ; i < sbox.options.length; i++) {
		if (sbox.options[i].value == value) {
			sbox.selectedIndex = i;
			return;
		}
	}
}

  function setCriteria() {
    with (document.forms[0]) {
      setSelect(fobj, ""); 
      setSelect(freg, ""); 
      setSelect(fcurr, ""); 
    } 
  }

  var prev = "";
  var next = "";

  function drawPrevNext() {

    document.write("<table border=0 cellpadding=2 align=right><tr><td width=50 valign=center>&nbsp;")
    document.write(prev)
    document.write("</td><td width=50 valign=center>&nbsp;"+next+"</td></tr></table>") 
  }

  var g_1Astk = false;
  var g_2Astk = false;




function setCategories()
{
  var F = document.forms[0];

  setCategory(1,strHidcat1);
  setCategory(2, strHidcat2);
  setCategory(3,strHidcat3);
}

function setCategory(No,sel)
{
  var F = document.forms[0]; 

  var sCat1 = (F.selCat1.selectedIndex<1) ? '' : F.selCat1[F.selCat1.selectedIndex].value;
  var sCat2 = (F.selCat2.selectedIndex<1) ? '' : F.selCat2[F.selCat2.selectedIndex].value;
	
  if (No==1) FillSelectBox(F.selCat1,GetCategoryList('',''),sel);
  if (No==2 && sCat1 != '') FillSelectBox(F.selCat2,GetCategoryList(sCat1,''),sel);
  if( No==3 && sCat1 != '' && sCat2 != '') FillSelectBox(F.selCat3,GetCategoryList(sCat1,sCat2),sel);

	var cat2 = document.getElementById('divCat2');
	var cat3 = document.getElementById('divCat3');

  if(No==2 && F.selCat1.selectedIndex==0)
  {
    cat2.style.display="none";
    cat3.style.display="none";
    return;
  }

  if(No==3 && F.selCat2.selectedIndex==0)
  {
    document.getElementById('divCat3').style.display="none";
    return;
  }

  if (No == 2) {
    if (F.selCat2.options.length > 1) {
      document.getElementById('divCat2').style.display="block";
    } else {
      document.getElementById('divCat2').style.display="none";
    }
    document.getElementById('divCat3').style.display="none";
  }

  if (No == 3) {
		var vis;
    if (F.selCat3.options.length > 1) {
      vis = 'block';
    } else {
      vis = 'none';
    }
    document.getElementById('divCat3').style.display= vis;
  }
}

function FillSelectBox(objSel,sList,sel){

	aCat = sList.split(',')
	if(sel=='')
		var a = new Option('<--- Show all --->','',true,true)
	else
		var a = new Option('<--- Show all --->','',false,false)
	if (typeof objSel.options != 'undefined') 
	{
		objSel.options.length = 0
		objSel.options[0] = a
	}else{
		objSel.options = new Array(0)
		objSel.options[0] = a
	}

	if (sList=='') return

	for(var i =0;i<aCat.length;i++)
		if(sel==aCat[i])
			objSel.options[objSel.options.length] = new Option(aCat[i],aCat[i],true,true)
		else
			objSel.options[objSel.options.length] = new Option(aCat[i],aCat[i],false,false)
}

function GetCategoryList(Cat1,Cat2){
var Ret = ''
	for(var i=0;i<CategoryList.length;i+=3){
		if(Cat1!=''){
		   if (Cat1==CategoryList[i]){
			if(Cat2==''){
				if (Ret.indexOf(','+CategoryList[i+1])==-1)
					Ret = Ret + ',' + CategoryList[i+1]
			}
			else if(Cat2==CategoryList[i+1] && Ret.indexOf(','+CategoryList[i+2])==-1)
				Ret = Ret + ',' + CategoryList[i+2]
		   }	
		}
		else
			if(CategoryList[i]!=''&&Ret.indexOf(','+CategoryList[i])==-1)
				Ret = Ret + ',' + CategoryList[i]
	}
	return Ret.substr(1)
}

var c1=''
var c2=''
var c3=''
var recNumber = 0

function openPerfChart(typeCode) {
  var strLnk = 'PerformanceChart.aspx?typeCode=' + typeCode;
  
  var height = 485;
  
  if(!document.all)
  {
    height = 505;
  }
  
  var strPrm = "width=780,height="+height+",status=1,location=0,titlebar=0,toolbar=0,menubar=0,resizable=1,scrollbars=0";
  window.open(strLnk, "_blank", strPrm);
}


var selCat3 = '';

function getValue()	
{
	return GetSelectValue('selCat3');
}
		
		function GetSelectValue(id)
		{
			var sel = document.getElementById(id);
			return sel.options[sel.selectedIndex].value;
		}
		
		function go(type){
			var fname = document.getElementById('fname').value;
			if(type==''){
			    var selCat1 = GetSelectValue('selCat1');
			    var selCat2 = '', selCat3 = '';

			    if(selCat1 != ''){
				    selCat2 = GetSelectValue('selCat2');
				    if (selCat2 != '') {
					    selCat3 = GetSelectValue('selCat3');
				    }
			    }
    			
			    window.location="pricetable.aspx?fname="+ fname +"&strRec=0&selCat1="+ selCat1 +"&selCat2="+selCat2+"&selCat3="+selCat3; 
			}
			else{
			    window.location="pricetable.aspx?=Hargreaves&fname="+ fname +"&strRec=0"; 
			}
			
		}

		function openPDF(url) { //","status=1,toolbar=1"); 
		window.open(url,'FactSheet','width=800,height=600,menubar=no,maximise=yes,resizable=yes,scrollbars=yes,alt=FundInformation,status=1,location=0'); 
		}

	
	
function updateChart() {

  var frm = document.chartfm;
  var charturl = scharturl;

  with (document.chartfm) {
    itspan = parseInt(timespan[timespan.selectedIndex].value);
    charturl += "&span=" + itspan;
  }

  charturl+="&code="+codes;
  document.images.chartimg.src=charturl;
}


