
function openWindowTell(url) {
	popUpWin = window.open(url,'tell','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=410,height=500,screenX=110,screenY=10,left=110,top=10');
}

/* =============================================================
   Function     isDate(PFormat,PDate)
   Description  
   Parameter    
   		PFormat   :  Format Date
   		PDate     :  Date
   Return true if PDate is a valid date
   ============================================================= */
	function isDate(PFormat,PDate) {
          
		var year  =	0;
		var month =	0;
		var day   =	0;				

	    var W_YYYY = PFormat.indexOf("YYYY");
        var W_YY   = PFormat.indexOf("YY");
        var W_MM   = PFormat.indexOf("MM");
        var W_DD   = PFormat.indexOf("DD");         
		
        if (W_YYYY > 1 ) {
		   year  = PDate.substring(W_YYYY,W_YYYY+4);
		   month = PDate.substring(W_MM,W_MM+2);
		   day   = PDate.substring(W_DD,W_DD+2);
        }
        else
        { 
     	   if (PDate.substring(W_YY,W_YY+2)>80)
     	   {
    		   year  = "19"+PDate.substring(W_YYYY,W_YYYY+2);
	    	   month = PDate.substring(W_MM,W_MM+2);
		      day   = PDate.substring(W_DD,W_DD+2);
           }
           else 
     	  {
    		   year  = "20"+PDate.substring(W_YYYY,W_YYYY+2);
	    	   month = PDate.substring(W_MM,W_MM+2);
		       day   = PDate.substring(W_DD,W_DD+2);
     	  }	  
        }
		
	    if ( ! ( isYear(year) && isMonth(month) && isDay(day) ) ) return false;
	    var intYear = parseInt(year,10);
	    var intMonth = parseInt(month,10);
	    var intDay = parseInt(day,10);
	    if ( intDay > daysInMonth[intMonth] ) return false; 
	    if ( ( intMonth == 2 ) && ( intDay > daysInFebruary(intYear) ) ) return false;
	    return true;
	}

/* =============================================================
   Function     testDate(PFormat,Pdata1, Pdata2)
   Description  
   Parameter    
   		PFormat : 
   		PDate1  : 
   		PDate2  : 				
   Return 		
   ============================================================= */
function testDate(PFormat,P2, P3) {
	var WData1 = "";
	var WData2 = "";
	
  	var year  =	0;
	var month =	0;
	var day   =	0;				

    var W_YYYY = PFormat.indexOf("YYYY");
    var W_YY   = PFormat.indexOf("YY");
    var W_MM   = PFormat.indexOf("MM");
    var W_DD   = PFormat.indexOf("DD");         
	
    if (W_YYYY > 1 ) {
       WDate1 = P2.substring(W_YYYY,W_YYYY+4)+"-"+P2.substring(W_MM,W_MM+2)+"-"+P2.substring(W_DD,W_DD+2);
       WDate2 = P3.substring(W_YYYY,W_YYYY+4)+"-"+P3.substring(W_MM,W_MM+2)+"-"+P3.substring(W_DD,W_DD+2);	   
    }
    else
    { 
	  if (P2.substring(W_YY,W_YY+2)>80)	  {
 	      WDate1 = "19"+P2.substring(W_YY,W_YY+2)+"-"+P2.substring(W_MM,W_MM+2)+"-"+P2.substring(W_DD,W_DD+2); 
 	  } else {
 	      WDate1 = "20"+P2.substring(W_YY,W_YY+2)+"-"+P2.substring(W_MM,W_MM+2)+"-"+P2.substring(W_DD,W_DD+2);	  
 	  }
	  if (P3.substring(W_YY,W_YY+2)>80)	  {
 	      WDate2 = "19"+P3.substring(W_YY,W_YY+2)+"-"+P3.substring(W_MM,W_MM+2)+"-"+P3.substring(W_DD,W_DD+2); 
 	  } else {
 	      WDate2 = "20"+P3.substring(W_YY,W_YY+2)+"-"+P3.substring(W_MM,W_MM+2)+"-"+P3.substring(W_DD,W_DD+2);	  
 	  }
    }
		
	if(WDate1>WDate2)
	{ 
	   return false;
	}
	else
	{
	   return true;
	}
}

function SetListPeriodIntervallo(week, nomeform)
{
	var mySelectYear = nomeform.CmbAnno;
	var mySelectPeriod = nomeform.CmbPeriodo;
	var mySelectMonth = nomeform.CmbMese;
	var mySelectWeek = nomeform.CmbSettimana;
	var mySelectDay = nomeform.CmbGiorno;
    var mySelectYearTo = nomeform.CmbAnnoTo;
    var mySelectMonthTo = nomeform.CmbMeseTo;
    var mySelectDayTo = nomeform.CmbGiornoTo;
    var mySpanPeriodA = nomeform.divPeriodoA;
    
    //var xxmySpanPeriodA = document.all['divPeriodoA'];
    
    var xxmySpanPeriodA = document.getElementsByName("divPeriodoA");
	   
    //alert(nomeform.name);
    
    --nomeform.divPeriodoA;

	if (mySelectYear.value == 'All')
	{
		mySelectPeriod.selectedIndex = 'All';
		mySelectDay.selectedIndex = 'All';
		mySelectPeriod.disabled = true;
		mySelectMonth.disabled = true;
		mySelectDay.disabled = true;
		mySelectWeek.disabled = true;
		mySelectMonth.style.display = 'none';
		mySelectDay.style.display = 'none';
		mySelectWeek.style.display = 'none';
		//mySpanPeriodoA.style.display = 'none';
			if (nomeform.name != "myform2")
   			xxmySpanPeriodA[0].style.display = 'none';
   		else
   		   xxmySpanPeriodA[1].style.display = 'none';
		
	}
	else
	{
		mySelectPeriod.disabled = false;
		if (mySelectPeriod.value == 'Week')
		{		
			ListWeek2(mySelectYear.value, week, nomeform)
			mySelectMonth.disabled = true;
			mySelectDay.selectedIndex = 'All';
			mySelectDay.disabled = true;
			mySelectWeek.disabled = false;
			mySelectMonth.style.display = 'none';
			mySelectDay.style.display = 'none';
			mySelectWeek.style.display = '';
			//mySpanPeriodoA.style.display = 'none';
			//
			if (nomeform.name != "myform2")
   			xxmySpanPeriodA[0].style.display = 'none';
   		else
   		   xxmySpanPeriodA[1].style.display = 'none';
		}
		else if (mySelectPeriod.value == 'FROM')
		{
			mySelectMonth.disabled = false;
			mySelectDay.disabled = false;
			mySelectWeek.disabled = true;	
			mySelectMonth.style.display = '';
			mySelectDay.style.display = '';
			mySelectWeek.style.display = 'none';
            //Elimino la voce "tutto"
            mySelectDay.options[0] = null;
            mySelectDay[mySelectDay.selectedIndex].value = 1;
            //mySpanPeriodoA.style.display = '';
            //
            if (nomeform.name != "myform2")
   			   xxmySpanPeriodA[0].style.display = '';
   		   else
   		      xxmySpanPeriodA[1].style.display = '';
		}
		else
		{
			if (mySelectPeriod.value == 'Month')
			{
				mySelectMonth.disabled = false;
				mySelectDay.disabled = false;
				mySelectWeek.disabled = true;	
				mySelectMonth.style.display = '';
				mySelectDay.style.display = '';
				mySelectWeek.style.display = 'none';
                //Aggiungo la voce "tutto"
                if (mySelectDay.value > 0) {                
				    var oOption = document.createElement("OPTION");
				    oOption.text='Tutto';
				    oOption.value='0';
				    mySelectDay.options.add(oOption, 0);
				}				
				//mySpanPeriodoA.style.display = 'none';
				//
			if (nomeform.name != "myform2")
   			xxmySpanPeriodA[0].style.display = 'none';
   		else
   		   xxmySpanPeriodA[1].style.display = 'none';

				

			}
			else 
			{
				mySelectMonth.disabled = true;
				mySelectDay.selectedIndex = 'All';
				mySelectDay.disabled = true;
				mySelectWeek.disabled = true;
				mySelectMonth.style.display = 'none';
				mySelectDay.style.display = 'none';
				mySelectWeek.style.display = 'none';
				//mySpanPeriodoA.style.display = 'none';
         if (nomeform.name != "myform2")
   			xxmySpanPeriodA[0].style.display = 'none';
   		else
   		   xxmySpanPeriodA[1].style.display = 'none';
			}
		}
	}
}

function ListWeek2 (year, numeroWeek, nomeform)
{
	var mySelect = nomeform.CmbSettimana	
	for (i = mySelect.options.length - 1; i >= 0; i--)
	{
	    mySelect.options.remove(i);
	}
	var myDataPG = new Date(year, 0, 1);	//1° gennaio dell'anno
	var myDataUG = new Date(year, 0, 1);	//1° gennaio dell'anno
	myDataPG.setDate(myDataPG.getDate() - myDataPG.getDay() + 1);		// setta il primo giorno della settimana
	myDataUG.setDate(myDataUG.getDate() - myDataUG.getDay() + 1 + 6);	// setta l'ultimo giorno della settimana
	var k = 0
	while (myDataPG.getFullYear() <= year)
	{
		k++
		var oOption = document.createElement("OPTION");
		oOption.text = k.toString() + ' - Dal ' + myDataPG.getDate().toString() + '/' + (myDataPG.getMonth()+1).toString() + '/' + myDataPG.getYear().toString() + ' Al ' + myDataUG.getDate().toString() + '/' + (myDataUG.getMonth()+1).toString() + '/' + myDataUG.getYear().toString() ;
		oOption.value = myDataPG.getYear().toString() + '/' + (myDataPG.getMonth()+1).toString() + '/' + myDataPG.getDate().toString() + '|' + myDataUG.getYear().toString() + '/' + (myDataUG.getMonth()+1).toString() + '/' + myDataUG.getDate().toString();
		mySelect.options.add(oOption);
		myDataPG.setDate(myDataPG.getDate() + 7);
		myDataUG.setDate(myDataUG.getDate() + 7);
		if (numeroWeek == myDataPG.getYear().toString() + '/' + (myDataPG.getMonth()+1).toString() + '/' + myDataPG.getDate().toString() + '|' + myDataUG.getYear().toString() + '/' + (myDataUG.getMonth()+1).toString() + '/' + myDataUG.getDate().toString())
		{
			var BookmarkWeek = k.toString()
		}
	}	
	mySelect.selectedIndex = (BookmarkWeek);
}
function SetListDay2(nomeform, quale)
{

    if (quale == 'to') {
	    var numAnno = nomeform.CmbAnnoTo.value;
	    var numMese = nomeform.CmbMeseTo.value;
	    var mySelect = nomeform.CmbGiornoTo;
    }
    else {
	    var numAnno = nomeform.CmbAnno.value;
	    var numMese = nomeform.CmbMese.value;
	    var mySelect = nomeform.CmbGiorno;
    }
    
	if (numMese==12){numMese=0; numAnno++;}
	var myData = new Date(numAnno, numMese, 0);
	var myNumGG = myData.getDate();
	var myNumGGEle = mySelect.options.length - 1;	

    if (nomeform.CmbGiorno.options[0].value != '0') {
        //Manca la voce "Tutti"
        myNumGGEle = myNumGGEle + 1;
    }        	
	        	
	if (myNumGGEle > myNumGG) 
	{	
	    for (i = myNumGGEle; i > myNumGG; i--) {
	        if (nomeform.CmbGiorno.options[0].value != '0') {
	            //Manca la voce "Tutti"
	            indice = i - 1;
	            mySelect.options[indice] = null;
	        }
	        else {
	            mySelect.options[i] = null;
	        }
	    }
	} 
	else {
		if (myNumGGEle < myNumGG) 
		{	
		    for (i = myNumGGEle + 1; i <= myNumGG; i++)
			{
				var oOption = document.createElement("OPTION");
				oOption.text=i;
				oOption.value=i;
				mySelect.options.add(oOption);
			}
		}
	}
}

	function CambiaTab(tab)
	{	
		//stringa=	"tskm_corsi.asp?Sez="+tab+"&utente="+document.StatusOrder.utente.value+"&userid="+document.StatusOrder.userid.value+""			
		stringa=	"tskm_corsi.asp";
		document.location.href=stringa;
	}
	function invia()
	{
		document.StatusOrder.Sez.value= "<%=Sez%>";
		document.StatusOrder.Action.value= "cerca";
	}
