

function updateDays(year,month,date_list) {
    selected = date_list.selectedIndex;

	// months are off by one.
    if (month==0 || month==2 || month==4 || month==6 || month==7 || month==9 || month==11) {
        days = 31;
    } else if (month==1) {
        if (isLeapYear(year))
            days = 29;
        else
            days = 28;
    } else {
        days = 30;
    }

    /* no mistake - mozilla and IExplorer requires double delete of selection list? (According to perbo) */
    for (i=0;i<date_list.length;i++)
        date_list.options[i] = null;
    for (i=0;i<date_list.length;i++)
        date_list.options[i] = null;


    // Add
    for (i=0;i<days;i++) {
        if (i<9)
            text="0" + (i+1);
        else
            text = "" + (i+1);

       date_list.options[i] = new Option(text,i+1);
    }

    date_list.selectedIndex = selected;
}

function isLeapYear(year) {
    if(((year % 4)==0) && ((year % 100)!=0) || ((year % 400) == 0))
        return true;
    else
        return false;
}


function addBookmark(url, description) {
    var agt = navigator.userAgent.toLowerCase();

    //alert(agt);
 
    if (agt.indexOf("aol")!=-1) {
      alert("AOL Users hit CTRL++ to add a bookmark to this site.");
    } else if( window.external && navigator.platform == 'Win32' ) {
      //IE Win32 - checking for AddFavorite produces errors for no good reason,
      //so use a platform detect.
      window.external.AddFavorite( url, description );
    } else if( window.opera && window.print ) {
      //Opera 6+ - add as sidebar panel to Hotlist
    } else if( document.layers || agt.indexOf("mozilla")!=-1) {
      window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
    } else {
      //other browsers - tell them to add a bookmark (adds current page, not target page)
      window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
    }
}

function doConfirm(text) {
	if (confirm(text)) { 
		return true;
	}
	return false;
}

function delayedRefresh(seconds) {
	setTimeout("refresh()", seconds * 1000);
}
	
function refresh() {
	window.location.reload(true);
}

function delayedGoto(seconds, url) {
	setTimeout("goto_url('" + url + "')", seconds * 1000);
}
	
function goto_url(url) {
	window.location.replace(url);
}

function popUp(contextPath, help_id) 
{
	  var generator = window.open(contextPath+'/Help/HelpInfo.do?help_id=' + help_id,'', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=300,left =400,top = 250');
	  return false;
}
		
function changeDt(month, day, year)
{
	
	switch(parseInt(month.value))
	{
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
				day.options[28] = new Option('29', '29');
				day.options[29] = new Option('30', '30');
    			day.options[30] = new Option('31', '31');
				break;
				
		case 2:
				if(parseInt(year.value) % 4 == 0)
				{
					day.options[28] = new Option('29', '29');
					day.options[30] = null;
					day.options[29] = null;
				}
	    		else
	    		{
					day.options[30] = null;
					day.options[29] = null;
					day.options[28] = null;
	    		}
	    		break;
	    		
	    case 4:
	    case 6:
	    case 9:
	    case 11:
	    		day.options[28] = new Option('29', '29');
    			day.options[29] = new Option('30', '30');
				day.options[30] = null;
				break;
	}
}
