﻿/* NB: for WordPress, must change "$" to "jQuery" */
/* Change opactiy for social media icons */
jQuery(function(){
	jQuery('#social img').animate({
		"opacity" : .8
	});
	jQuery('#social img').hover(function(){
		jQuery(this).stop().animate({
			"opacity" : 1
		});
	}, function() {
		jQuery(this).stop().animate({
			"opacity" : .8
		});
	});
});
/* Change opacity for other images with class of faded */
jQuery(function(){
	jQuery('img.faded').animate({
		"opacity" : .5
	});
	jQuery('img.faded').hover(function(){
		jQuery(this).stop().animate({
			"opacity" : 1
		});
	}, function() {
		jQuery(this).stop().animate({
			"opacity" : .5
		});
	});
});
/*Search box focus*/
jQuery(document).ready(function(){
	var searchBoxtext = jQuery(".text");
	var searchBox = jQuery("#searchbox");
	var searchBoxDefault = "Search...";
	searchBoxtext.focus(function(e){
		jQuery(this).addClass("active");
	});
	searchBoxtext.blur(function(e){
		jQuery(this).removeClass("active");
	});
	searchBox.focus(function(){
		if(jQuery(this).attr("value") == searchBoxDefault) jQuery(this).attr("value", "");
	});
	searchBox.blur(function(){
		if(jQuery(this).attr("value") == "") jQuery(this).attr("value", searchBoxDefault);
	});
});
/* Expanding submenus used in contact forms - ABL adaptation of Simple JQuery menu - Copyright 2008 by Marco van Hylckama Vlieg web: http://www.i-marco.nl/weblog/ email: marco@i-marco.nl */
function initMenus() {
	jQuery('ul.menu ul').hide();
	jQuery.each(jQuery('ul.menu'), function(){
		jQuery('#' + this.id + '.expandfirst ul.expanded').show();
	});
	jQuery('ul.menu li a').click(
		function() {
			var checkElement = jQuery(this).next();
			var parent = this.parentNode.parentNode.id;

			if(jQuery('#' + parent).hasClass('noaccordion')) {
				jQuery(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if(jQuery('#' + parent).hasClass('collapsible')) {
					jQuery('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				jQuery('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
jQuery(document).ready(function() {initMenus();});
