﻿var destination='Redline Cambridge, MA 02138';	
function openMapFooter()
{
	 var search=document.getElementById('footer_direction').value;
	 window.open('http://maps.google.com/maps?f=d&source=s_d&saddr='+search+'&daddr='+destination+'&hl=en');
}

function openAboutMap()
{
	 var search=document.getElementById('about_direction').value;
	 window.open('http://maps.google.com/maps?f=d&source=s_d&saddr='+search+'&daddr='+destination+'&hl=en');
}


/*
	Awesome Javascript
	Mike Kivikoski
	


	1. Modal for Personalized Menu
	2. Event backgrounds.
	3. Global nav, currently active link
	4. Click on Home Event Div
	5. Dropdown fade
	6. Add class to last Reviews
	7. Top Slider
	8. Open link in new window
	9. Masonary

*/

	// A.
		/* This function based heavily on Filament Plugin by : Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com) */	
		function equalHeight(element){
			
			$(element).each(function(){
				var tallest = 0;				
				$(this).each(function(i){
					if ($(this).height() > tallest) { tallest = $(this).height(); }
				});
				$(element).css({'min-height': tallest}); 
			})
			return this;
		};	

$(document).ready(function(){


	// 1.
		
	
	//if ( $('#personalized_menu a').length ){
			//$('#personalized_menu a').attr('rel','lightbox');
	//};

	
	equalHeight('.itembg');
	



	// 2.
	// make sure to execute this on page load
	$(function() {
	    // determine if the browser supports transition
	    var thisStyle = document.body.style,
	    supportsTransition = thisStyle.WebkitTransition !== undefined ||
	        thisStyle.MozTransition !== undefined ||
	        thisStyle.OTransition !== undefined ||
	        thisStyle.transition !== undefined;
	
	    // assign jQuery transition if the browser doesn't support
	    if ( ! supportsTransition ) {
	        var defaultCSS = {
	            backgroundColor: '#F3F2F0'
	        },
	        hoverCSS = {
	            backgroundColor: '#e0dfde'
	        };
	
	        // loop through each button
	        $('.itembg_home').each(function() {
	            var $subtle = $(this);
	
	            // bind an event listener for mouseover and focus
	            $subtle.bind('mouseenter focus', function() {
	                $subtle.animate(hoverCSS, 500, 'swing' );
	            });
	
	            // bind the reverse for mouseout and blur
	            $subtle.bind('mouseleave blur', function(ev) {
	                if ( ev.type == 'mouseleave' && ev.target == document.activeElement ) return false;
	
	                $subtle.animate(defaultCSS, 500, 'swing' );
	            });
	        });
	    }
	});





	//alert('common.js');

	// 4.

		
		$('.itembg_home').click(function(){
			//var link = $(this).children($('div.event_desc')).children('a:first-child').attr('href'); //Long long chain. Yuck. 
			var link = $(this).children($('div.event_desc')).children('a').attr('href');
			var pLink = $(this).children($('div.event_desc')).children('p').children('a').attr('href');
			//alert(link);
			window.location = pLink;
		});





	// 5.

	if($('ul#dropmenu li ul').length){
		$('ul#dropmenu li ul').prepend('<li class="shadow menu-item">');
	};	

	
	// 6.
	$('.reviews .news-article:last').addClass('last');
	
	
	
	// 7.
	$('#sliderLink').hover(function(){
		$('#sliderLink').hide();
		$('#slider').slideToggle('fast', function(){

			$('#slider').hover(function(){
					//alert('slider hover');	
				},function(){
					$(this).slideUp('fast',function(){
						$('#sliderLink').show();
				});
			});
		});	
		return false;
	});
	


	// 8.
		$('a.external').click(function(){
			window.open(this.href);
			return false;
		});
		
		

	// 9.
	
		
		$('.menu-container').masonry({
		  singleMode: true,
		  columnWidth: 500, 
		  itemSelector: '.menu-section' 
		});

	

	// 10.
		$('.page-id-12 iframe').attr('allowTransparency','true');







	
}); //End jQuery


/*
	$(window).load(function(){
		alert('masonry');
		    $('.menu-container').masonry({
			  singleMode: true,
			  columnWidth: 500, 
			  itemSelector: '.menu-section' 
			});
	});
*/

