//JS Functions @0-3D735901
var isNN = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);
var IEVersion = (isIE ? getIEVersion() : 0);
var NNVersion = (isNN ? getNNVersion() : 0);
var EditableGrid = false;
var disableValidation = false;

var lastVisitedLink = null;
var lastVisitedLinkColor = null;

var menuHash = new Array();

// Start of My function 2007-01-01

var http_request = false;

var eventsSearch_DatePicker_s_date_start = new Object(); 
eventsSearch_DatePicker_s_date_start.format           = "mm/dd/yyyy";
eventsSearch_DatePicker_s_date_start.style            = "Styles/Basic/Style.css";
eventsSearch_DatePicker_s_date_start.relativePathPart = "";
eventsSearch_DatePicker_s_date_start.themeVersion     = "3.0";

function popUp(URL) {

	nwin = window.open(URL, 'Staff', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=750,height=600');
}

var version4 = (navigator.appVersion.charAt(0) == "4"); 
var popupHandle;
function closePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close();
}
function displayPopup(position,url,name,height,width,evnt) {
// position=1 POPUP: makes screen display up and/or left, down and/or right 
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center
var properties = "scrollbars=1, toolbar = 0, location = 0, height = " + height;
properties = properties + ", width=" + width;
var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
if(navigator.appName == "Microsoft Internet Explorer") {
screenY = document.body.offsetHeight;
screenX = window.screen.availWidth;
}
else {
screenY = window.outerHeight
screenX = window.outerWidth
}
if(position == 1)	{ // if POPUP not CENTER
cursorX = evnt.screenX;
cursorY = evnt.screenY;
padAmtX = 10;
padAmtY = 10;
if((cursorY + height + padAmtY) > screenY) {
// make sizes a negative number to move left/up
padAmtY = (-30) + (height * -1);
// if up or to left, make 30 as padding amount
}
if((cursorX + width + padAmtX) > screenX)	{
padAmtX = (-30) + (width * -1);	
// if up or to left, make 30 as padding amount
}
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = cursorX + padAmtX;
topprop = cursorY + padAmtY;
}
else {
leftprop = (cursorX - pageXOffset + padAmtX);
topprop = (cursorY - pageYOffset + padAmtY);
   }
}
else{
leftvar = (screenX - width) / 2;
rightvar = (screenY - height) / 2;
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = leftvar;
topprop = rightvar;
}
else {
leftprop = (leftvar - pageXOffset);
topprop = (rightvar - pageYOffset);
   }
}
if(evnt != null) {
properties = properties + ", left = " + leftprop;
properties = properties + ", top = " + topprop;
}
closePopup();
popupHandle = open(url,name,properties);
}

function getEltById(id) {

  return document.getElementById ? document.getElementById(id)
        : (document.all ? document.all[id] : document[id]);
}

function getFrameEltById(id) {

/*
	if ( window.contentFrame && window.contentFrame[id] ) {

		return window.contentFrame[id];

    } else if ( window.parent.contentFrame && window.parent.contentFrame[id]) {

	  	return window.parent.contentFrame[id];

    } else {

		return getEltById(id);
    }
*/
	//for (i=0; i<window.parent.frames.length; i++) {
    //alert("The title of frame #" + i + " is: " + window.parent.frames(i).document.title);	
	//}

	return getEltById(id);
}

function makeRequest(url) {

	window.location.href=url;
}

function makeRequest_org(url) {

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function alertContents() {

    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //var xmldoc = http_request.responseXML;
            //var root_node = xmldoc.getElementsByTagName('root').item(0);
            //alert(root_node.firstChild.data);
            //MainContent.innerHTML = http_request.responseText; 
			var contentObj = getEltById("MainContent");
			contentObj.innerHTML =  http_request.responseText;
			//var nextHeight = getEltById('MainContent').offsetHeight;
			//getEltById('footer').style.pixelTop = (nextHeight >= 450)?nextHeight:450;
		
			getEltById('searchBlock').style.height  = 0;
			//getEltById('searchBlock').style.backgroundColor = "#e6e6e4"; 
			//getEltById('searchBlock').style.backgroundImage = "url('images/nav_bg.jpg')";
			getEltById('Menu75').style.backgroundImage = "url('images/1-1-6_2.jpg')";

			var navColumn = getEltById('navColumn');
			var mainContent = getEltById('MainContent');
			
			var nextH = ( navColumn.offsetHeight > mainContent.offsetHeight ) ? 
				navColumn.offsetHeight : mainContent.offsetHeight;

			getEltById('footer').style.top = ( navColumn.offsetHeight > mainContent.offsetHeight ) ? 
				navColumn.offsetHeight : mainContent.offsetHeight;

			getEltById('searchBlock').style.height = nextH - getEltById('searchBlock').offsetTop;


		} else {
            alert('There was a problem with the request.');
        }
    }

}

function menuBackground() {

			getEltById('searchBlock').style.height  = 0;
			//getEltById('searchBlock').style.backgroundColor = "#e6e6e4"; 
			//getEltById('searchBlock').style.backgroundImage = "url('images/nav_bg.jpg')";
			getEltById('Menu75').style.backgroundImage = "url('images/1-1-6_2.jpg')";

			var navColumn = getEltById('navColumn');
			var mainContent = getEltById('MainContent');
			
			var nextH = ( navColumn.offsetHeight > mainContent.offsetHeight ) ? 
				navColumn.offsetHeight : mainContent.offsetHeight;

			getEltById('footer').style.top = ( navColumn.offsetHeight > mainContent.offsetHeight ) ? 
				navColumn.offsetHeight : mainContent.offsetHeight;

			getEltById('searchBlock').style.height = nextH - getEltById('searchBlock').offsetTop;
}

function rdMakeRequest(url) {

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = rdContents;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function rdContents() {

    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //var xmldoc = http_request.responseXML;
            //var root_node = xmldoc.getElementsByTagName('root').item(0);
            //alert(root_node.firstChild.data);
			//var innerContent = getFrameEltById('RD_LEVEL_CONTENT');
			var innerContent = document.getElementById('RD_LEVEL_CONTENT');
			innerContent.innerHTML = http_request.responseText;

			getEltById('searchBlock').style.height = 0;
			//getEltById('searchBlock').style.backgroundColor = "#e6e6e4"; 
			//getEltById('searchBlock').style.backgroundImage = "url('images/nav_bg.jpg')";
			getEltById('Menu75').style.backgroundImage = "url('images/1-1-6_2.jpg')";

			var navColumn = getEltById('navColumn');
			var mainContent = getEltById('MainContent');

			if (getEltById('footer')) {
			
				var nextH = ( navColumn.offsetHeight > mainContent.offsetHeight ) ? 
					navColumn.offsetHeight : mainContent.offsetHeight;

				getEltById('footer').style.top = nextH;
				
				getEltById('searchBlock').style.height = 
				     nextH - 
					 getEltById('searchBlock').offsetTop;

			}

        } else {
            alert('There was a problem with the request.');
        }
    }

}

function OpMakeRequest(url) {

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = OpContents;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function OpContents() {

    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //var xmldoc = http_request.responseXML;
            //var root_node = xmldoc.getElementsByTagName('root').item(0);
            //alert(root_node.firstChild.data);
            OTHER_CONTENT.innerHTML = http_request.responseText;  
        } else {
            alert('There was a problem with the request.');
        }
    }

}

function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
     http_request = new XMLHttpRequest();
     if (http_request.overrideMimeType) {
     	// set type accordingly to anticipated content type
        //http_request.overrideMimeType('text/xml');
        http_request.overrideMimeType('text/html');
     }
  } else if (window.ActiveXObject) { // IE
     try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
        try {
           http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
     }
  }
  if (!http_request) {
     alert('Cannot create XMLHTTP instance');
     return false;
  }
  
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function myEventSubmit(poststr) {
  makePOSTRequest('Events.php?ccsForm=eventsSearch', poststr);
}

function myArticleSubmit(poststr) {
  makeRequest('Articles.php?' + poststr);
}

function myStaffSubmit(poststr) {
  makeRequest('Staffs.php?' + poststr);
}

function myGallerySubmit(poststr) {
  makeRequest('default.php?module=g&' + poststr);
}

// End of My Function



// Date formatting functions begin ---------------------------------------------------


var arrayLocaleInfo = "en|en|US|Yes;No;|2|.|,|January;February;March;April;May;June;July;August;September;October;November;December|Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec|Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday|Sun;Mon;Tue;Wed;Thu;Fri;Sat|m/d/yyyy|dddd, mmmm dd, yyyy|h:nn tt|h:nn:ss tt|0|AM|PM".split("|");


function getLocaleInfo(id)
{
	switch (id)
	{
	case "LanguageAndCountry":	return arrayLocaleInfo[0];
	case "language":			return arrayLocaleInfo[1];
	case "country":				return arrayLocaleInfo[2];
	case "booleanFormat":		return arrayLocaleInfo[3];
	case "decimalDigits":		return arrayLocaleInfo[4];
	case "decimalSeparator":	return arrayLocaleInfo[5];
	case "groupSeparator":		return arrayLocaleInfo[6];
	case "monthNames":			return arrayLocaleInfo[7];
	case "monthShortNames":		return arrayLocaleInfo[8];
	case "weekdayNames":		return arrayLocaleInfo[9];
	case "weekdayShortNames":	return arrayLocaleInfo[10];
	case "shortDate":			return arrayLocaleInfo[11];
	case "longDate":			return arrayLocaleInfo[12];
	case "shortTime":			return arrayLocaleInfo[13];
	case "longTime":			return arrayLocaleInfo[14];
	case "firstWeekDay":		return arrayLocaleInfo[15];
	case "AMDesignator":		return arrayLocaleInfo[16];
	case "PMDesignator":		return arrayLocaleInfo[17];
	}
	return "";
}



var listMonths = String(getLocaleInfo("monthNames")).split(";");
var listShortMonths = String(getLocaleInfo("monthShortNames")).split(";");
var firstWeekDay = getLocaleInfo("firstWeekDay");
var listWeekdays = String(getLocaleInfo("weekdayNames")).split(";");
var listShortWeekdays = String(getLocaleInfo("weekdayShortNames")).split(";");
firstWeekDay = listShortWeekdays[parseInt(firstWeekDay)];


function isInArray(strValue, arrArray)
{
  var intResult = -1;
  for ( var j = 0; j < arrArray.length && (strValue != arrArray[j]); j++ );
  if ( j != arrArray.length )
    intResult = j;    
  return intResult;
}

function parseDateFormat(strMask)
{

 if (strMask=="LongDate")
      return  parseDateFormat(getLocaleInfo("longDate"));
 else if (strMask=="LongTime")
      return  parseDateFormat(getLocaleInfo("longTime"));
 else if (strMask=="ShortDate")
      return  parseDateFormat(getLocaleInfo("shortDate"));
 else if (strMask=="ShortTime")
      return  parseDateFormat(getLocaleInfo("shortTime"));
 else if (strMask=="GeneralDate")
      return  parseDateFormat(getLocaleInfo("shortDate")+" "+getLocaleInfo("longTime"));

  var UNDEF;
  var arrResult = new Array();             
  if (strMask == "" || typeof(strMask) == "undefined")
    return arrResult;
  var arrMaskTokens = new Array(
  "d", "w", "m", "M", "q", "y", "h", "H", "n", "s", 
  "dd", "ww", "mm", "MM", "yy", "hh", "HH", "nn", "ss", "S",
  "ddd", "mmm", "MMM", "A/P", "a/p", "dddd", "mmmm", "MMMM", 
  "yyyy", "tt", "AM/PM", "am/pm", "LongDate", "LongTime", 
  "ShortDate", "ShortTime", "GeneralDate");
  var arrMaskTokensFirstLetters = new Array("d", "w", "m", "M",
  "q", "y", "h", "H", "n", "s", "A", "a", "L", "S", "G", "t");
  var strMaskLength = strMask.length;
  var i = 0, intMaskPosition = 0;
  var arrMask = new Array();
  var strToken = "";
  while (i < strMaskLength)
  {
  if (strMask.charAt(i) == "\\")
  {
    strToken += strMask.charAt(++i);
    i ++;
  }
  else if (strMask.charAt(i) == "'")
  {
    i ++;
    while ((i < strMask.length) && (strMask.charAt(i) != "'"))
    strToken += strMask.charAt(i++);
    i ++;
  }
  else
  {
    var j = isInArray(strMask.charAt(i), arrMaskTokensFirstLetters);
    if ( j != -1 )
    {
    var k;
    for (k = (arrMaskTokens.length - 1); k >= 0 && 
      strMask.slice(i, i + arrMaskTokens[k].length) != arrMaskTokens[k]; k--);
    if (k != -1)
    {
      if (strToken.length > 0)
      {
      if ( isInArray(strToken, arrMaskTokens) == -1)
        arrMask[intMaskPosition ++] = strToken;
      else
        arrMask[intMaskPosition ++] = "\\" + strToken;
      strToken = "";
      }
      arrMask[intMaskPosition ++] = arrMaskTokens[k];
      i += arrMaskTokens[k].length;
    }
    else
    {
      strToken = strMask.charAt(i);
      i ++;
    }
    }
    else
    {
    strToken += strMask.charAt(i);
    i ++;
    }
  }
  }
  if (strToken.length > 0)
  {

  if ( isInArray(strToken, arrMaskTokens) == -1)
    arrMask[intMaskPosition ++] = strToken;

  else
    arrMask[intMaskPosition ++] = "\\" + strToken;

  strToken = "";
  }
  arrResult = arrMask;
  return arrResult;
}

function parseParams(text,substitutions)
{
  // replace the {0}, ... with corresponded substitution string and return the result
  var resString = text;
  if (resString!="" && substitutions!=null)
  {
    var array = (typeof(substitutions)!="object")?(new Array(substitutions)):substitutions;
    var icount = array.length;
    for (var i=0; i<icount; i++) 
      resString = resString.replace("{"+i+"}", array[i]);
    delete array;
    array = null;
  }
  return resString;
}

function functionExists(functionName)
{
  var exists = true;
  try{
    exists = typeof(eval(functionName))=="function";
  }catch(e){
    exists = false;
  }
  return exists;
}

function ccsShowError(control, msg)
{
  alert(msg);
  control.focus();
  return false;
}

function getNNVersion()
{
  var userAgent = window.navigator.userAgent;
  var isMajor = parseInt(window.navigator.appVersion);
  var isMinor = parseFloat(window.navigator.appVersion);
  if (isMajor == 2) return 2;
  if (isMajor == 3) return 3;
  if (isMajor == 4) return 4;
  if (isMajor == 5) 
  {
    if (userAgent.toLowerCase().indexOf('netscape')!=-1)
    {
      isMajor = parseInt(userAgent.substr(userAgent.toLowerCase().indexOf('netscape')+9));
      if (isMajor>0) return isMajor;
    }
    if (userAgent.toLowerCase().indexOf('firefox')!=-1) return 7;
    return 6;
  }
  return isMajor;
}

function getIEVersion()
{
  var userAgent = window.navigator.userAgent;
  var MSIEPos = userAgent.indexOf("MSIE");
  return (MSIEPos > 0 ? parseInt(userAgent.substring(MSIEPos+5, userAgent.indexOf(".", MSIEPos))) : 0);
}

function inputMasking(evt)
{
  if (isIE && IEVersion > 4)
  {
    if (window.event.altKey) return false;
    if (window.event.ctrlKey) return false;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = window.event.keyCode;
      this.value = applyMask(keycode, mask, this.value);
    }
    return (window.event.keyCode==13?true:false);
  } else if (isNN && NNVersion<6)
  {
    if (evt.ALT_MASK) return false;
    if (evt.CONTROL_MASK) return false;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = evt.which;
      this.value = applyMask(keycode, mask, this.value);
    }
    return (evt.which==13?true:false);
  } else if (isNN && NNVersion==6)
  {
    if (evt.ctrlKey) return false;
    var cancelKey = evt.which < 32;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = evt.which;
      if (keycode >= 32)
        this.value = applyMask(keycode, mask, this.value);
    }
    return cancelKey;
  } else if (isNN && NNVersion==7)
  {
    if (evt.altKey) return false;
    if (evt.ctrlKey) return false;
    var cancelKey = evt.which==13;
    if (typeof(this.ccsInputMask) == "string")
    {
      var mask = this.ccsInputMask;
      var keycode = evt.which;
      cancelKey = keycode < 32;
      if (!cancelKey)
        this.value = applyMask(keycode, mask, this.value);
    }
    return cancelKey || evt.which==13;
  } else
    return true;
}

function applyMaskToValue(mask, value)
{
  var oldValue = String(value);
  var newValue = "";
  var icount = oldValue.length;
  for (var i=0; i<icount; i++)
  {
    newValue = applyMask(oldValue.charCodeAt(i), mask, newValue);
  }
  return newValue;
}

function applyMask(keycode, mask, value)
{
  var digit = (keycode >= 48 && keycode <= 57);
  var plus = (keycode == 43);
  var dash = (keycode == 45);
  var space = (keycode == 32);
  var uletter = (keycode >= 65 && keycode <= 90);
  var lletter = (keycode >= 97 && keycode <= 122);
  
  var pos = value.length;
  switch(mask.charAt(pos))
  {
    case "0":
      if (digit)
        value += String.fromCharCode(keycode);
      break;
    case "L":
      if (uletter || lletter)
        value += String.fromCharCode(keycode);
      break;
    default:
      var isMatchMask = (String.fromCharCode(keycode) == mask.charAt(pos));
      while (pos < mask.length && mask.charAt(pos) != "0" && mask.charAt(pos) != "L")
        value += mask.charAt(pos++);
      if (!isMatchMask && pos < mask.length)
        value = applyMask(keycode, mask, value);
  }  
  return value;
}

function validate_control(control)
{
/*
ccsCaption - string
ccsErrorMessage - string

ccsRequired - boolean
ccsMinLength - integer
ccsMaxLength - integer
ccsRegExp - string

ccsValidator - validation function

ccsInputMask - string
*/
  if (disableValidation) return true;
  var errorMessage = control.ccsErrorMessage;
  var customErrorMessage = (typeof(errorMessage) != "undefined");
   
  if (typeof(control.ccsRequired) == "boolean" && control.ccsRequired)
    if (control.value == "")
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The value in field {0} is required.", control.ccsCaption));

  if (typeof(control.ccsMinLength) == "number")
    if (control.value != "" && control.value.length < parseInt(control.ccsMinLength))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The number of symbols in field {0} can't be less than {1}.", Array(control.ccsCaption,parseInt(control.ccsMinLength))));

  if (typeof(control.ccsMaxLength) == "number")
    if (control.value != "" && control.value.length > parseInt(control.ccsMaxLength))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The number of symbols in field {0} can't be greater than {1}.", Array(control.ccsCaption,parseInt(control.ccsMaxLength))));

  if (typeof(control.ccsInputMask) == "string")
  {
    var mask = control.ccsInputMask;
    var maskRE = new RegExp(stringToRegExp(mask).replace(/0/g,"\\d").replace(/L/g,"[A-Za-z]"), "i");
    if (control.value != "" && (control.value.search(maskRE) == -1))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The value in field {0} is not valid.", control.ccsCaption));
  }

  if (typeof(control.ccsRegExp) == "string")
    if (control.value != "" && (control.value.search(new RegExp(control.ccsRegExp, "i")) == -1))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The value in field {0} is not valid.", control.ccsCaption));

  if (typeof(control.ccsDateFormat) == "string")
  {
    if (control.value != "" && !checkDate(control.value, parseDateFormat(control.ccsDateFormat).join("")))
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The value in field {0} is not valid. Use the following format: {1}.", Array(control.ccsCaption, parseDateFormat(control.ccsDateFormat).join(""))));
  }

  if (typeof(control.ccsValidator) == "function")
    if (!control.ccsValidator())
      return ccsShowError(control, customErrorMessage ? errorMessage :
        parseParams("The value in field {0} is not valid.", control.ccsCaption));

  return true;
}


function stringToRegExp(string, arg)
{
  var str = String(string);
  str = str.replace(/\\/g,"\\\\");
  str = str.replace(/\//g,"\\/");
  str = str.replace(/\./g,"\\.");
  str = str.replace(/\(/g,"\\(");
  str = str.replace(/\)/g,"\\)");
  str = str.replace(/\[/g,"\\[");
  str = str.replace(/\]/g,"\\]");
  return str;
}

function checkDate(dateValue, dateFormat)
{
  dateFormat = dateFormat.replace("AM/PM","f1").replace("A/P","f2").replace("am/pm","f3").replace("a/p","f4");

  var DateMasks = new Array(
                    new Array("MMMM", "[a-z]+"),
                    new Array("mmmm", "[a-z]+"),
                    new Array("yyyy", "[0-9]{4}"),
                    new Array("MMM", "[a-z]+"),
                    new Array("mmm", "[a-z]+"),
                    new Array("HH", "([0-1][0-9]|2[0-4])"),
                    new Array("hh", "(0[1-9]|1[0-2])"),
                    new Array("dd", "([0-2][0-9]|3[0-1])"),
                    new Array("MM", "(0[1-9]|1[0-2])"),
                    new Array("mm", "(0[1-9]|1[0-2])"),
                    new Array("yy", "[0-9]{2}"),
                    new Array("nn", "[0-5][0-9]"),
                    new Array("ss", "[0-5][0-9]"),
                    new Array("w", "[1-7]"),
                    new Array("d", "([1-9]|[1-2][0-9]|3[0-1])"),
                    new Array("y", "([1-2][0-9]{0,2}|3([0-5][0-9]|6[0-5]))"),
                    new Array("H", "(00|0?[1-9]|1[0-9]|2[0-4])"),
                    new Array("h", "(0?[1-9]|1[0-2])"),
                    new Array("M", "(0?[1-9]|1[0-2])"),
                    new Array("m", "(0?[1-9]|1[0-2])"),
                    new Array("n", "[0-5]?[0-9]"),
                    new Array("s", "[0-5]?[0-9]"),
                    new Array("q", "[1-4]"),
                    new Array("tt", "("+getLocaleInfo("AMDesignator")+"|"+getLocaleInfo("PMDesignator")+")")
                  );
  var regExp = "^"+stringToRegExp(dateFormat)+"$";
  var icount = DateMasks.length;
  for (var i=0; i<icount; i++)
  {
    regExp = regExp.replace(DateMasks[i][0], DateMasks[i][1]);
  }
  regExp=regExp.replace("f1","(AM|PM)").replace("f2","(A|P)").replace("f3","(am|fm)").replace("f4","(a|f)");

  var regExp = new RegExp(regExp,"i");
  return String(dateValue).search(regExp)!=-1;
}

function validate_row(rowId, form)
{
  var result = true;
  var isInsert = false;
  if (disableValidation) return true;
  if(typeof(eval(form + "EmptyRows")) == "number")
    if(eval(form + "Elements").length - rowId <= eval(form + "EmptyRows"))
      isInsert = true;
  var icount = eval(form + "Elements")[rowId].length;
  for (var i = 0; i < icount && isInsert; i++)
    isInsert = GetValue(eval(form + "Elements")[rowId][i]) == "";
  if(isInsert) return true;

  if(typeof(eval(form + "DeleteControl")) == "number")
    {
      var control = eval(form + "Elements")[rowId][eval(form + "DeleteControl")];
      if(control.type == "checkbox")
        if(control.checked == true ) return true;
      if(control.type == "hidden")
        if(control.value != "" ) return true;
    }

  
  for (var i = 0; i < icount && (result = validate_control(eval(form + "Elements")[rowId][i])); i++);
  return result;
}

function GetValue(control) {
    if (typeof(control.value) == "string") {
        return control.value;
    }
    if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
        var j;
        var jcount = control.length;
        for (j=0; j < jcount; j++) {
            var inner = control[j];
            if (typeof(inner.value) == "string" && (inner.type != "radio" || inner.status == true)) {
                return inner.value;
            }
        }
    }
    else {
        return GetValueRecursive(control);
    }
    return "";
}

function GetValueRecursive(control)
{
    if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true)) {
        return control.value;
    }
    var i, val;
    var icount = control.children.length;
    for (i = 0; i<icount; i++) {
        val = GetValueRecursive(control.children[i]);
        if (val != "") return val;
    }
    return "";
}


function validate_form(form)
{
  var result = true;
  if (disableValidation) return true;
  if(typeof(form) == "object" && String(form.tagName).toLowerCase()!="form" && form.form!=null) form = form.form;
  if(typeof(form) == "object" && document.getElementById(form.name + "Elements")) {
    if (typeof(eval(form.name + "Elements")) == "object") 
    {
      var jcount = eval(form.name + "Elements").length;
      for (var j = 0; j < jcount && result; j++) result = validate_row(j, form.name);
    }else
    {
      var icount = form.elements.length;
      for (var i = 0; i < icount && (result = validate_control(form.elements[i])); i++);
    }
  }else if(typeof(form) == "string" && document.getElementById(form.name + "Elements"))
  {
    if(typeof(eval(form + "Elements")) == "object"){
      var jcount = eval(form + "Elements").length;
      for (var j = 0; j < jcount && result; j++)
        result = validate_row(j, form);
    }
  }else if (typeof(form) == "object")
        {
          var icount = form.elements.length;
          for (var i = 0; i < icount && (result = validate_control(form.elements[i])); i++);
        }
        else
        {
          var icount = document.forms[form].elements.length;
          for (var i = 0; i < icount && (result = validate_control(document.forms[form].elements[i])); i++);
        }
  return result;
}

function forms_onload()
{
  var forms = document.forms;
  var i, j, elm, form;
  var icount = forms.length;
  var arrElementsOnLoad = new Array();

  for(i = 0; i < icount; i++)
  {
    form = forms[i];
    if (typeof(form.onLoad) == "function") form.onLoad();
    var jcount = form.elements.length;

    for (j = 0; j < jcount; j++)
    {
      elm = form.elements[j];
      if (typeof(elm.onLoad) == "function") arrElementsOnLoad[arrElementsOnLoad.length] = elm;
    }
  }

  for (i = 0; i < arrElementsOnLoad.length; i++)
	arrElementsOnLoad[i].onLoad();

  return true;
}

function all_onload()
{
  var element = null;
  var elements = new Array();
  var icount = document.all.length;

  for(var i = 0; i < icount; i++)
  {
    element = document.all[i];
    if (typeof(element.onLoad) == "function") elements[elements.length] = element;
  }

  for (var i = 0; i < elements.length; i++)
    elements[i].onLoad();

  return true;
}

//
// If element exist than bind function func to element on event.
// Example: check_and_bind('document.NewRecord1.Delete1','onclick',page_NewRecord1_Delete1_OnClick);
//
function check_and_bind(element,event,func) {
  var htmlElement = eval(element);
  if (!htmlElement)
  {
    var index = element.lastIndexOf(".");
    var form = element.substr(0,index);
    var control = element.substr(index+1);
    var htmlForm = eval(form);
    if (htmlForm)
    {
      var list = document.getElementsByName(control);
      var icount = list.length;
      for (var i=0; i<icount; i++)
      {
        if (list[i].form && list[i].form.name==htmlForm.name)
        {
          eval("document.getElementsByName(\""+control+"\")["+i+'].'+event+'='+func);
        }
      }
    } 
  }else{
    if (htmlElement) {
      if (typeof(htmlElement)=="object" && !htmlElement.tagName && htmlElement.length > 0)
      {
        var icount = htmlElement.length;
        for (var i=0; i < icount; i++)
          eval(element+"["+i+'].'+event+'='+func);
      }else eval(element+'.'+event+'='+func);
    }
  }
}

function getElement(elementId, rowNumber) {
  var control = document.getElementById(elementId);
  if (control == null) {
    control = document.getElementById(elementId + "_" + rowNumber);
  }
  return control;
}

function getRowFromId(elementId) {
  var lastUnderscore = elementId.lastIndexOf("_");
  if (lastUnderscore != -1) {
    return elementId.substring(lastUnderscore + 1);
  }
  return null;
}

function getSameLevelCtl(elementName, existingElement) {
  var rowNumber = null;
  if (existingElement != null && existingElement['id'] != null) {
    rowNumber = getRowFromId(existingElement.id);
  }
  return getElement(elementName, rowNumber);
}

function addEventHandler(element, event, handler) {
  if (typeof(element) == "string") {
    return bindEventHandler(element, event, handler);
  }
  if (element) {
    var oldHandler = (element['on'+event]) ? element['on'+event] : function () {};
    element['on'+event] = function () {
      oldHandler.apply(element, arguments);
      handler.apply(element, arguments)
    };
    return true;
  }
  return false;
}

function bindEventHandler(elementName, event, handler) {
  var element = getElement(elementName);
  if (event == 'load' && elementName == "") { //Page
    handler.apply(element, arguments);
  }
  if (element != null) {
    if (event != 'load') {
      addEventHandler(element, event, handler);
    } else {
      handler.apply(element, arguments);
    }
  } else {
    var currentRow = 1;
    while (element = getElement(elementName, currentRow)) {
      if (event != 'load') {
        addEventHandler(element, event, handler);
      } else {
        handler.apply(element, arguments);
      }
      currentRow++;
    }
  }
}

function TD_MouseOver (elementName, event) {

	var element = getElement(elementName);

	if (element != null) {
		if (event == '0') {
			element.style.background = "#FFFFFF";
		} else {
			element.style.background = "#CCCCFF";
		}
	}
}

function Last_VisitedLink (elementName) {

	var element = getElement(elementName);

	if (element != null) {

		if (lastVisitedLink != null) {
			lastVisitedLink.style.color = lastVisitedLinkColor;
			lastVisitedLinkColor = element.style.color;
			lastVisitedLink = element;
			//lastVisitedLink.style.color = "#87ad9d";
			lastVisitedLink.style.color = "#06AF32";
		} else {

			lastVisitedLink = element;
			lastVisitedLinkColor = lastVisitedLink.style.color;
			lastVisitedLink.style.color = "#06AF32";
		}
	}

}

function Footer_ReTop () {

	getEltById('searchBlock').style.height = 0;
	var contentColumn2 = getEltById('contentColumn2');
	var navColumn = getEltById('navColumn');
	var footer = getEltById('footer');
    var paragraphH = contentColumn2.clientHeight;
	var paragraphTop = (contentColumn2.clientTop) ? contentColumn2.clientTop : contentColumn2.offsetTop;
	var nextH = paragraphTop + paragraphH ;
	
	nextH = (nextH > navColumn.clientHeight) ? nextH : navColumn.clientHeight;
	
	//nextH = nextH - getEltById('searchBlock').style.height;
	getEltById('footer').style.top = (nextH >= 430) ? nextH : 430;
	getEltById('searchBlock').style.height = ((nextH >= 430) ? nextH : 430) - getEltById('searchBlock').offsetTop;
}

function SearchBlock (id) {


	if (id == 1) {
		getEltById('searchBlock').style.backgroundColor = "#ffffff"; 
	} else {
		getEltById('searchBlock').style.backgroundColor = "#e6e6e4"; 
	}

	getEltById('searchBlock').style.height = 0;
	var contentColumn2 = getEltById('contentColumn2');
	var navColumn = getEltById('navColumn');
	var footer = getEltById('footer');
    var paragraphH = contentColumn2.clientHeight;
	var paragraphTop = (contentColumn2.clientTop) ? contentColumn2.clientTop : contentColumn2.offsetTop;
	var nextH = paragraphTop + paragraphH ;
	
	nextH = (nextH > navColumn.clientHeight) ? nextH : navColumn.clientHeight;
	
	getEltById('footer').style.top = (nextH >= 430) ? nextH : 430;
	getEltById('searchBlock').style.height = ((nextH >= 430) ? nextH : 430) - getEltById('searchBlock').offsetTop;

}

//simplified show/hide function

function close_all_menu() {

	for (var i in menuHash) {
	 	var obj = document.getElementById(i);
	 	if (obj) {
			obj.style.display = 'none';
		}
	}

}



function toggle_display(obj_id){

	
	
	var obj = document.getElementById(obj_id);

	if (!obj)
	{
		return false;
	}

	menuHash[obj_id] = 1;


	if (obj.style.display == '' || obj.style.display == 'none'){
		close_all_menu();
		
		var state = 'block';
	
	} else {
		
		var state = 'none';
	
	}
	
	
	obj.style.display = state;

	Footer_ReTop();

	return false;

}

function name_split(str){
	document.write (str);   
}

function d(o)
{
	return document.getElementById(o);
}

function loadimage(_imagepath)
{
	image = d("ContentBanner");
	image.style.display = "none";

	imagepath = _imagepath;

	req = getreq();
	req.onreadystatechange = imagexists;
	req.open("get", imagepath, true);
	req.send(null);		
}

function imagexists()
{
	if(req.readyState == 4)
	{
		if(req.status == 200)
		{
			//warning.innerHTML = "Image exists";
			image.style.display = "block";
			image.src = imagepath;
		}
		else
		{
			//warning.innerHTML = "Image does not exist";
			image.style.display = "block";
		}
	}
}

function getreq()
{
	if(window.XMLHttpRequest)
		return new XMLHttpRequest();
	else if(window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
}

function rand ( min, max )
{
	var myRand = ( Math.floor ( Math.random ( ) * max + 1 ) );
  
	if (myRand < min) {
		return (myRand + min);
	} else {
		return myRand;
	} 
}

//End JS Functions

