// --------------------------------------------
// DEFINE THE PATH TO THIS WEBSITE
// --------------------------------------------
// This needs to be changed once you move these 
// pages to your webserver.
// --------------------------------------------
//var PATH = "http://CDEV2/"
var PATH = "http:www.charlottefl.com/outreach/CDEV2_SEARCH/"


//-----------------------------------------
// DECLARE VARIABLES
//-----------------------------------------
var msgWindow = null; 
var avWidth = screen.availWidth;
var avHeight = screen.availHeight;
var w = 0;
var h = 0;



//-----------------------------------------
//  FUNCTION:  CENTER THE WINDOW
//-----------------------------------------
//  generic window opener used by help,
//  remarks, comments and thankyou windows
//-----------------------------------------
function CenterWindow(url,w,h,scroll) {
	var scr;
	scr = ((scroll) ? "scrollbars," : "");

	// only allow one window open at a time
	if (msgWindow != null && msgWindow.open) msgWindow.close();

	// hide or show scrollbars based upon scroll parameter
	msgWindow = window.open(url,'', scr+'width=' + w + ',height=' + h + ',left=' +((avWidth  - w - 10) * .5) + ',top=' + ((avHeight  - h - 30) * .5));
}

//-----------------------------------------
// INPUT VERIFICATION BEFORE FORM SUBMISSION
//-----------------------------------------
//  FUNCTION:  CHECK PERMIT NUMBER
//-----------------------------------------
function CheckPermitNumber(form) {

	if (form.PERMIT_NBR.value.length < 8  || form.PERMIT_NBR.value.length > 10) {
		alert("The length of Permit Numbers must be \n" +
		      " between 8 and 10 numbers long.");
		return false;
	}
	if (isValid(form.PERMIT_NBR.value,'0123456789') == false) {	
		alert("Please enter numbers only.")
                form.PERMIT_NBR.focus();
                return false;
	}
	return true;
}
//-----------------------------------------
// INPUT VERIFICATION BEFORE FORM SUBMISSION
//-----------------------------------------
//  FUNCTION:  NUMBERS ONLY
//  make sure we accept only numeric values
//-----------------------------------------
function isValid(string,allowed) {

    for (var i=0; i< string.length; i++) {
       if (allowed.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}


//-----------------------------------------
// INPUT VERIFICATION BEFORE FORM SUBMISSION
//-----------------------------------------
//  FUNCTION:  CHECK ADDRESS INPUT
//-----------------------------------------
function CheckAddress(form) {
	if (form.ADDRESS.value == "") {
		alert("Please enter a Street Name.");
		return false;
	}
//12/19/2005 NClauss - changed to 2 characters from 3 so PO St would work
	if (form.ADDRESS.value.length < 2) {
		alert("Please enter at least two characters for Address.");
		return false;
	}
	return true;
}
//-----------------------------------------
//  FUNCTION:  GO HOME
//-----------------------------------------
//  Go to CDEV Home page, but first open
//  and display a Thank You window
//-----------------------------------------  
function GoHome() {
	// popup the thank you window
	CenterWindow("http://www.charlottefl.com/outreach/CDEV2_SEARCH/Help/thank_you.htm",400,180,false);
 
	// now, show the home page in the main browser window
   	window.location = "http://www.charlottecountyfl.com/bcs/"  
} 
 
//-----------------------------------------
//  FUNCTION:  GO PERMIT STATUS
//-----------------------------------------
//  Go to the Permit Status Search page
//----------------------------------------- 
function goPermitStatus(){
	window.location.href = "http://www.charlottefl.com/outreach/CDEV2_SEARCH/Search/Permit_Search.asp";
}

//-----------------------------------------
//  FUNCTION:  GO CONTRACTOR STATUS
//-----------------------------------------
//  Go to the Contractor Status Search page
//----------------------------------------- 
function goContractorStatus(){
	window.location.href = "http://www.charlottefl.com/outreach/CDEV2_SEARCH/Search/Contractor_Search.asp";
}


//-----------------------------------------
//  FUNCTION:  CLOSE WINDOW
//-----------------------------------------
//  Close this window
//-----------------------------------------
function CloseWindow() {
	self.close();
}

//-----------------------------------------
//  FUNCTION:  PRINT WINDOW
//-----------------------------------------
//  Prints the contents of the remarks window
//-----------------------------------------
function PrintWindow() {
print();
}

//-----------------------------------------
//  FUNCTION:  OPEN HELP WINDOW
//-----------------------------------------
//  Opens the Help page in a separate window
//-----------------------------------------
function OpenHelp() {
	CenterWindow("http://www.charlottefl.com/outreach/CDEV2_SEARCH/Help/PermitStatus_Help.htm",550,400,true);
}


//-----------------------------------------
//  FUNCTION: flagDescription
//-----------------------------------------
//   Color Expired text grey
//-----------------------------------------
function flagDescription(ts) { 
	if (ts == "ARCHIVED OR EXPIRED") {
		document.write('<font color="#999999">');  // medgray "#C0C0C0" litegrey "#808080" grey
		document.write("ARCHIVED OR EXPIRED");
		document.write('</font>');
	}
	else {
		document.write(ts);
	}
}
