// JavaScript Document

var addHTMLonLoad = function(){	
  $(".all").addClass('js');
  $(".nav.site li.item").prepend('<div class="ns i1"></div><div class="ns i2"></div><div class="ns i3"></div><div class="ns i4"></div>');
  $('.nav.site ul.subList').hide();
  
  
  if($.browser.mozilla) //corners doesn't work in chrome or safari and there is no browser sniff for those broswers
  {		$(".nav.site ul.subList li.i7 a").corners('5px bottom');
		/*$('.nav#eLearning2 .cs.i1 p a.health',
		  '.nav#eLearning2 .cs.i1 p a.education',
		  '.nav#eLearning2 .cs.i1 p a.foodRetail',
		  '.nav#eLearning2 .cs.i1 p a.foodDrinks',
		  '.nav#eLearning2 .cs.i1 p a.catering',
		  '.nav#eLearning2 .cs.i1 p a.building',
		  '.nav#eLearning2 .cs.i1 p a.construction').corners('5px');*/
  		$('.industry #eLearning2 .cs.i1 a.visit').corners('5px');
		$('.industry #eLearning2 .cs.i1').corners('5px');
		$('.industry #steps1 li').corners('5px top');
		$('.industry #s2ss3').corners('5px left');
		$('.industry #s2ss3 .copy').corners('5px');
		$('.industry #s2ss4').corners('5px right');
		$('.clearfix').corners('5px');
		$('#s2ss1').corners('5px left');
		$('.home #s2ss2sss1').corners('5px'); 
		//$('.industry #s2ss1sss1').corners('5px');  

		$('.elearning #steps1 li').corners('5px top');
		$('.elearning #s2ss3').corners('5px');
		$('.elearning #s2ss3 .copy').corners('5px');
		$('.elearning #s2ss4').corners('5px right');
		$('.elearning #s2ss1sss1').corners('5px'); 
  } 
  
  if(location.hash=="#js_incidents1")
  {	$('#incidents1').show();
  	$('#avoiding1,#resources1').hide();
	$('#steps1 li').removeClass('selected');
	$('#steps1 li.incidents').addClass('selected');
  }
  else if(location.hash=="#js_avoiding1")
  {	$('#avoiding1').show();
  	$('#incidents1,#resources1').hide();
	$('#steps1 li').removeClass('selected');
	$('#steps1 li.avoiding').addClass('selected');
  }
  else if(location.hash=="#js_resources1")
  {	$('#resources1').show();
  	$('#avoiding1,#incidents1').hide();
	$('#steps1 li').removeClass('selected');
	$('#steps1 li.resources').addClass('selected');
  }
  else
  {	$('#incidents1').show();
  	$('#avoiding1,#resources1').hide();
	$('#steps1 li').removeClass('selected');
	$('#steps1 li.incidents').addClass('selected');
  }
}
$(document).ready(function(){
  addHTMLonLoad(); 
  
  $("#site1 > ul > li").hover(
	function(){
			$(this).addClass('hover');
	},
	function(){
			$(this).removeClass('hover');
	}
  );
  $("#site1 li.i2").click(
	function(){ 
		var ul = $(this).find('ul.subList');
		if(ul.is(':hidden'))
		{	ul.slideDown('fast');
		}
		else
		{	ul.slideUp('fast');
		}
			
	}
);
  $("#site1 li.item ul.subList").mouseleave(
		function(){
			$(this).slideUp('fast');
		}										 
	);
 
  $('#steps1 li').hover(
		function()
		{	$(this).filter(':not(.selected)').addClass('hover');
		},
		function()
		{	$(this).removeClass('hover');
		}
	)

  $('#steps1 ul.subList li').hover(
		function()
		{	$(this).filter(':not(.selected)').addClass('hover');
		},
		function()
		{	$(this).removeClass('hover');
		}
	)

 $('#steps1 li.incidents').click(
		function()
		{	$(this).addClass('selected');
			$(this).siblings().removeClass('selected');
			$('#avoiding1,#resources1').hide();
			$('#incidents1').fadeIn('slow');
			location.hash = "#js_incidents1";
			return false;
		}
	);
  $('#incidents1 a.next').click(
		function()
		{	$('#avoidingTab').addClass('selected');
			$('#avoidingTab').siblings().removeClass('selected');
			$('#incidents1,#resources1').hide();
			$('#avoiding1').fadeIn('slow');
			location.hash = "#js_avoiding1";
			return false;
		}
	);
  $('#steps1 li.avoiding').click(
		function()
		{	$(this).addClass('selected');
			$(this).siblings().removeClass('selected');
			$('#incidents1,#resources1').hide();
			$('#avoiding1').fadeIn('slow');
			location.hash = "#js_avoiding1";
			return false;
		}
	);   
  $('#avoiding1 a.next').click(
		function()
		{	$('#resourcesTab').addClass('selected');
			$('#resourcesTab').siblings().removeClass('selected');
			$('#avoiding1,#incidents1').hide();
			$('#resources1').fadeIn('slow');
			location.hash = "#js_resources1";
			return false;
		}
	);
  $('#steps1 li.resources').click(
		function()
		{	$(this).addClass('selected');
			$(this).siblings().removeClass('selected');
			$('#avoiding1,#incidents1').hide();
			$('#resources1').fadeIn('slow');
			location.hash = "#js_resources1";
			return false;
		}
	);
   $('.previous1 li.incidents a, .next1 li.incidents a').click(
		function()
		{	$('#steps1 li').removeClass('selected');
			$('#steps1 li.incidents').addClass('selected');
			$('#avoiding1,#resources1').hide();
			$('#incidents1').fadeIn('slow');
			location.hash = "#js_incidents1";
			return false;
		}
	);
   $('.previous1 li.avoiding a, .next1 li.avoiding a').click(
		function()
		{	$('#steps1 li').removeClass('selected');
			$('#steps1 li.avoiding').addClass('selected');
			$('#incidents1,#resources1').hide();
			$('#avoiding1').fadeIn('slow');
			location.hash = "#js_avoiding1";
			return false;
		}
	);
   $('.previous1 li.resources a, .next1 li.resources a').click(
		function()
		{	$('#steps1 li').removeClass('selected');
			$('#steps1 li.resources').addClass('selected');
			$('#avoiding1,#incidents1').hide();
			$('#resources1').fadeIn('slow');
			location.hash = "#js_resources1";			
			return false;
		}
	);
});
