/*
 * MealsTogethercom Common Javascript
 *
 * August 10, 2009
 *
 */

// init the $meals namespace. All functions should be part of this namespace
var $meals = window.$meals || {};  

//
// createLink(): Given a jQuery selector and a URL, add an onclick event that 
// lets you click on a div to go to a new page 
//
$meals.createLink = function(cssSelector, url) {
	$(cssSelector).click(function() { 
		if ($(this).hasClass('external')) {
			window.open( url );
        	return false;
		} else {
			location.href=url;
		}
	});
}

$(document).ready( function() {

	
	$('a[rel="external"]').click( function() {
	     window.open( $(this).attr('href') );
	    return false;
	});	
        
    // insert a tooltip span that tells you that you're leaving the site
    // class='warning' can be applied to anything other than a link
    // class='warningLink' should only be applied to <a> tags, as it is needed to keep IE6 happy
 	$('.warning, a.warningLink').append("<span>You are now exiting this web site.  The Clorox Company is not responsible for the content or data collection of the website you are about to go to.</span>");
  	$('.warning span').addClass('externalTooltip');	// only add externalTooltip class to the 'warning' objects (not the 'warningLink' objects)
    												// because IE6 has a hissy fit if the span inside the warningLink object has a class

});
