if (document.images){

about = new Image();  about.src = view_path+"images/menu/about.jpg";
donate = new Image();  donate.src = view_path+"images/menu/donate.jpg";
news = new Image();  news.src = view_path+"images/menu/news.jpg";
grantees = new Image();  grantees.src = view_path+"images/menu/grantees.jpg";
contact = new Image();  contact.src = view_path+"images/menu/contact.jpg";

}

function swap(newclass){
	
	identity=document.getElementById('navid');
	
	identity.className=newclass;


}



function clearTabs(set,total){
    for(i=1;i<=total;i++){
        tab = id2elem(set+'_t'+i);

        tab.className = "";
        section = id2elem(set+'_s'+i);
        section.style.display = "none";
    }
}

function filterNonNumeric(field) {
	var result = new String();
	var numbers = "0123456789";
	var chars = field.value.split(""); // create array
	for (i = 0; i < chars.length; i++) {
	if (numbers.indexOf(chars[i]) != -1) result += chars[i];
	}
	if (field.value != result) field.value = result;
}

function displaynameFilter(field) {
	var result = new String();
	var vals = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var chars = field.value.split(""); // create array
	for (i = 0; i < chars.length; i++) {
	if (vals.indexOf(chars[i]) != -1) result += chars[i];
	}
	if (field.value != result) field.value = result;
}

function emailLookup(val) {
	var fldval = $(val).value;
	var pars = 'v='+fldval;
	var URL = '/ola/ajax/emaillookup/';

	if (!fldval == '') {
    	var myAjax = new Ajax.Request(
		URL,
		{
			asynchronous: true,
			method: 'post',
			parameters: pars,
			onLoading: showLookup,
			onSuccess: showEmailSearchResults
		});
	}
}

function showEmailSearchResults (response) {
	var SEARCH_GOOD = 0;
	var SEARCH_FAILED = 1;
    var responseCode = response.responseText;

    //alert(responseCode);
    if (responseCode == SEARCH_GOOD) {
		//alert('Good Displayname');
		$('email-error').style.display = 'block';
		$('email-error').addClassName('formsuccess').update('You Can Use The Email Address Provided!');
    } else {
		//alert('email already in the system');
		$('email-error').style.display = 'block';
		$('email-error').addClassName('formerror').update('The Email Address Provided Has Already Been Registered');
		$('email').focus();
    }
}


function displaynameLookup(val) {
	var fldval = $(val).value;
	var pars = 'v='+fldval;
	var URL = '/ola/ajax/displaynamelookup/';

	if (!fldval == ''){
    	var myAjax = new Ajax.Request(
		URL,
		{
			asynchronous: true,
			method: 'post',
			parameters: pars,
			onLoading: showLookup,
			onSuccess: showNameSearchResults
		});
	}
}

function showLookup () {
	$('loading').style.display = 'block';

}

function showNameSearchResults (response) {
	var SEARCH_GOOD = 0;
	var SEARCH_FAILED = 1;
    var responseCode = response.responseText;

    //alert(responseCode);
    if (responseCode == SEARCH_GOOD) {
		//alert('Good Displayname');
		$('username-error').style.display = 'block';
		$('username-error').addClassName('formsuccess').update('Your Choosen Display Name is Available!');
    } else {
		//alert('Displayname already in the system');
		$('username-error').style.display = 'block';
		$('username-error').addClassName('formerror').update('Your Choosen Display Name is Already Taken');
		$('displayname').focus();
    }
}

function verifyPass () {
	var pwd1 = $('password').value;
	var pwd2 = $('pwd2').value;

	if (pwd1 != pwd2){
		$('password2-error').update('Passwords Do NOT Match!');
		$('password').focus();
	}
}

function videohover(num,dir){
    title = id2elem('title'+num);
    thumb = id2elem('thumb'+num);
    if (dir==1){
       //title.style.display = 'block';
       thumb.style.border = '1px solid #090';
    }else{
       //title.style.display = 'none';
       thumb.style.border = '1px solid #999';
    }
}

function setscrollwidth(holderid, tNum, tWidth, border, margins){
    holder = id2elem(holderid);
    hWidth = ((tNum+1)*tWidth)+(2*border)+(2*margins);
    holder.style.width = hWidth+'px';
}

function tabswitch(set,tNum,total){
    clearTabs(set,total);
    tab = id2elem(set+'_t'+tNum);

    tab.className = 'on';
    section = id2elem(set+'_s'+tNum);
    section.style.display = "block";
}
function roll(sname,rname){
    sname = id2elem(sname);
    sname.src = rname.src;
}
function id2elem(id) {
	if (typeof(id) != 'string') {
		return id;
	}
	if (document.getElementById) {
		id = document.getElementById(id);
	} else if (document.all) {
		id=document.all[id];
	} else {
		id = null;
	}
	return id;
}
function popup(url,width,height){
    nw = window.open(url,"newwindow","width="+width+",height="+height+",status=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,location=0");
    nw.focus();
}





function checkForm(){
if (document.subscribeForm.elements['Email Address'].value.length > 0){
 return true;
 }
else{
 alert('Please enter your email address.');
 document.subscribeForm.elements['Email Address'].focus();
 return false;
 }
}