$(document).ready(function () {
/*
	$('#type-store,label[for=type-store] img').click(function() {
		$('#type-store').attr('checked','checked');
		$('#store-visit-info').slideDown(500);
		$('#comment-fields').slideDown(500);
	});
	$('#type-corp,label[for=type-corp] img').click(function() {
		$('#type-corp').attr('checked','checked');
		$('#storeno').val('');
		$('#coop').val('');
		$('#store-visit-info').slideUp(500);
		$('#comment-fields').slideDown(500);
	});
	// show or hide fields based on input
	if ($('#storeno').val() == '' && !$('#type-store').attr('checked')) {
		$('#store-visit-info').hide();
		$('#comment-fields').hide();
	}
	if ($('#type-corp').attr('checked')) {
		$('#comment-fields').show();
	}
*/
	// detect gmaps compatible browser
	if (GBrowserIsCompatible()) {
		// show selected store
		if ($('#storeno').val()) {
			jmmap.setup('map'); // (div)
			jmmap.showSingleStore($('#storeno').val())
			$('#store-picker #zip').hide();
			$('#store-picker label[for=zip]').hide();
		} else {
			//create map using div id = map
			$('#store-picker #zip').keyup(function() {
				if (this.value.length == 5) {
					$(this).blur();
					if (!jmmap.map) {
						jmmap.setup('map'); // (div)
					}
					jmmap.showStoresInZip(this.value,false); // zip code, pickClosest
				}
			});
		}
		// add charcounter
		charcounter.setup($('#thoughts'),2048);
		// set unload
		window.onunload = GUnload;
	}
});
