
function DisableCateg(iSelect,otherSelect)
{
  var strKey  = eval("document.forms[0].elements['" + iSelect + "'].options[document.forms[0].elements['" + iSelect + "'].selectedIndex].value");

  if ((strKey.substr(0,1))!=="0")
  {
   eval("document.forms[0].elements['" + otherSelect + "'].disabled = true");
  }
  else
  {
   eval("document.forms[0].elements['" + iSelect + "'].disabled = false");
   eval("document.forms[0].elements['" + otherSelect + "'].disabled = false");
  }
}

function ChangeOptions(lstPrimary, lstSecondary, strArray) 
{
  var alen    = eval(strArray + ".length")
  var listLen = 1;

  var selArray = new Array();
  var selObj = document.getElementById(lstPrimary);
  var selObjSec = document.getElementById(lstSecondary);
  var i;
  var count = 0;
  selObjSec.options.length = 0;
  selObjSec.disabled = false;

  for (z=0; z<selObj.options.length; z++) {
    if (selObj.options[z].selected) {
      selArray[count] = selObj.options[z].value;
      count++;
    }
  }
  //se seleziono + cat, simulo il Tutte per popolare i subSelect 
  if (count>1) { selArray[0]=0; count=1 }

  for (x=0; x<count; x++) {
	strKey = selArray[x]
	posSel=0
	for (var i = 0; i < alen; i++) {
	  if (eval(strArray + "[i][0].toString() == '" + strKey + "'")) {
	    eval("document.forms[0]." + lstSecondary + ".options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1].toString())");
	    listLen = listLen + 1;
	  }
	}
  }
  if (listLen > 1) {
      selObjSec.options[0] = new Option('Tutti _________________________________________', '0');
      selObjSec.options[posSel].selected = true;
  }
  else {selObjSec.disabled = true } 
}

function ChangeOptions_OLD(lstPrimary, lstSecondary, strArray) 
{
  var alen    = eval(strArray + ".length")
  var listLen = 1;
  var strKey  = eval("document.forms[0]." + lstPrimary + ".options[document.forms[0]." + lstPrimary + ".selectedIndex].value")
  eval("document.forms[0]." + lstSecondary + ".options.length = 0");
  
  eval("document.forms[0]." + lstSecondary + ".disabled = false");

  posSel=0
  for (var i = 0; i < alen; i++) 
  {
   if (eval(strArray + "[i][0].toString() == '" + strKey + "'")) {
      eval("document.forms[0]." + lstSecondary + ".options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1].toString())");
      listLen = listLen + 1;
    }
  }
  if (listLen > 1) {
    eval("document.forms[0]." + lstSecondary + ".options[0] = new Option('Tutti _________________________________________', '0')");
    eval("document.forms[0]." + lstSecondary + ".options[" + posSel + "].selected = true");
  }
  else {eval("document.forms[0]." + lstSecondary + ".disabled = true"); } 
}

function SubmitReq(strAction)
{
   if (strAction != "")
   {
     document.forms[0].action = strAction;
     document.forms[0].submit();
   }
}

function trim(a){
	return a.replace(/^\s+/,'').replace(/\s+$/,'')
}	

function SbmReq(dove)
{
   if (dove=="2") {strAction="FSAdv.asp"} else {strAction="FSSelectStd.asp"} 
   tNome = trim(document.forms[0].tNome.value)
   tIsin = trim(document.forms[0].tIsin.value)
   
   if (tNome != "" && tNome.length<=3) 
     {alert('Il nome del fondo è troppo breve per effettuare una ricerca.')}
   else if (tIsin != "" && tIsin.length<12) 
     {alert('Il codice Isin è troppo breve per effettuare una ricerca.')}
   else {
		selSicav = document.forms[0].selSicav.selectedIndex
		selSocGest = document.forms[0].selSocGest.selectedIndex
		selRatingCFS = document.forms[0].selRatingCFS.selectedIndex
		selCategCFS = document.forms[0].selCategCFS.selectedIndex
		selPaese = document.forms[0].selPaese.selectedIndex
		selSubSett = document.forms[0].selSubSett.selectedIndex
		selStile = document.forms[0].selStile.selectedIndex
		selTipologia = document.forms[0].selTipologia.selectedIndex
		selCategAG = document.forms[0].selCategAG.selectedIndex

		if ( tNome!="" || tIsin!="" || selSicav>0 || selSocGest>0 || selRatingCFS>0 || selCategCFS>0 || selPaese>0 || selSubSett>0 || selStile>0 || selTipologia>0 || selCategAG>0 ) {
			document.forms[0].action = strAction;
			document.forms[0].submit();
		}
		else { alert('Impostare almeno un criterio di selezione!') }
	}
}

