<!--
	// Java scripts for data checking
//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code visit http://www.dynamicdrive.com

var highlightcolor="lightYellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}

}	


var month = 0;
var day = 0;
var year = 0;



function isaDate(thisDate){


var date = thisDate.value
	if (date.length == 0)
	{
		return true;
	}
	else
	{
	if (date.length > 0 )
	{
		date = validNumber(date)
		if ( date.length == 7)
		{
		    date = "0" + date
		}
		if ( date.length == 8) //ie. 01012001
		{
			if((isValidDate(date))==true)
			{
				//insert "/" to make it look like 01/01/2001
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5) + date.charAt(6) + date.charAt(7);
				return true;
		
			}
			else
			{
				return false;
			}
		} // end if ( date.length == 8)
		if ( date.length == 7) //ie. 1012001
		{
			if((isValidDate(date))==true)
			{
				//insert "/" to make it look like 01/01/2001
				thisDate.value = date.charAt(0) + "/" + date.charAt(1) + date.charAt(2) + "/" + date.charAt(3) + date.charAt				(4) + date.charAt(5) + date.charAt(6);
				return true;
			}
			else
			{
				return false;
			}
		} // end if ( date.length == 7)
		else if (date.length == 6)
		{
			if (date.charAt(4) < "6")  //if the year part ** < 60, we look at it as 20**, otherwise, it is 	19**
			{
				date = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3) + "20" + date.charAt(4) + date.charAt(5);
			}
			else
			{
				date = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3) + "19" + date.charAt(4) + date.charAt(5);
			}
			if((isValidDate(date))==true)
			{
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5)+ date.charAt(6) + date.charAt(7);
				return true;

			}
			else
			{
				return false;
			}
		} //end if (date.length == 6)
		else if (date.length == 4)
		{
			if (date.charAt(4) < "6")
			{
				date = "0" + date.charAt(0) + "0" + date.charAt(1)  + "20" + date.charAt(2) + date.charAt(3);
			}
			else
			{
				date = "0" + date.charAt(0) + "0" + date.charAt(1)  + "19" + date.charAt(2) + date.charAt(3);
			}
			if((isValidDate(date))==true)
			{
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5)+ date.charAt(6) + date.charAt(7);	
				return true;
			}
			else
			{
				return false;
			}
		} //end if (date.length == 4)
		else
		{
			//SB alert("the number of digits can only be 4 or 6 or 8");
			this.value=""
			return false;
		} 
	}// end if (date.length > 0 )
	}// end if (date.length == 0 )

}

function isBDate(thisDate){

var date = thisDate.value
	if (date.length == 0)
	{
		//isOK="true"
		return true;
	}
	else
	{
	if (date.length > 0 )
	{
		date = validNumber(date)
		if ( date.length == 7)
		{
		    date = "0" + date
		}
		if ( date.length == 8) //ie. 01012001
		{
			if((isValidDate(date))==true)
			{
				//insert "/" to make it look like 01/01/2001
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5) + date.charAt(6) + date.charAt(7);
			}
			return true;
		} // end if ( date.length == 8)
		else if (date.length == 6)
		{
			if (date.charAt(4) < "9")  //if the year part ** < 90, we look at it as 19**, otherwise, it is 20**
			{
				date = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3) + "19" + date.charAt(4) + date.charAt(5);
			}
			else
			{
				date = date.charAt(0) + date.charAt(1) + date.charAt(2) + date.charAt(3) + "20" + date.charAt(4) + date.charAt(5);
			}
			if((isValidDate(date))==true)
			{
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5)+ date.charAt(6) + date.charAt(7);
			}
			
			return true;
		} //end if (date.length == 6)

		else if (date.length == 4)
		{
			if (date.charAt(4) < "9")
			{
				date = "0" + date.charAt(0) + "0" + date.charAt(1)  + "19" + date.charAt(2) + date.charAt(3);
			}
			else
			{
				date = "0" + date.charAt(0) + "0" + date.charAt(1)  + "20" + date.charAt(2) + date.charAt(3);
			}
			if((isValidDate(date))==true)
			{
				thisDate.value = date.charAt(0) + date.charAt(1) + "/" + date.charAt(2) + date.charAt(3) + "/" + date.charAt(4) + date.charAt(5)+ date.charAt(6) + date.charAt(7);
			}
			return true;
		} //end if (date.length == 4)
		else
		{
			//SB alert("the number of digits can only be 4 or 6 or 8");
            this.value=""
			return false;
		} 
	}// end if (date.length > 0 )
	}// end if (date.length == 0 )

}


function isValidDate(dataStr)
{
	//translate strings into integers
	month = (dataStr.charAt(0) - "0")*10 + (dataStr.charAt(1) - "0");
	day = (dataStr.charAt(2) - "0")*10 + (dataStr.charAt(3) - "0");
	year = (dataStr.charAt(4) - "0")*1000 + (dataStr.charAt(5) - "0")*100 + (dataStr.charAt(6) - "0")*10 + (dataStr.charAt(7) - "0");
	
	
	//alert(month);

	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}



	if (day < 1 || day > 31) { // check day range
		alert("Day must be between 1 and 31.");
		return false;
	}

	if ((month==4 || month==6 || month==9 || month==11) && day==31) { 
		alert("Month "+month+" doesn`t have 31 days!")
		return false;
	}

	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn`t have " + day + " days!");
			return false;
		}
	}
	return true;
	
}

function isInRange(thisDate, past, future)
{
	var dataStr = thisDate.value;
	year = (dataStr.charAt(6) - "0")*1000 + (dataStr.charAt(7) - "0")*100 + (dataStr.charAt(8) - "0")*10 + (dataStr.charAt(9) - "0");
	var now = new Date(); 
	var now_year = now.getFullYear();
	
	difference = year - now_year;
	if(difference >= past && difference <= future)
	{
		return true;
	}
	else
	{
		alert("The year should be within the past " + past + " years and " + future + " years in the future")
		return false;
	}
}

function addDay(currentObj, days)
{
	if((month <=0) || (day<=0) || (year<=0)){
		alert("invalid day to populate into the next date field")
	}
	else
	{
		var time = new Date(year, month-1, day);
		var count = 1000*60*60*24*1;  //million seconds for one hour
    	
    	// convert the time to milliseconds.
    	var buffer = Date.parse(time) ;
		
    	// Add the one day
    	buffer += count ;

    	// Construct a *new* Date by passing in the milliseconds.
    	var newDate = new Date(buffer) ;
    	if(currentObj.name != null)
    	{
			for( j = 0; j< document.forms(0).elements.length - 1; j++)
			{
				if(document.forms(0).elements[j].name==currentObj.name)
					break;
			}
			if( j == document.forms(0).elements.length )
				alert("there isn't a next object to set text")
			else
			{
				newMonth = newDate.getMonth() + 1
				if ( newMonth < 10 )
					newMonth = "0" + newMonth
				
				
				newDay = newDate.getDate()
				if(newDay < 10)
					newDay = "0" + newDay
				
				newYear = newDate.getFullYear()
				
				document.forms(0).elements[j+1].value = newMonth + "/" + newDay + "/" + newYear
			}
		}
	}
	
}

function isPhoneEmpty(thisNumber){
	if(thisNumber.value.length == 0)
	{
		alert(thisNumber.name + " can not be empty");
		thisNumber.select();
		thisNumber.focus();
		return true;
	}  
	return false;
}
		
function isPhoneNumber(thisNumber){

	var number = thisNumber.value
	
if (number.length == 0 )
	{
	return true;
}
else
{
	if (number.length > 0 )
	{
		number = validNumber(number)
		if ( number.length == 10) //ie. 6082131960
		{
			thisNumber.value = "(" + number.charAt(0) + number.charAt(1) + number.charAt(2) + ")"  + number.charAt(3) + number.charAt(4) + number.charAt(5) + "-" + number.charAt(6) + number.charAt(7)+ number.charAt(8) + number.charAt(9);
			return true;
		} // end if ( number.length == 8)
		else
		{
			//SB  alert("the number of digits must be 10");
			this.value=""
			return false;
			
		}		
	}// end if (number.length > 0 )	
	}// end if (number.length == 0 )	

	return false;
}

function validNumber(number)
{
	var checkOK = "0123456789"  //to Check if the input contains all numbers
	var validNumber =""
	for (i = 0;  i < number.length;  i++)
	{
		ch = number.charAt(i)
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
				validNumber = validNumber + ch;
		}
	}
	return validNumber 
}

//Function to see if core num is valid
function validCoreNum(CoreNumber,validRange){
var thisNum = CoreNumber
var thisRange = validRange

if (thisNum <= validRange)
{

	return true
}
else
{
	alert("Must be less than or equal to " + validRange);
	return false
}
}


function openIT(theURL,theWindowName){
	var winLeft = (screen.width - 800) / 2;
	var winLeft = 1
	var winUp = (screen.height - 800) / 2;
				open(theURL,theWindowName,"resizable=1,location=yes,toolbar=yes,status=yes,titlebar=yes,menubar=yes,width=700,height=400,left=1,top="+winUp+",scrollbars=yes");			

}

function openITSmall(theURL){
	var winLeft = (screen.width - 800) / 2;
	var winUp = (screen.height - 800) / 2;
			open(theURL,"Find","resizable=1,location=no,toolbar=no,status=no,titlebar=yes,menubar=no,width=700,height=520,left="+winLeft+",top="+winUp+",scrollbars=yes");
		}


function textCounter(field, countfield, maxlimit) 
	{

	if (field.value.length > maxlimit) // if too long...trim it!
		{
		field.value = field.value.substring(0, maxlimit);
		alert ("Warning: You have exceeded the maximum characters available. Please modify your entry.");
		}	

	// otherwise, update 'characters left' counter
	else 
		{		
		countfield.value = maxlimit - field.value.length;
		}
	}

function getCounty(theCity,theFrom,theTo,theForm,theRegion){
	parent.hiddenstuff.location="findcounty.asp?city="+theCity+"&from="+theFrom+"&to="+theTo+"&form="+theForm+"&region="+theRegion;
}


function isEmpty(thisDate){
	if(thisDate.value.length == 0)
	{
		alert(thisDate.name + " can not be empty");
		return true;
	}  
	return false;
}


function isInRange(thisDate, past, future)
{
	var dataStr = thisDate.value;
	year = (dataStr.charAt(6) - "0")*1000 + (dataStr.charAt(7) - "0")*100 + (dataStr.charAt(8) - "0")*10 + (dataStr.charAt(9) - "0");
	var now = new Date(); 
	var now_year = now.getFullYear();
	
	difference = year - now_year;
	if(difference >= past && difference <= future)
	{
		return true;
	}
	else
	{
		alert("The year should be within the past " + past + " years and " + future + " years in the future")
		return false;
	}
}

function addDay(currentObj, days)
{
	Alret("addday");
	if((month <=0) || (day<=0) || (year<=0)){
		alert("invalid day to populate into the next date field")
	}
	else
	{
		var time = new Date(year, month-1, day);
		var count = 1000*60*60*24*1;  //million seconds for one hour
    	
    	// convert the time to milliseconds.
    	var buffer = Date.parse(time) ;
		
    	// Add the one day
    	buffer += count ;

    	// Construct a *new* Date by passing in the milliseconds.
    	var newDate = new Date(buffer) ;
    	if(currentObj.name != null)
    	{
			for( j = 0; j< document.forms(0).elements.length - 1; j++)
			{
				if(document.forms(0).elements[j].name==currentObj.name)
					break;
			}
			if( j == document.forms(0).elements.length )
				alert("there isn't a next object to set text")
			else
			{
				newMonth = newDate.getMonth() + 1
				if ( newMonth < 10 )
					newMonth = "0" + newMonth
				
				
				newDay = newDate.getDate()
				if(newDay < 10)
					newDay = "0" + newDay
				
				newYear = newDate.getFullYear()
				
				document.forms(0).elements[j+1].value = newMonth + "/" + newDay + "/" + newYear
			}
		}
	}
	
}

function sameDay(currentObj, days)
{
	if((month <=0) || (day<=0) || (year<=0)){
		alert("invalid day to populate into the next date field")
	}
	else
	{
		var time = new Date(year, month-1, day);
		var count = 1000*60*60*24*1;  //million seconds for one hour
    	
    	// convert the time to milliseconds.
    	var buffer = Date.parse(time) ;
		
    	// Add the one day
    	//buffer += count ;

    	// Construct a *new* Date by passing in the milliseconds.
    	var newDate = new Date(buffer) ;
    	if(currentObj.name != null)
    	{
			for( j = 0; j < document.forms(0).elements.length - 1; j++)
			{
				if(document.forms(0).elements[j].name==currentObj.name)
					break;
			}
			if( j == document.forms(0).elements.length )
				alert("there isn't a next object to set text")
			else
			{
				newMonth = newDate.getMonth() + 1
				if ( newMonth < 10 )
					newMonth = "0" + newMonth
				
				
				newDay = newDate.getDate()
				if(newDay < 10)
					newDay = "0" + newDay
				
				newYear = newDate.getFullYear()
				
				if (document.forms(0).elements[j-2].value == "" )
					document.forms(0).elements[j-2].value = newMonth + "/" + newDay + "/" + newYear
			}
		}
	}
	
}

function updatedcolor(thisis)
{
document.getElementById(thisis.name).style.backgroundColor="#E9EAA2";
document.getElementById("txtChangesMade").value="yes"; 

}


function ChecktheDate(field)
{

if(!isaDate(field))
{
    alert ("Please enter a valid date.  Dates must be in the following format: 12/05/97.  You may enter dates without the slashes, for example to enter 12/05/97, type 120597.  The slashes will be added automatically.");
    field.value="";
    field.focus()
    field.select()
}

}

    var _oldColor;

    

    function SetNewColor(source)

    {

        _oldColor = source.style.backgroundColor;
        source.style.backgroundColor = '#D6F2F2';

    }

    

    function SetOldColor(source)

    {

        source.style.backgroundColor = _oldColor;

    }
    


//-->