   
// hide/reveal toggle //

$(document).ready(function()
{
  //hide the all of the element with class msg_body
  $(".msg_body").hide();
  //toggle the componenet with class msg_body
  $(".msg_head").click(function()
  {
    $(this).next(".msg_body").slideToggle(300);
	$(this).toggleClass("active");
	$(this).siblings("h3").removeClass("active");
		
  });
  
  //mouseover on map//
  $('.map').maphilight();
  
  //higlight form elements//
  $("li.highlights").hover(function () {
      $(this).css({ backgroundColor:"#f4d6b4" });
    }, function () {
      var cssObj = {
        backgroundColor: "transparent",
        fontWeight: "",
        color: "#000"
      }
      $(this).css(cssObj);
    });
	
	//wrap span to create left hand nav rounded corners//
	$(".wrap").after("<span class='topRight'><\/span><span class='bottomLeft'><\/span><span class='bottomRight'><\/span><span class='bottomLeft'><\/span>");
	
	// Email a friend //
	$('.emailPrint li').after('<li><a class="styleswitch email print" href="#print">Printer friendly version</a></li>');
	
	// Stle witcher //
	$('.styleswitch').click(function() {
		$('.screenStyle').remove();	
		$('#print2').after('<link type="text/css" href="http://webarchive.nationalarchives.gov.uk/+/http://www.civilservice.gov.uk/css/print.css"  rel="stylesheet" media="screen" id="print1" />');
	});	
	$('.returnLink').click(function() {
		window.location.reload();
	});			
	$('.printLink').click(function() {
		window.print();
		return false;
	});	
	
	// Mythbuster popup//
	$('.question').after('<ul class="options"><li class="true"><a href="#" title="">True?</a></li><li class="false"><a href="#" title="">False<span>?</span></a></li></ul>')
	$('.answer').hide().removeClass('static').addClass('dynamic');
	$('.answer.dynamic h3').hide();
	$('.options a').click(function(){
		select($('.false'));
		$('.answer.dynamic').show();
		return false;
	});	
	$('.answer.dynamic').click(function(){
		$(this).hide();
		$('.false').removeClass('selected');
	});
	
	function select(option) {
		if ($('.answer.dynamic:visible')) {
			$(option).addClass('selected');
		}
	};
	
});

//creates pop up calendar//
jQuery(function($){
				$("#dateinput").datepicker();
				})


function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=450,height=500,scrollbars=yes');
return false;
}
function popupLarge(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=500,scrollbars=yes');
return false;
}
  
  // strip alternate table cells in tables
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eaeaea";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

	    // avoid rows that have a class attribute
        // or backgroundColor style
	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
 
         // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
        
		      mytd.style.backgroundColor = even ? evenColor : oddColor;
              
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
// -->

