/*
 * Common javascript functions for store locator
 * Currently shared between ProBuild.com and SLAT
 */

setupSLViewDetails = function(entryNum) {
	if (entryNum != null) {
		var storeLocatorDetailsLink = document
				.getElementById("locationResultsForm:resultTable:" + entryNum
						+ ":hiddenMoreDetailsLink");
		if (storeLocatorDetailsLink != null) {
			if (jQuery.browser.mozilla) {
				var evt = document.createEvent("MouseEvents");
				evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
						false, false, false, false, 0, null);
				storeLocatorDetailsLink.dispatchEvent(evt);
			} else if (jQuery.browser.msie) {
				storeLocatorDetailsLink.click();
			} else {
				// Default approach for all other browsers
				storeLocatorDetailsLink.click();
			}
		}
	}
	jQuery('.storeLocResultPrint').css("display", "none");
};

storeLocReady = function() {
	jQuery('.storeLocResult tr').click( function() {
		jQuery('.selected').removeClass('selected');
		jQuery(this).addClass('selected');
	})
};

enableSlideshow = function() {
	//alert ('enabling slideShow');
	jQuery('#storeSlides').cycle({
		fit: 1,
		timeout: 1000,
		delay: 1500
	});
	jQuery('#storeSlides').css("visibility", "visible");
	return true;
};

commonSetActiveLocationFromPin = function(itr) {
	jQuery('.selected').removeClass('selected');
	var loopItr = 0;
	var thisItr = itr;
	jQuery(".storeLocResult > tbody").children(".dr-table-firstrow").each(
			function(){
				if (thisItr == loopItr) {
					jQuery(this).addClass('selected');
				}
				loopItr++;
			}
	);
};

setActiveLocation0 = function() {
	commonSetActiveLocationFromPin(0);
};

setActiveLocation1 = function() {
	commonSetActiveLocationFromPin(1);
};

setActiveLocation2 = function() {
	commonSetActiveLocationFromPin(2);
};

setActiveLocation3 = function() {
	commonSetActiveLocationFromPin(3);
};

setActiveLocation4 = function() {
	commonSetActiveLocationFromPin(4);
};

setActiveLocation5 = function() {
	commonSetActiveLocationFromPin(5);
};

setActiveLocation6 = function() {
	commonSetActiveLocationFromPin(6);
};

setActiveLocation7 = function() {
	commonSetActiveLocationFromPin(7);
};

setActiveLocation8 = function() {
	commonSetActiveLocationFromPin(8);
};

setActiveLocation9 = function() {
	commonSetActiveLocationFromPin(9);
};
