// JavaScript Document
$(document).ready(function(){	
	
	jQuery("#eNewsForm").validate();
	
	jQuery("#commentForm").validate();
    
    jQuery("#pform").validate();
	
	//if selected class applied then remove it first
    if($('#navigation ul li a'))
    {
        $('#navigation ul li a').removeClass('selected');   
    }
	
	//find the active page and add selected class to its link
	$('#navigation ul li a').filter(function(){
		var pathname = window.location.pathname;
		var patharray = pathname.split('/');
		var pagename = patharray.slice(-1);
		var elem = $(this).attr("href") == pagename;
		
		return elem;
	}).addClass('selected');
	
	if($("#navigation ul li a").hasClass("selected") == false) {
      $("#navigation ul li a:first").addClass("selected");
    }
	
	$('#right_col .hider:not(:first)').hide();
	$('#content_area .hider:not(:first)').hide();
	//$('.enJs').hide();
	
  		$("#right_col h2").click(function(){
  		$("#right_col .hider:visible").hide('slow');
	
		$(this).next().show('slow');
		});
	
		$("#content_area h2").click(function(){
  		$("#content_area .hider:visible").slideToggle(400);
	
		$(this).next().slideToggle(400);
		});
				
	//top navigation dropdown
	$('#top_navigation_belowHeader .hider').hide();
	  
  		$("#top_navigation_belowHeader h2").click(function(){
  		$("#top_navigation_belowHeader .hider:visible").hide('slow');
	
		$(this).next().show('slow');
		
		$(this).next('.hider').hover(function() {
		}, function(){	
			$(this).parent().find("ul.hider").hide('slow'); //When the mouse hovers out of the hider, move it back up
		});
	});
    
    $('#navigation').height(Math.max.apply(Math, $('#navigation, #content_area').map(function() {
      return $(this).height();
    }).get()));
	
	$(".answer").hide();
	
	$(".faq").click(function(){
		$(this).next().show(200);
	});
});

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=650,height=600,scrollbars=yes');
return false;
}

