 $(document).ready(function() {
	      //clear out the default value when the input field gains focus
		  
		   $("#print-page").click(function(e){
				e.preventDefault();
				
				window.print();
			});
		  
	      var input = $('#searchAndLogin input, #newsletter input, input.keywordclear');
		  var prevValue;
		  input.focus(function() {
		    prevValue = this.value;
			this.value = '';
          });
		  //...and replace the default value if the user didn't change it on leaving the field
          input.blur(function() {
		    var curValue = this.value;
			if(curValue == '' || curValue == 'undefined') {
			this.value = prevValue;
			} else {
			    this.value = curValue;
			}
		  });
		  
		  //listen or clicks on the sitemap
		  var visible = false;
		  $('a#sitemapLink').click(function(e) {
		     e.preventDefault();
			 var sitemap = $('#sitemap');
		     if(!visible) {
			     $(this).css('background-position', '55px -17px');
			     sitemap.animate({'height': '220px'});
				 setTimeout("$.scrollTo($('#sitemap'), 1000)",1000);
				 visible = true;
			 } else {
			      $(this).css('background-position', '55px 4px');
			      sitemap.animate({'height': '0px'});
				 $.scrollTo($('#sitemapLink'), 1000);
				 visible = false;
			 }
		  });
		  
		  //Create rollover states on the sectors page panels - for IE6!
		  $('#panels div.panel').mouseover(function() {
			$(this).css('background-color', '#f4f3f1');								  
		  });
		   $('#panels div.panel').mouseout(function() {
			$(this).css('background-color', '#ffffff');								  
		  });
		  
		  //Listen for rollover on the nav items and show corresponding nav menu on rollover
		  $('#navigation ul li a').mouseover(function() {
		      $(this).find('div').show();
		  });
		  $('#navigation ul li a').mouseout(function() {
		      $(this).find('div').hide();
		  });
		  
		  
		  //set the height of the tab container based on the height of the content
		  //this is needed as absolute positioning is used to stack the content panels of the tab area on top of one another
		  var selectedPane = $('#tabs .contentPane.selected');
		  $('#tabs').css('height', ((selectedPane).height() + 66) + 'px' )
		  
		  //Create tab effect on content pages
		  $('#tabs ul li a').click(function(e) {
			  $('#tabs ul li').removeClass('selected');
			  $(this).closest('li').addClass('selected');
		      e.preventDefault();
		      var id = this.id;
			  $('#tabs .contentPane').hide();
			  $('#tabs #panel_'+id).show();
			  var currPanelheight = $('#tabs #panel_'+id).height();
			   $('#tabs ').css('height', (currPanelheight + 66) + 'px' );
		  }); 
		  
		  
		  
		  
		   /*QUICK SEARCH*/
   		$('#ourPeopleNav ul li a').click(function(e) {
			
			var what = $('#what').val();
			if (what == 'surname'){
				 $('#str_Person_surname').val($(this).text() + '*');
				 $('#str_Person_firstname').val('');
			}else{
				 $('#str_Person_firstname').val($(this).text() + '*');
				 $('#str_Person_surname').val('');
				
			}
			 $('#quick_search').submit();
			 e.preventDefault();
		});
		
		  /*QUICK SEARCH*/
   		$('#quickSearch ul li a').click(function(e) {
			
			var what = $('#what').val();
			if (what == 'surname'){
				 $('#str_Person_surname').val($(this).text() + '*');
				 $('#str_Person_firstname').val('');
			}else{
				 $('#str_Person_firstname').val($(this).text() + '*');
				 $('#str_Person_surname').val('');
				
			}
			 $('#quick_search').submit();
			 e.preventDefault();
		});
      
 
		 $('a.qs_firstname').click(function(e) {
			  $('#what').val('firstname');
			  $(this).addClass('selected');
			  $(this).siblings('.qs_surname').removeClass('selected');
			
			  
			  
		  });
       

		$('a.qs_surname').click(function(e) {
					//alert('here');
		  	$('#what').val('surname');
			$(this).addClass('selected');
			$(this).siblings('.qs_firstname').removeClass('selected');		  
		});
		



		$('.datepicker').datePicker({clickInput: "true", startDate:'01/01/1990'});/*, createButton:"false"*/
		
			
	/*	$('.datepicker').datePicker({startDate:'01/01/1990'})
		.bind(
			'focus',
			function()
			{
				$(this).dpDisplay();
			}
		).bind(
			'blur',
			function()
			{
				$(this).dpClose();
			}
		);
*/

		/*offices tool tip function*/
		$(function(){
			$(".tipTip").tipTip({defaultPosition:'top'});
		});


		 })//doc ready end
        function ourPeopleRollovers() {
			var current;
		  $('.person').hover(function() {
									//  alert('hi');
			var id = $(this).attr('id');
			var idd = id.replace('img_','');
			$('#'+idd).show();
			  current = '#'+idd;
			});
			$('.personDetail').mouseout(function() {
				  $(this).hide();
			});
				$('.personDetail a.link').mouseover(function() {
				  $(this).closest('.personDetail').show();
				})
				$('.personDetail ,wrap').mouseover(function() {
				  $(this).closest('.personDetail').show();
				})
        }
 
 
 

 
 
 
 
 
 
 
 
 
//Make the hover states for the nav work in IE6 
 sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


