/***********************************************************************************************************************
NOTE: Because of a bug in jQuery with IE8 we had to add an IE stylesheet hack to get the system to work in all browsers. I hate hacks but had no choice :(.
************************************************************************************************************************/
$(document).ready(function() {
						   
	 
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.blogButton').click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.blogButton').removeClass('blogButtonSelected');
		
		
		if($(this).prev().is(':visible') == true) {		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$(this).prev().slideUp('normal');
		}
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).prev().is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('blogButtonSelected');
			$(this).removeClass('blogOver');
			$(this).children('.blogOpen').hide();
			$(this).children('.blogClose').show();
			//OPEN THE SLIDE
			$(this).prev().slideDown('normal');
					
		 } else {
			
			$(this).children('.blogClose').hide();
			$(this).children('.blogOpen').show();
					
		 } 
		  
	 });
	  
	
	/*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	//ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 

	
	$('.blogButton').mouseover(function() {
		if($(this).prev().is(':hidden') == true) {									 
	$(this).addClass('blogOver');
		} 
	//ON MOUSEOUT REMOVE THE OVER CLASS
	}).mouseout(function() {
		$(this).removeClass('blogOver');										
	});

	/*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	
	/********************************************************************************************************************
	CLOSES ALL S ON PAGE LOAD
	********************************************************************************************************************/	
	$('.newsContent').hide();
	$('.blogContent').hide();
	$('.blogClose').hide();


$(window).bind("load", function() {

	function goToByScroll(id){  
       $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');  
 } 
	
		function getUrlVars() {   
       var vars = [], hash;   
       var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');   
       for (var i = 0; i < hashes.length; i++) {   
           hash = hashes[i].split('=');   
           vars.push(hash[0]);   
           vars[hash[0]] = hash[1];   
       }   
       return vars;   
   } 



var tab = getUrlVars()["blogid"];     

if(tab) {
	$('#blog'+tab).trigger('click');
	$('#blogOld').trigger('click');
	goToByScroll('post'+tab); 
} 
	
	
});

});

