function clockDrivenPromotionImages(ourLayout) {

	var replacers = [
					 
		/* 
		{	
			layout:, Exact name of the layout where the replacement is to occur.
			index:, The index of the tile you wish to replace. Lowest number is 1.
			image:, URL of image you want to replace existing tile with
			code:,  Use to inject code instead of just an image, such as when you want to replace the existing tile and include linking.
			thumb:, URL of thumb that corresponds to replacement tile
			startDate:, Date replacement should occur
			endDate: Date replacement should no longer occur
		}, 
		
		{
			layout:"HomePage_BuickGMC1",
			index:1,
            image:"http://assets.qa-2.cobaltgroup.com/teams/repository/bf8/b3f80de2610048fb800146edef087/3/hero_layout1_sierra.jpg",
            startDate:"7/25/2010",
			endDate:"7/25/2010"
		},
		
		{	
			layout:"HomePage_Cadillac_Exclusive1",
			index:1,
            code:'<a title="Quick Quote Form" href="QuickQuoteForm?cs:a:i=cad_hero_image"><img alt="SRX" src="http://assets.qa-2.cobaltgroup.com/teams/repository/730/ec6c0e25b10048c2f080020e74f33/1/srx.jpg" /></a><a class="ctaButton ctaButton1 sprite" href="QuickQuoteForm?cs:a:i=cad_hero_image"></a><a class="ctaButton ctaButton2 sprite" href="NewVehicleSearch?cs:a:i=cad_hero_image"></a>',
            thumb:"http://assets.qa-2.cobaltgroup.com/teams/repository/756/fa5d8e25b10048c2f080020e74f33/1/srx.jpg",
			startDate:"7/25/2010",
			endDate:"7/25/2010"
		},
		
		{
			layout:"HomePage_BuickGMC1",
			index:1,
            image:"http://assets.qa-2.cobaltgroup.com/teams/repository/bf8/b3f80de2610048fb800146edef087/3/hero_layout1_sierra.jpg",
            startDate:"8/16/1901",
			endDate:"8/17/1901"
		},
		{	
			layout:"HomePage_Cadillac_Exclusive1",
			index:1,
            code:'<a href="AboutSpecials?promo=Cadillac_Premium_Care_Maintenance&cs:a:i=cad_hero_care_maint"><img src="http://assets.cobaltnitra.com/teams/repository/export/5d6/48658eb3310048b0a00146edef087/5d648658eb3310048b0a00146edef087.jpg" alt="Cadillac Premium Care Maintenance" title="Cadillac Premium Care Maintenance" /></a>',
            thumb:"http://assets.cobaltnitra.com/teams/repository/export/7ca/02d10eb3310048b0a00146edef087/7ca02d10eb3310048b0a00146edef087.jpg",
			startDate:"9/8/1901",
			endDate:"9/8/1901"
		},
		{	
			layout:"HomePage_Cadillac_Exclusive2",
			index:1,
            code:'<a href="AboutSpecials?promo=Cadillac_Premium_Care_Maintenance&cs:a:i=cad_hero_care_maint"><img src="http://assets.cobaltnitra.com/teams/repository/export/5e9/388a8eb3310048b0a00146edef087/5e9388a8eb3310048b0a00146edef087.jpg" alt="Cadillac Premium Care Maintenance" title="Cadillac Premium Care Maintenance" /></a>',
			startDate:"9/8/1901",
			endDate:"9/8/1901"
		},
		*/
		{	
			layout:"HomePage_Chevy_Exclusive1",
			index:1,
			image:"http://assets.cobaltnitra.com/teams/repository/export/576/faf78ec661004856600146efa6b30/576faf78ec661004856600146efa6b30.jpg",
			thumb:"http://assets.cobaltnitra.com/teams/repository/export/57b/b1828ec661004856600146efa6b30/57bb1828ec661004856600146efa6b30.jpg",
			startDate:"3/1/2011",
			endDate:""
		},
		{	
			layout:"HomePage_Chevy_Exclusive2",
			index:1,
			image:"http://assets.cobaltnitra.com/teams/repository/export/be1/cc748ec741004856600146efa6b30/be1cc748ec741004856600146efa6b30.jpg",
			startDate:"3/1/2011",
			endDate:""
		}
					 
	];
		
	if (replacers.length>0) {
		var replacement, dealerDefault, dealerIndex=-1, slides, dateToday = new Date(); dateToday.setHours(0,0,0,0);
		
		/* Keep dealerDeafault for Chevy layouts up-to-date or a timer driven tile may override dealer content */
		
		if (ourLayout=="HomePage_Chevy_Exclusive1") {
			dealerDefault = "http://assets.cobaltnitra.com/teams/repository/export/c77/aa230ef9c1004855610145efa6b30/c77aa230ef9c1004855610145efa6b30.jpg"; 		
			dealerIndex = 6;
		} else if (ourLayout=="HomePage_Chevy_Exclusive2") {
			dealerDefault = "http://assets.cobaltnitra.com/teams/repository/export/c93/38948ef9c1004855610145efa6b30/c9338948ef9c1004855610145efa6b30.jpg";
			dealerIndex = 6;
		} 
		
		
		
		if (ourLayout=="HomePage_BuickGMC1") {slides = jQuery("ul.jcarousel-skin-gmhero").children();}
		if (ourLayout=="HomePage_Cadillac_Exclusive1") {slides = jQuery(".slide"); var thumbs = jQuery(".jcarousel-clip .jcarousel-list .jcarousel-item");}
		if (ourLayout=="HomePage_Cadillac_Exclusive2") {slides = jQuery(".slide");}
		
				
		
		for (i=0; i<replacers.length; i++) {
			replacement=replacers[i];	
			if (replacement.layout != ourLayout) {continue;}
			if (isEmpty(replacement.startDate)) {replacement.startDate=dateToday;} else {replacement.startDate=new Date(replacement.startDate);}
			if (isEmpty(replacement.endDate)) {replacement.endDate=dateToday;} else {replacement.endDate=new Date(replacement.endDate);}
			
			if ((dateToday < replacement.startDate ) || (dateToday > replacement.endDate )) {
				continue;
			}

			
			if ((replacement.layout == "HomePage_Cadillac_Exclusive1") || (replacement.layout == "HomePage_Cadillac_Exclusive2") || (replacement.layout == "HomePage_BuickGMC1")) {
				if (!replacement.code) {
					jQuery(slides[replacement.index-1]).html('<img src="'+replacement.image+'" />');
				} else {
					jQuery(slides[replacement.index-1]).html(replacement.code);
				}
				if (replacement.thumb) {	
					jQuery(thumbs[replacement.index-1]).html('<img src="'+replacement.thumb+'" width="140 height="90" />');
				}
			} else if ((replacement.layout == "HomePage_Chevy_Exclusive1") || (replacement.layout == "HomePage_Chevy_Exclusive2")) {
				if (replacement.index==dealerIndex) {
					if (jQuery("#dealerHero").html().indexOf(dealerDefault)!=-1) {
   						jQuery("#dealerHero").html('<img src="'+replacement.image+'" border="0" />');
					}
				} else {
					jQuery("#masterHero"+replacement.index).html('<img src="'+replacement.image+'" border="0" />');
					if (replacement.thumb) {
						jQuery("#masterHeroThumb"+replacement.index).html('<img src="'+replacement.thumb+'" border="0" />');
					}
				}
			}
		}
	}
	
	function isEmpty(candidate) {
		if ((candidate==undefined) || (candidate=="") || (candidate==null) || (candidate==undefined)) {
			return (true);
		}
		return (false);
	}		

	
}


jQuery(function(){ 
	var ourLayout = ContextManager.getPageLayout();
	if (ContextManager.getVersion()!="WIP") {
		if ((ourLayout == "HomePage_BuickGMC1") || (ourLayout == "HomePage_Cadillac_Exclusive1") || (ourLayout == "HomePage_Cadillac_Exclusive2") || (ourLayout == "HomePage_Chevy_Exclusive1") || (ourLayout == "HomePage_Chevy_Exclusive2")) {
		clockDrivenPromotionImages(ourLayout);
		}
	}
	if ((ourLayout == "HomePage_BuickGMC1") || (ourLayout == "HomePage_Buick_Endorsed")) {
		jQuery("#gm-hero-carousel").css("visibility","visible");
	}

});
