// JavaScript Document

// add active class to active page link javascript
$(document).ready(function(){
	var str=location.href.toLowerCase();
	$('#directory a').each(function() {
		if (str.indexOf(this.href.toLowerCase()) > -1) {
	    	$(this).addClass("active");
	    }
	});
 })

// lightbox javascript
$(document).ready(function() {
	$(".viewMap").fancybox({
		'overlayColor' : '#333'
	});
	$(".viewSitemap, .viewPrivacy").fancybox({
		'overlayColor' : '#333',
		'type'	: 'iframe',
		'autoScale' : true,
		'height' : '50%'
	});
	$(".newsStory").fancybox({
		'overlayColor' : '#333',
		'type'	: 'iframe',
		'autoScale' : true,
		'width' : '75%',
		'height' : '75%'
	});
	$(".viewLogin").fancybox({
		'overlayColor' : '#333',
		'type'	: 'iframe',
		'autoScale' : true,
		'width' : 300,
		'height' : 260
	});
});

// same height javascript
$(function(){
  var tallest = 0;
  var $columnsToEqualize = $(".columnEqual");
  	$columnsToEqualize.each(function() {
    	var thisHeight = $(this).height();
    	if (thisHeight > tallest) {
      		tallest = thisHeight;
    }
  	});
  	$columnsToEqualize.height(tallest);
});

// rounded corner javascript
$(function(){
	$('#google_translate_element').corner("round bottom 8px")
	$('.footerInside').corner("15px top");
});
	
// menu javascript
$(function(){
	$('ul.sf-menu').superfish({      // the delay in milliseconds that the mouse can remain outside a submenu without it closing
    	delay: 200,
    	speed: 0,
    	autoArrows: true,
    	dropShadows: false,
    	disableHI: true			
	}); 
});

window.onload = function() {
	var menuID = 'menu'; // The ID of your menu
	var activeClass = 'current'; // The class to add
	
	var menu = document.getElementById(menuID);
    var items = menu.getElementsByTagName('a');
        for( var i = 0; i < items.length; i++ ) {
            if( items[i].href.replace(/https?:\/\/.*?\//i , '/') ==
                location.href.replace(/https?:\/\/.*?\//i , '/') ) {
                items[i].parentNode.className = activeClass;
                break;
            }
        }
	$(".current").parents().filter("li").addClass('current');
	$('<span class="last"></span>').appendTo(".sf-menu li:last");  
}; 
