jQuery(function(){
//navigation
/*
jQuery("#nav ul li").hover(
function () {
jQuery(this).stop().animate({
opacity: 0
}, 300 );
},
function () {
jQuery(this).stop().animate({
opacity: 1
}, 300 );
}
);
*/
jQuery("#nav ul li").hover(
function () {
jQuery(this).children('ul').css('display', 'block');
},
function () {
jQuery(this).children('ul').css('display', 'none');
}
);
//accordion
if (jQuery('ul#accordion').length > 0) {
jQuery('ul#accordion > li').append('+');
jQuery('ul#accordion > li').css('cursor', 'pointer');
jQuery('ul#accordion > li > ul').slideUp(0);
var bodyClass = jQuery('body').attr('class');
var teachers = /teachers/;
var about = /about/;
var careers = /about/;
var news = /news/;
var video = /video/;
jQuery('ul#accordion > li').attr('state', 'closed');
if (about.test(bodyClass)) {
jQuery('ul#accordion > li:first-child > ul').slideDown(0, function(){
jQuery('ul#accordion > li:first-child').attr('state', 'open');
jQuery('ul#accordion > li:first-child > span').replaceWith('-');
});
} else if (teachers.test(bodyClass)) {
jQuery('ul#accordion > li:nth-child(2) > ul').slideDown(0, function(){
jQuery('ul#accordion > li:nth-child(2)').attr('state', 'open');
jQuery('ul#accordion > li:nth-child(2) > span').replaceWith('-');
});
} else if (news.test(bodyClass) || video.test(bodyClass)) {
jQuery('ul#accordion > li:nth-child(3) > ul').slideDown(0, function(){
jQuery('ul#accordion > li:nth-child(3)').attr('state', 'open');
jQuery('ul#accordion > li:nth-child(3) > span').replaceWith('-');
});
} else if (careers.test(bodyClass)) {
jQuery('ul#accordion > li:nth-child(4) > ul').slideDown(0, function(){
jQuery('ul#accordion > li:nth-child(4)').attr('state', 'open');
jQuery('ul#accordion > li:nth-child(4) > span').replaceWith('-');
});
}
/*
jQuery('ul#accordion > li:first-child > ul').slideDown(0, function(){
jQuery('ul#accordion > li:first-child').attr('state', 'open');
jQuery('ul#accordion > li:first-child > span').replaceWith('-');
});
*/
jQuery('ul#accordion > li').click(function(){
if (jQuery(this).attr('state') == 'open'){
jQuery(this).children('ul').slideUp(500, function(){
//var tester3 = jQuery(this).next();
//console.log(tester3);
jQuery(this).parent().attr('state', 'closed');
//var tester4 = jQuery(this).next();
//console.log(tester4);
jQuery(this).next().replaceWith('+');
if (jQuery('ul#accordion > li:last-child').attr('state') == 'closed') {
jQuery('ul#accordion > li:last-child').children('h3').css('border-bottom', 'none');
}
});
} else {
jQuery('ul#accordion > li[state="open"]').children('ul').slideUp(500, function(){
jQuery(this).next().replaceWith('+');
jQuery(this).parent('li').attr('state', 'closed');
if (jQuery(this).prev().attr('class') == 'last') {
jQuery('ul#accordion > li:last-child').children('h3').css('border-bottom', 'none');
}
});
if(jQuery(this).children('h3').attr('class') == 'last') {
jQuery(this).children('h3').css('border-bottom', '1px solid #ccc');
}
jQuery(this).children('ul').slideDown(500, function(){
jQuery(this).parent().attr('state', 'open');
jQuery(this).next().replaceWith('-');
});
}
});
}
//homepage featured video effect
if(document.getElementById('homeFeatureContent') != null && document.getElementById('rotatorA') == null) {
var fImg = document.getElementById('homeFeatureContent').getElementsByTagName('img');
jQuery(fImg).css('cursor', 'pointer');
var vLoc = document.getElementById('vidLoc').innerHTML;
var fVid = '';
jQuery(fImg).click(function(){
jQuery(this).fadeOut(500, function(){
jQuery('#homeFeatureContent').prepend(fVid);
});
});
}
//apply an active class to active links
var anchorUrl = window.location.href.split('.com/')[1];
jQuery('#accordion a[href*="' + anchorUrl + '"]').addClass('nav_active').css('color', '#333');
//remove 'donate' text from contribute button
if (document.getElementById('processbutton') != null) {
var submitButton = document.getElementById('processbutton');
submitButton.setAttribute('value', '');
}
//remove 'submit form' text from submit button
if (document.getElementById('submit') != null) {
var submitFormButton = document.getElementById('submit').firstChild;
submitFormButton.setAttribute('value', '');
}
});