function Init(MyForm)
{
	// note that we need to look for document representing a specific 
	// layer as defined in the "standard" CDC header
        var doc = document;
        if (document.layers) {
		doc = document.layers['tbody'].document;
	}


        LevelsObject = doc[MyForm].which;
        LevelsObject.length = 1

	LevelsObject.options[0].value = 'above';
        LevelsObject.options[0].text = 'above';
   //  LevelsObject.options[1].value = 'below';
   //  LevelsObject.options[1].text = 'below';

}

function move_div(x,y){
	if (isNaN(x+y))return
	if(ns4){div1.moveTo(x,y)}else{div1.style.left=x+'px';div1.style.top=y+'px';}
}

function write_div(text){
	if(ns4){
		div1.document.open();
		div1.document.write(text);
		div1.document.close();
	}
	else {div1.innerHTML=text;}
}




function SetAboveBelow(MyForm) 
{
	// note that we need to look for document representing a specific 
	// layer as defined in the "standard" CDC header
        var doc = document;
        if (document.layers) {
		doc = document.layers['tbody'].document;
	}


        VarObject = doc[MyForm].threshold.value;


        if (VarObject.selectedIndex < 0) {
		VarObject.selectedIndex = 0;
	}

	// mm, changed to have only 1 option=  above

        LevelsObject = doc[MyForm].which;
	currentLevel = LevelsObject[LevelsObject.selectedIndex].text;
	LevelsObject.selectedIndex = 0;


        if (VarObject.length < 6){

                LevelsObject.length = 1

	        LevelsObject.options[0].value = 'above';
                LevelsObject.options[0].text = 'above';
   //          LevelsObject.options[1].value = 'below';
   //          LevelsObject.options[1].text = 'below';
        
        } else {
               LevelsObject.length = 1
               var temp = new Array();
               temp = VarObject.split('_');
               if (temp[0] == 'upper') {
                LevelsObject.options[0].value = 'above';
                LevelsObject.options[0].text = 'above';
               }
               if (temp[0] == 'lower') {
                LevelsObject.options[0].value = 'below';
                LevelsObject.options[0].text = 'below';
               }
        } 

}





document.onmousemove = dragIt
if(ns4)
{
document.captureEvents( Event.MOUSEMOVE )
}

function addZero(vNumber){ 
   return ((vNumber < 10) ? "0" : "") + vNumber 
  } 

function getToday(){

	todaysdate = new Date();
	date  = todaysdate.getDate();
	day  = todaysdate.getDay() + 1;
	month = todaysdate.getMonth() + 1;
	yy = todaysdate.getYear();
	year = (yy < 1000) ? yy + 1900 : yy;

        return year+addZero(month)+addZero(date);
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}


function Verify(MyForm)
{
        var doc = document;
        var minYear=2001;
        var daysInMonth = DaysArray(12);

       

        if (document.layers) {
		doc = document.layers['tbody'].document;
	}
        fcstdate = doc[MyForm].fcstdate.value;


	var strDay=fcstdate.substring(6,8) ; 
        var strMonth=  fcstdate.substring(4,6);  
        var strYear =  fcstdate.substring(0,4) ; 
		
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
        if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)

	vday=parseInt(strDay);
	vyear=parseInt(strYear);
        vmonth = parseInt(strMonth);

        if(fcstdate==''){ 	
               alert(" Forecast date can't be empty.");
	       return false;
	}

        if(fcstdate > getToday()){ 	
              alert("Invalid forecast date.");
           	return false;
	}

        if(fcstdate.substring(4,6)>'12' || fcstdate.substring(4,6)<'01'){
	       alert("Please enter a valid month");
	       return false;
        }

	if (strDay.length<1 || vday<1 || vday>31 || (vmonth==2 && vday>daysInFebruary(vyear)) || vday > daysInMonth[vmonth]){
		alert("Please enter a valid day");
		return false
	}


	if (strYear.length != 4 || vyear==0 || vyear<minYear){
		alert("Please enter a valid 4 digit year since "+minYear);
		return false;
	}
	else{
           	return true;
	}


}




