//Funzione descrizione sottostante
function openSottostante(idc){
 
  
 ff = window.open("sottostante_dettaglio.asp?ID=" + idc, "winnews", "height=400,width=500");
 ff.focus();
}

//Funzione descrizione sottostante
function openScheda(idc){

  
 ff = window.open("scheda_dettaglio.asp?ID=" + idc, "winnews", "scrollbars=yes,height=400,width=550");
 ff.focus();
}


//Funzione convalida sottostante
function convalida(idSelect){
  if (idSelect == 1){
    document.dati_cert.sottostante_azioni_estere.selectedIndex=0;
    document.dati_cert.sottostante_altro.selectedIndex=0;
    //alert("1");
    } 
    else{
      if (idSelect==2){
        document.dati_cert.sottostante_indici.selectedIndex=0;
        document.dati_cert.sottostante_altro.selectedIndex=0;
        //alert("2");
      }
      else{
        document.dati_cert.sottostante_azioni_estere.selectedIndex=0;
        document.dati_cert.sottostante_indici.selectedIndex=0;
        //alert("3");
      }
  }
}

//Funzione convalida sottostante investment
function ConvalidaInv(idSelect){
  if (idSelect == 1){
    document.dati_cert.sottostante_azioni_estere.selectedIndex=0;
    document.dati_cert.sottostante_altro.selectedIndex=0;
    document.dati_cert.sottostante_azioni_italiane.selectedIndex=0;
    //alert("1");
    } 
  if (idSelect==2){
    document.dati_cert.sottostante_indici.selectedIndex=0;
    document.dati_cert.sottostante_altro.selectedIndex=0;
    document.dati_cert.sottostante_azioni_italiane.selectedIndex=0;
    //alert("2");
    }
  if (idSelect==3){
    document.dati_cert.sottostante_azioni_estere.selectedIndex=0;
    document.dati_cert.sottostante_indici.selectedIndex=0;
    document.dati_cert.sottostante_azioni_italiane.selectedIndex=0;
    //alert("3");
    }
  if (idSelect==4){
    document.dati_cert.sottostante_altro.selectedIndex=0;
    document.dati_cert.sottostante_indici.selectedIndex=0;
    document.dati_cert.sottostante_azioni_estere.selectedIndex=0;
    //alert("4");
    }
}

function controlla_data(objform,ndate){
  //alert(ndate);
  if (checkdate(ndate)==false){
    alert('attenzione la data è errata');
    document.dati_cert.gg.selectedIndex=0;
    document.dati_cert.mm.selectedIndex=0;
    document.dati_cert.aa.selectedIndex=0;
  }else{
    objform.submit();
  }
}

function checkdate(Valuetext){

//	window.onerror=null // for all other strange errors
	var err=0

	//a=document.frm.dat.value
    
	a = Valuetext;

	if (a == '//') return true;
	
	if (a.length != 10) err=1

	b = a.substring(3, 5)// mese

	c = a.substring(2, 3)// '/'

	d = a.substring(0, 2)// giorno

	e = a.substring(5, 6)// '/'

	f = a.substring(9, 10)// anno

	//basic error checking
	if (b<1 || b>12) err = 1

	if (c != '/') err = 1

	if (d<1 || d>31) err = 1

	if (e != '/') err = 1

	if (f<0 || f>99) err = 1


	//advanced error checking

	// months with 30 days

	if (b==4 || b==6 || b==9 || b==11){
		if (d==31) err=1
	}



	// february, leap year
	if (b==2){

		// feb

		var g=parseInt(f/4)

		if (isNaN(g)) {

			err=1

		}



		if (d>29) err=1

		if (d==29 && ((f/4)!=parseInt(f/4))) err=1

	}

	if (err==1){
	   return false;
		//alert('Inserimento Errato');
	}
	else{
	   return true;
		//alert('OK!');
	}

}
