

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname
function showevent (ID)
{
window.open("calendar/ShowEventDetails.asp?ID=" + ID, "nw",'titlebar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=120,left=200,width=600,height=500')

}
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}


function checkState(check, alerttxt) {
            var states = "ALAKAZARCACOCTDEDCFLGAHIIDILINIAKS";
            states += "KYLAMEMDMAMIMSMNMOMTNENMNVNHNJNMNY";
            states += "NCNDOHOKORPARISCSDTNTXUTVTVAWAWVWIWY";

            // Include the following to test for Canadian provinces.
            /* Canadian provinces included only if
               a second parameter is supplied and is set to true. */
            if (arguments[2])
               states += "ABBCMBNBNFNSONPEPQSK";
            /* If the string is found in an even position, the state
               is valid. */
			if  ((states.indexOf(check) % 2))
			{
				alert(alerttxt);
				return false;
			}
            return true;
}

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}

function validateEmail(field) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = field;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
   return true;
}

function validatePermission(chk, alertTxt){
  if (!(chk.checked))
  {
    alert(alertTxt);
    return false;
  }
  else
    return true;
}





function validate_form(thisform)
{
	var boolIsValid = true;
	
with (thisform)
  {
  if (validate_required(fname,"Please Enter a value for First Name")==false)
  {
	fname.focus();
	boolIsVaild = false;
  }
  if (validate_required(lname,"Please Enter a value for Last Name")==false)
  {
	lname.focus();
	boolIsValid = false;
  }	
  if (validate_required(city,"Please Enter a value for City")==false)
  {
	city.focus();
	boolIsValid = false;
  }
  if (checkState(state.value, "Please enter a valid 2 digit state abreviation") ==false)
  {
	state.focus();
	boolIsValid = false;
  }
  if (validateZIP(zip.value) ==false)
  {
	zip.focus();
	boolIsValid = false;
  }
 if (validateEmail(email.value) ==false)
  {
	email.focus();
	boolIsValid = false;
  }
  if (validate_required(comments,"Please Enter a Comment to be sent to the office.")==false)
  {
	comments.focus();
	boolIsVaild = false;
  } 
  if (validatePermission(PermissionGranted,"Please select the Permission Checkbox.")==false)
  {
	PermissionGranted.focus();
	boolIsVaild = false;
  }
}

  
  return boolIsValid;
  
}