
//if Javascript is present load script specific styles

if(document.getElementById){
	
	var styleLink = document.getElementById('scriptSpecific');
	styleLink.href = "/styles/script-specific.css";
	
}


$(document).ready( function() { 																	//When the document is ready

//Open external links in new windows
		
		var external = $('a[rel="external"]');														//Get all links with rel="external" and place them into the 'external'
		
		external.attr("title", external.attr("title") + " - Link opens in a new window..");			//Take the links current title and append it with the external link message
			
		external.click( function() {																//When an external link is clicked
			
		window.open( $(this).attr('href') );														//Open its href in a new window
        
		return false;																				//Cancel the links default behaviour
		
		})																							//End function
		
		
		
		
//Colour form fields on form submission, visual aid when submitting forms via AJAX

	
	/*	$('form').submit( function() {																//When a form is submitted
			
		var formFields = $(this).find(':input[class!="submit"]');									//Put the forms input and textarea elements into 'formFields' with the submit button (has class="submit")
		
		var increment = 155;																		//The amount of blue to be used initially
		
		function fadeIt(){																			//Declare a function called fadeIt
		
		formFields.css({backgroundColor: "rgb(255,255,"+ (increment+=4) +")"});						//Take the selected inputs and increase the blue by four degrees 
		
		if(increment < 255){																		//If the increment is less than white	
			
			setTimeout(fadeIt, 40);																	//repeat after 40 milliseconds
			
			}
		
		}
		
		fadeIt();																					//Call the initial function
		
		return true;																				//Cancel the forms default behaviour (replace with AJAX)
		
		});																							//End function

*/
//FAQs section ------------------------------

	$(".faq .faqSection p").hide();
	
	$(".faq .faqSection h2").click( function(){
		
		if($($(this).siblings("p")).is(":hidden")){
		
		$(this).addClass("active");
		$(this).siblings("p").slideDown('fast');
		
		} else {
			
		$(this).removeClass("active");
		$(this).siblings("p").slideUp('fast');
		
		}
		
	})
	
//Training Events section ------------------------------

	$("ul.courseType li ul").hide();
	$("ul.courseType li h2 a").addClass("jsActive");
	
	$("ul.courseType li h2 a").click( function(){
		
		if($($(this).parents().siblings("ul")).is(":hidden")){
		
		$(this).addClass("active");
		$(this).parents().siblings("ul").not("#formats").slideDown('fast');
		
		
		} else {
			
		$(this).removeClass("active");
		$(this).parents().siblings("ul").not("#formats").not("#features").not("#links").slideUp('fast');
		
		}
		return false;
	})

//Menu hover options

$('#primaryNav li').hover( function(){

	$(this).children('ul:not(".show")').width('123px');
	$(this).children('ul:not(".show")').show();
				
	}, function(){
		
	$(this).children('ul:not(".show")').hide();
					
})

$('#primaryNav li ul li a').hover( function(){

	$(this).parents('li').parents('ul').siblings('a').addClass('expanded');
				
	}, function(){
		
	$(this).parents('li').parents('ul').siblings('a').removeClass('expanded');
					
})

//if Javascript is available put in the hover expantion arrow

	$('#primaryNav li ul').parents('li').addClass("expandable");


//Remove defualt open subnav state if javascript is available	

	$('#primaryNav li ul').removeClass("show");	
  			
}); 																								//End document.ready