/* Created by VM for XL project */
$(document).ready(function() {

$("#home").click(function() {
	$("#home_image").attr("src", "/images/xl/home_white.gif");
	$("#win_image").attr("src", "/images/xl/win_gray.gif");
	$("#participants_image").attr("src", "/images/xl/participants_gray.gif");
	$(".xlSlideshowImages").html("<img src='/images/xl/home_tab.jpg' border='0'usemap='#Map' /><map name='Map'><area shape='rect' coords='73,531,395,552' href='/events' target='_self' alt='discover events throughout the five boroughs'></map><div class='xlcloud'></div>");
	$("div.colABox").css({display: "none"});

	// This overwrites the old tracking pixel source with a new value.
	var prd=new Date(),pru=Date.UTC(prd.getUTCFullYear(),prd.getUTCMonth(),prd.getUTCDay(),prd.getUTCHours(),prd.getUTCMinutes(),prd.getUTCSeconds(),prd.getUTCMilliseconds());
	var pr_eid=pru+Math.random();
	var pr_event='';
	var pr_item='';
	var pr_quantity='';
	var pr_value='';
	$("#tp").attr("src","http://ev.ads.pointroll.com/event/?ss=C7E761C6-BA59-485D-82F7-C9640AD7486D&av=5525&eid="+pr_eid+"&ev="+pr_event+"&item="+pr_item+"&q="+pr_quantity+"&val="+pr_value+"&r="+Math.random());
	$("#tp2").attr("src","http://ev.ads.pointroll.com/event/?ss=13F9D98B-CC8E-4260-BD08-2B0238FCB421&av=5525&eid="+pr_eid+"&ev="+pr_event+"&item="+pr_item+"&q="+pr_quantity+"&val="+pr_value+"&r="+Math.random());
	// Refresh ad units.
	var axel = Math.random() + "";
	var ord = axel * 1000000000000000000;

	jQuery.each($("iframe"), function() {
		$(this).attr({
			src: $(this).attr("src").replace(/(?:ord=)(.*)?/, "ord=" + ord)
		});
		// console.log($(this).attr("src").replace(/(?:ord=)(.*)?/, "ord=" + ord));
	});
	
	// omniture page view	
	s.prop2 = "xl home|pre-launch program description";
	s.t();
	
});

$("#homelink").click(function() {
$("#home_image").attr("src", "/images/xl/home_white.gif");
$("#win_image").attr("src", "/images/xl/win_gray.gif");
$("#participants_image").attr("src", "/images/xl/participants_gray.gif");
$(".xlSlideshowImages").html("<img src='/images/xl/home_tab.jpg' border='0' usemap='#Map' /><map name='Map'><area shape='rect' coords='73,531,395,552' href='/events' target='_self' alt='discover events throughout the five boroughs'></map><div class='xlcloud'></div>");
$("div.colABox").css({display: "none"});
});


$("#participants").click(function() {
$("#participants_image").attr("src", "/images/xl/participants_white.gif");
$("#home_image").attr("src", "/images/xl/home_gray.gif");
$(".xlSlideshowImages").html('<div class="xlHeroMain"><img border="0" src="/images/xl/spend_3x_640x310.jpg"/></div>');
$("div.colABox").css({display: "block"});
});

// XL neighborhoods dropdown
	$("#lxNeighborhoods").hide();
	$("#lxNeighborhoods").css('cursor', 'hand');
	
	$(".xlExploreNeiborhoods").click(function(){
		$("#lxNeighborhoods").toggle();
		return false;
	});
// OFFCLICK function for the neighboroood drop down	
	xloffclick.init();
});	
	var xloffclick = {
	list: [],
	
	// prepare the list of target objects to receive offclick behavior
	init: function() {
		xloffclick.list = [
			{
				root			: '.xlMenuToolbar',
				callback	: function() {
					$('#lxNeighborhoods').hide();
				}
			}
		];
		
		xloffclick.attach();
	},
	// have the onmousedown event bind to the body,
	// which will attempt to close all the targets
	// unless a user clicks on a target itself
	attach: function() {
		var list = xloffclick.list;
		
		$('body').mousedown(function(evt) {
			for(x in list) {
				if($(evt.target).parents().filter(list[x].root).length == 0)
					list[x].callback();
			}
		});
	}
		
};