/* Custom Store */
jQuery(document).ready(function()
{
	// Initialize Rollover States
	navigation.rollover.init();
	
	// Fix PNG Issue & Position Geomarker (Static Image)
	jQuery.ifixpng('assets/images/pixel.gif'); 
	jQuery("#banner, #grandOpening").ifixpng();
	jQuery("#geomarker").ifixpng().css({'position':'relative','left':'147px','top':'111px'});
	
	// Initialize Result Tabs
	jQuery('#hours').tabs({ fxFade: true, fxSpeed: 'fast', fxAutoHeight: true });
	
	// Zebra-Strip Store Hours
	jQuery('#hours table').each(function(){
		jQuery(this).find('tr:even').css('background', 'url("assets/images/backgroundStoreHours.gif") repeat-y');
		jQuery(this).find('td:first-child').css('width','72px').end().find('td:last-child').css('width','125px');
	});
	
	jQuery("#storeInformation #head #map div span").click(function(){
		jQuery(this).parent().fadeOut("fast", function(){ jQuery("#geomarker").show(); });
	});
	
	jQuery('.storenewsletter').click(function(){ openInFrame(lightwindows + 'newsletter?store=' + storeID) });
	jQuery('.storeDirections').click(function(){ openInFrame(lightwindows + 'directions?store=' + storeID); });
});


// Navigation Rollover Images
navigation = {};
navigation.rollover = 
{
	init: function()
	{
		this.preload();
		
		jQuery('#storeUpdates #head img').hover(
			function () {jQuery(this).attr('src', navigation.rollover.newimage(jQuery(this).attr('src')));},
			function () {jQuery(this).attr('src', navigation.rollover.oldimage(jQuery(this).attr('src')));}
		);
	},
	
	preload: function()	{ jQuery(window).bind('load', function() { jQuery('#storeUpdates #head img').each(function(key,elm) { jQuery('<img>').attr('src', navigation.rollover.newimage(jQuery(this).attr('src')));}); }); },	
	newimage: function (src) { return src.substring(0, src.search(/(\.[a-z]+)$/)) + '_O' + src.match(/(\.[a-z]+)$/)[0];	},
	oldimage: function(src) { return src.replace(/_O\./, '.'); }
}