var oLastBtn=0;

function RaiseButton(){
	
	window.event.cancelBubble=true;
	oBtn = window.event.srcElement;
	if(oLastBtn && oLastBtn != oBtn){
		HideButton();
	}
	if(oBtn.buttonType){
		oBtn.className = oBtn.buttonType + "Up";
		oLastBtn=oBtn;
	}
	else
		oLastBtn = 0;
	
	
}


function DepressButton(){
	window.event.cancelBubble=true;
	oBtn = window.event.srcElement;
	if(oBtn.buttonType){
		oBtn.className = oBtn.buttonType + "Down"; 
	}
}

function btnHideChosen(oFrom){
	if (btnLastClass == null) 
		btnLastClass = "LeftNavChosen";
	btnHide(oFrom);
}

function HideButton(){
	oLastBtn.className = oLastBtn.buttonType + "Off";
}

function MakeBGBlue(oRegion) {
	oRegion.style.backgroundColor="#99CCFF";	
	oRegion.style.cursor="hand";		
}

function MakeBGWhite(oRegion) {
	var oToEl = window.event.toElement;
	if ((oToEl && !oRegion.contains(oToEl))||!oToEl) {
	oRegion.style.backgroundColor="#FFFFFF";	
	}		
}

function ToolbarRed() {
	oSrcEl = window.event.srcElement;
	if (oSrcEl.tagName == "IMG") {
		oSrcEl.src = oSrcEl.src.substring(0,(oSrcEl.src.indexOf(".gif"))) + "-red.gif";
		window.event.cancelBubble = true;
	}
}
function ToolbarWhite() {
	oSrcEl = window.event.srcElement
	if (oSrcEl.tagName == "IMG") {
		oSrcEl.src = oSrcEl.src.substring(0,(oSrcEl.src.indexOf("-red.gif"))) + ".gif";
		window.event.cancelBubble = true;
	}
}

//*****************************************	 
//Global caps function.  Use g_bc in all pages
//to access the browser info
//*****************************************	 
function globalCaps(){
	var A=navigator.userAgent, t=true, p="", v="";
	p=A.indexOf("MSIE");
	if (p!=-1){
    	this.ie=true;
		v=A.charAt(p+5);
		(v=="2")?this.ie2=true:this.ie2=false;
		(v=="3")?this.ie3=true:this.ie3=false;
		(v=="4")?this.ie4=true:this.ie4=false;
		(v=="5")?this.ie5=true:this.ie5=false;
	} else {
		this.ie=false;
		this.ie2=false;
		this.ie3=false;
		this.ie4=false;
		this.ie5=false;	
	}
	(this.ie4||this.ie5)?this.IE4RelOrNewer=true:this.IE4RelOrNewer=false;
	(A.indexOf("Mozilla") != -1 && A.indexOf("compatible")==-1)?this.nav=true:this.nav=false;
	(A.indexOf("Windows 95")>0||A.indexOf("Win95")!=-1||A.indexOf("Win98")!=-1||A.indexOf("Windows 98")!=-1||A.indexOf("Windows NT")!=-1)?this.win32=true:this.win32=false;
	(A.indexOf("Windows 3.1")!=-1||A.indexOf("Win16")!=-1)?this.win16=true:this.win16=false;
	(A.indexOf("Mac")!=-1)?this.anymac=true:this.anymac=false;
	(A.indexOf("SunOS")!=-1||A.indexOf("HP-UX")!=-1||A.indexOf("X11")!=-1)?this.unix=true:this.unix=false;
	(A.indexOf("Windows CE")!=-1)?this.wince=true:this.wince=false;
}

//*****************************************
//Global browser info object
//*****************************************
var gbc=new globalCaps();



//*****************************************	 
//Functions to support left nav menu
//*****************************************	 

var btnLastClass = null;
var btnLastFontColor = null;

function btnUp(oFrom){
	
	if (document.readyState != "complete") return;
	//movement between A and DIV
	if (window.event.fromElement == null || window.event.toElement == null) return;

	if ((!oFrom.children(0).className) && ((oFrom.children(0).className == "LeftNavOff")  && (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)))) {
		window.event.cancelBubble=true;
		btnLastClass = oFrom.children(0).className;
		btnLastFontColor = oFrom.children(0).children(0).style.color;
		oFrom.children(0).className = "LeftNavUp";	
		oFrom.children(0).children(0).style.color = "white";
	}
	if (gbc.ie4) {	
		if (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)) return;
	}
	window.event.cancelBubble=true;
	btnLastClass = oFrom.children(0).className;
	btnLastFontColor = oFrom.children(0).children(0).style.color;
	oFrom.children(0).className = "LeftNavUp";	
	oFrom.children(0).children(0).style.color = "white";
}

function btnHide(oFrom){
	if (document.readyState != "complete") return;
	//moving out of the button space
	if (window.event.toElement == null || window.event.toElement.tagName == "BODY" || window.event.toElement.tagName == "IMG" || window.event.toElement.tagName == "TD") {
		//alert ("Class: " + btnLastClass + " Color: " + btnLastFontColor);
		window.event.cancelBubble=true;
		if (btnLastClass == null) btnLastClass = "LeftNavOff";
		oFrom.children(0).className = btnLastClass;
		oFrom.children(0).children(0).style.color = btnLastFontColor;
		return;
	}

	//movement between A and DIV
	if (gbc.ie4) {
		if (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)) return;
	}
	//moving between buttons
	window.event.cancelBubble=true;
	if (btnLastClass == null) btnLastClass = "LeftNavOff";
	oFrom.children(0).className = btnLastClass;
	oFrom.children(0).children(0).style.color = btnLastFontColor;
}

function btnDown(oFrom){
	if (document.readyState != "complete") return;
	window.event.cancelBubble=true;
	oFrom.children(0).className = "LeftNavDown";
}
//*****************************************	 
//End functions to support left nav menu
//*****************************************	 



//*****************************************	 
//Form Validation Functions
//*****************************************	 


// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";

/****************************************************************/

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

/****************************************************************/

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

/****************************************************************/

// Checks to see if a required field is blank.  If it is, a warning
// message is displayed...

function ForceEntry(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isWhitespace(strField)) {
		alert("You need to enter information for " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}

/****************************************************************/

// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{
    if (isEmpty(s)) return true;
  
    // is s whitespace?
    if (isWhitespace(s)) return true;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return true;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return true;
    else return false;
}
		
/****************************************************************/
function ForceEMail(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isEmail(strField)) {
		alert("You need to enter a proper " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}

/****************************************************************/

// PURPOSE:  Check to see if the string passed in is a valid time.
//	A valid time is defined as a string which is postfixed with either
//  "PM" or "AM".  Next it checks to see if there is a colon in the
//  string.  If there is, it makes sure that at least one digit preceeds
//  it and two proceed it.

	function IsTime(strTime)
	{
		var strTestTime = new String(strTime);
		strTestTime.toUpperCase();

		var bolTime = false;

		if (isWhitespace(strTestTime)) return true;

		if (strTestTime.indexOf(":",0) == 0)
			return true;

		var nColonPlace = strTestTime.indexOf(":",1);
		if (((parseInt(nColonPlace) + 3) < (strTestTime.length - 1) || (parseInt(nColonPlace) + 2) > (strTestTime.length - 1)))
			return true;


		return false;
	}

/****************************************************************/

function ForceTime(objField, FieldName)
{
	var strField = new String(objField.value);
	if (IsTime(strField)) {
		alert("You need to enter a proper " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}

/****************************************************************/

// Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message

function IsNumber(s)
{
	var strField = new String(s);
	
	if (isWhitespace(strField)) return true;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			return true;
		}

	return false;
}

/****************************************************************/
function ForceNumber(objField, FieldName)
{
	var strField = new String(objField.value);
	if (IsNumber(strField)) {
		alert("You need to enter a proper " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}


/****************************************************************/

/* PURPOSE:  Returns true if the string is a valid date number.
	A method is passed in (1 = month, 2 = day).  If the string is
	nonnumeric, false is passed back.  If the day in the date string
	is greater than 31, false is returned.  If the month is greater
	than 12, an error is returned.
*/

function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 2)
		if (parseInt(str) > 31)
			return false;
	if (method == 1)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}


/****************************************************************/

/* PURPOSE: Checks to see if the string is a valid date.  A valid
	date is defined as any of the following:

		MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
		MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
*/

function isDate(strDate)
{
	var str = new String(strDate);

	if (isWhitespace(str)) {
		return true;
	}

	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
		return true;
	}

	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		return true;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
		return true;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
		return true;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
		return true;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
		return true;
	}

	return false;
}

/****************************************************************/
function ForceDate(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isDate(strField)) {
		alert("You need to enter a proper " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}


/****************************************************************/


//*****************************************	 
//End Form Validation Functions
//*****************************************	 



/****************************************************************/

function popup(mylink, windowname, w, h)
{
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	winstring='width='+w+',height='+h+',scrollbars=yes';
	window.open(href, windowname, winstring);
}


function ViewPics(PicName) { 
	page="catpics.asp?Pic=" + PicName;
	newWin=window.open(page, '', 'titlebar=0,scrollbars=0,width=200,height=250,top=100,left=100');
	newWin.focus();
} 


    function addCookie(tag, value) {
       var expireDate = new Date();
       var expireString = "";
       expireDate.setTime(expireDate.getTime() + (1000 * 60 * 60 * 24 * 365));
       expireString = "expires=" + expireDate.toGMTString();
       document.cookie = tag + "=" + escape(value) + ";" + expireString + ";";
    }

    function getCookie(tag) {
       var value = null;
       var myCookie = document.cookie + ";";
       var findTag = tag + "=";
       var endPos;
    
       if (myCookie.length > 0) {
          var beginPos = myCookie.indexOf(findTag);
          if (beginPos != -1) {
             beginPos += findTag.length;
             endPos = myCookie.indexOf(";", beginPos);
             if (endPos == -1) 
                endPos = myCookie.length;
             value = unescape(myCookie.substring(beginPos, endPos));
          }
       }
       return value;
    }

	function SpecialMsg() {
		checkShow = getCookie("ohcanadaeh");
		if (checkShow != "true") {
			checkit = confirm("The 1st Niagara Scout Group is hosting an OH Canada Eh Dinner Show\n\nGet your tickets for the show now.\n\nClick OK to view details.\n","");
			if (checkit) {
				popup('ohcanadaeh.htm', 'ohcanadaeh', 400, 550);
				addCookie("ohcanadaeh","true");
			}
		}
	}

