/* 
-----------------------------------------------------------------
Theme Init
-----------------------------------------------------------------
*/



// ----------------------------
// Main Menu Initialisation
// ----------------------------
/*function animatemenu(){

	// Create an associative array of Elements / tab numbers
	// JS doesn't really do associative arrays - but can access values as if an object...
	var animation_config = [];
	animation_config["tab1"] = "page-home";
	animation_config["tab2"] = "page-about_us";
	animation_config["tab3"] = "page-our_services";
	animation_config["tab4"] = "page-our_systems";
	animation_config["tab5"] = "page-media_centre";
	animation_config["tab6"] = "page-news_and_events";
	animation_config["tab7"] = "page-jobs";
	animation_config["tab8"] = "page-contact_us";

	var body = null;
	var tab = null;

	for(i in animation_config) {
	   var k = animation_config[i];
	   if (document.getElementById(k)) {
	       body = k;
	       tab = i;
	       break;
	   }
	}

	if (body !== null) {
		//$("#menu ul ul li").animate({left:"-150px"},0);    
		//$("#menu ul ul").slideUp(0);
		$("#menu ul ul").css("display","none");
		console.log("#"+ body + " #menu #"+tab+" ul li");
		$("#"+ body + " #menu #"+tab+" ul").slideDown(400,function(){
			// IE hack to prevent elements disappearing
			$("#menu ul ul").css("zoom","1");
		});
	}
}



// Capture menu clicks
if (Drupal.jsEnabled) {
	$(document).ready(function() {
		// all top level anchors trigger slide up
		$("#menu ul li a").click(function(event){
			$("#menu ul ul").slideUp(400);
		});
		// submenu anchors do not
		$("#menu ul li.leaf a").unclick();

	});
}
*/


// ----------------------------
// Search Box
// ----------------------------
function setsearch(){
	(function ($) {
		//$("#imagesubmit").css("width","1px").animate({opacity:"0"});
		$("#edit-processed-keys").css("background","transparent").css("width","120px");
		$("#imagesubmit").css("background","transparent");
	})(jQuery);
}



// ----------------------------
// Capture news heading clicks
// ----------------------------
(function ($) {
	$(document).ready(function() {

		// hide all news content
		//$('ul.news-events-listing div.views-field').hide();

		// all news item headings toggle slide
		$("ul.news-events-listing h3").live ( 'click', function(){

			// toggle next views-field
			$(this).nextAll('div.views-field').slideToggle();

			// toggle chevron
			if ( $(this).children('span').length > 0 ) {
				// remove chevron
				$(this).children().remove("span");
				$(this).css("color","#83A1C4");
			} else {
				// prepend chevron
				$(this).prepend("<span class='chevron'>> </span>");
				$(this).css("color","#0F4B91");
			}

		});

		// hide all jobs content
		//$('ul.jobs_listing div.item_body').hide();

		// set inactive colour
		$("ul.jobs_listing h3").css("color","#b27270");

		// all news item headings toggle slide
		$("ul.jobs_listing h3").click(function(){

			// toggle next item_body
			$(this).nextAll('div.item_body').slideToggle();

			// toggle chevron
			if ( $(this).children('span').length > 0 ) {
				// remove chevron
				$(this).children().remove("span");
				$(this).css("color","#b27270");
			} else {
				// prepend chevron
				$(this).prepend("<span class='chevron'>> </span>");
				$(this).css("color","#8a181b");
			}

		});

	});

})(jQuery);
