nav_home_on = new Image();
nav_home_off = new Image();
nav_blog_on = new Image();
nav_blog_off = new Image()
nav_store_on = new Image();
nav_store_off = new Image();
nav_featured_on = new Image();
nav_featured_off = new Image();
nav_charities_on = new Image();
nav_charities_off = new Image();

nav_home_on.src = "images/nav_home_on.gif";
nav_home_off.src = "images/nav_home_off.gif";

nav_blog_on.src = "images/nav_blog_on.gif";
nav_blog_off.src = "images/nav_blog_off.gif";
 
nav_store_on.src = "images/nav_store_on.gif";
nav_store_off.src = "images/nav_store_off.gif";

nav_featured_on.src = "images/nav_featured_on.gif";
nav_featured_off.src = "images/nav_featured_off.gif";
 
nav_charities_on.src = "images/nav_charities_on.gif";
nav_charities_off.src = "images/nav_charities_off.gif";

function nav_on ( imgId )
{

  if ( document.images )
  {
    butOn = eval ( imgId + "_on.src" );
    document.getElementById(imgId).src = butOn;
  }
}
 
function nav_off ( imgId )
{
  if ( document.images )
  {
    butOff = eval ( imgId + "_off.src" );
    document.getElementById(imgId).src = butOff;
  }
}



/* FORM VALIDATION */

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_form(thisform)
{
	
with (thisform)
  {
  if (validate_required(name,"Please fill in your name")==false)
  {name.focus();return false;}
  if (validate_email(email,"Please fill in a valid email address such as myname@mysite.com")==false)
  {email.focus();return false;}
  if (validate_required(message,"Please fill in your message")==false)
  {message.focus();return false;}
  }
}

// -------------------------------------------

var lastDiv = "";
function showDiv(divName,hideDivName) {
	// hide any div with the name 'cms-visible-div' in case of editing an item
	// hide last div
	if (lastDiv) {
		document.getElementById(lastDiv).className = "cms-hidden-div";
	}
	//if value of the box is not nothing and an object with that name exists, then change the class
	if (divName && document.getElementById(divName)) {
		if ( hideDivName ) {
			document.getElementById(hideDivName).className = "cms-hidden-div";
		}
		document.getElementById(divName).className = "cms-visible-div";
		lastDiv = divName;
	}
}

// -------------------------------------------

