function doSpell(frm,fld) {
    //window.open("spellchecker/window.asp?jsvar=document."+frm+"."+fld+".value", null, "height=230,width=450,status=no,toolbar=no,menubar=no,location=no"); 
    window.open("spellchecker/default.asp?jsvar=document."+frm+"."+fld+".value", null, "height=230,width=450,status=no,toolbar=no,menubar=no,location=no"); 
	}


function OpenNewWindow(url, name, options) {
	var temp = window.open(url, name, options);
	if (temp)	{
    		temp.focus();
	} else {
		alert('Please Enable popups for this site to continue');return false;
	}
	return temp;
	}
function OpenModule(WName, PageName, Width, Height, Parameters) {
	var temp = OpenModule2(WName,PageName,Width,Height,Parameters,0,0,0,1,0,1);
	}
function OpenModule2(WName, PageName, Width, Height, Parameters, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize) {
	// The URL for the facility detail
	var url = 'default.aspx?p=' + PageName + '&NoModResize=1&NoNav=1&ShowFooter=False&' + Parameters;

	// Open the window
	var temp = OpenURL(url, WName, Width, Height, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize);
	}

function OpenURL(url, WName, Width, Height, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize) {

	// Get the window settings, set defaults if no settings are provided
	if(ToolBar == 1) {showToolBar = 'toolbar=yes';} else {showToolBar = 'toolbar=no';}
	if(Menubar == 1) {showMenuBar = 'menubar=yes';} else {showMenuBar = 'menubar=no';}
	if(Location == 1) {showLocation = 'location=yes';} else {showLocation = 'location=no';}
	if(ScrollBar == 1) {showScrollBar = 'scrollbars=yes';} else {showScrollBar = 'scrollbars=no';}
	if(StatusBar == 1) {showStatusBar = 'status=yes';} else {showStatusBar = 'status=no';}
	if(Resize == 1) {showResize = 'resizable=yes';} else {showResize = 'resizable=no';}

	// Get this window's position
	var x = 0;
	var y = 0;
	var w = 0;
	var h = 0;
	w = screen.AvailWidth;
	h = screen.AvailHeight;

	// Modify the position - CENTER THE NEW WINDOW
	x = (w-Width)/2;
	y = (h-Height)/2;

	// Open the window
	var temp = OpenNewWindow(url, WName, 'width=' + Width + ',height=' + Height + ',' + showStatusBar + ',' + showToolBar + ',' + showMenuBar + ',' + showLocation + ',' + showScrollBar + ',' + showResize + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y);
	}


function underconstruction(){
     alert('This feature is under construction');
   }

function rowon(row){
	row.className='rowhighlight';
	}

function rowoff(row){
	row.className='tnavTabContent';
	}

function rowHoverOn(row){
	row.className='rowHover';
	}

function rowHoverOff(row){
	row.className='rowNormal';
	}


function Left(str, n)
{
        if(n <= 0)							// Invalid bound, return blank string
                return '';
        else if (n > String(str).length)	// Invalid bound, return
                return str;					// entire string
        else								// Valid bound, return appropriate substring
                return String(str).substring(0,n);
}

function Right(str, n)
{
        if (n <= 0)							// Invalid bound, return blank string
           return "";
        else if (n > String(str).length)	// Invalid bound, return
           return str;						// entire string
        else {								// Valid bound, return appropriate substring
           var iLen = String(str).length;
           return String(str).substring(iLen, iLen - n);
        }
}








/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
**/

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

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 isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}



function dateDiff(psDateVal1, psDateVal2) {
	date1 = new Date();
	date2 = new Date();
	diff  = new Date();
	
	var psTimeVal1 = '01:00:00';
	var psTimeVal2 = '01:00:00';

	if (isDate(psDateVal1)) { // Validates first date 
		date1temp = new Date(psDateVal1 + " " + psTimeVal1);
		date1.setTime(date1temp.getTime());
	}
	else return false; // otherwise exits


	if (isDate(psDateVal2)) { // Validates second date 
		date2temp = new Date(psDateVal2 + " " + psTimeVal2);
		date2.setTime(date2temp.getTime());
	}
	else return false; // otherwise exits

	// sets difference date to difference of first date and second date

	diff.setTime(date2.getTime() - date1.getTime());

	timediff = diff.getTime();
	
	if (timediff>=0){
		return true;
	}else{
		return false;
	}
	
}


	function checkadate(chkMonth,chkDay,chkYear)
	{
		/*Validate Date DropDown Selection fields (Dropdown Month, Dropdown Day, text field Year)*/
		var checkOK = "0123456789";
		var checkStr = chkYear.value;
		var allValid = true;
		var decPoints = 0;
		var allNum = "";
		for (i = 0;  i < checkStr.length;  i++)
		{
		  ch = checkStr.charAt(i);
		  for (j = 0;  j < checkOK.length;  j++)
		    if (ch == checkOK.charAt(j))
		      break;
		  if (j == checkOK.length)
		  {
		    allValid = false;
		    break;
		  }
		  allNum += ch;
		}
	  
		if (!allValid)
		{
		  alert("Please enter only numbers in the \"chkYear\" field.");
		  chkYear.focus();
		  return (false);
		}

		var chkVal = allNum;
		var prsVal = parseInt(allNum);
		if (chkVal != "" && !(prsVal >= "1900" && prsVal <= "2100"))
		{
		  alert("Please enter a value greater than or equal to \"1900\" and less than or equal to \"2100\" in the Year field.");
		  chkYear.focus();
		  return (false);
		}
	
		var piSumDate = 0;
		if (chkMonth.selectedIndex != 0){piSumDate = 1;}			
		if (chkDay.selectedIndex != 0){piSumDate = piSumDate + 1;}
		if (chkYear.value != ""){piSumDate = piSumDate + 1;}

		if (piSumDate == 0){
			//no field values entered... no checking required
		}else if (piSumDate == 3){
			var usrBirthDate = chkMonth.value + '/' + chkDay.value + '/' + chkYear.value;
			if (isDate(usrBirthDate)==false){
				chkDay.focus();
				return (false);
			}
		}else{
			alert('Please enter the Month, Day and Year for the date');
			chkYear.focus();
			return (false);
		}
			  
	  return (true);
	}
	
	function checkanumber(chkNumber){
		var checkOK = "0123456789";
		var checkStr = chkNumber.value;
		var allValid = true;
		var decPoints = 0;
		var allNum = "";
		for (i = 0;  i < checkStr.length;  i++)
		{
		  ch = checkStr.charAt(i);
		  for (j = 0;  j < checkOK.length;  j++)
		    if (ch == checkOK.charAt(j))
		      break;
		  if (j == checkOK.length)
		  {
		    allValid = false;
		    break;
		  }
		  allNum += ch;
		}
		if (!allValid)
		{
			alert("Please enter only numbers in the field.");
			chkNumber.focus();
			return (false);
		}
	
	}
		

