//------------------------------------------------------------------------------

var IE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1)  && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1);

window.addEvent('domready', function() {
	//-- Set the style to none.  Images should be added via CSS.
	$$('.bvImageReplace').setStyle('display','none');

	//-- provide XHTML valid method for target=_blank for <a>'s
	$$('.bvLinkTargetBlank').each( function(el) {
		el.onclick = function() {
			var newWindow = window.open(this.getAttribute('href'), '_blank');
			newWindow.focus();
			return false;
		};
	}); // bvLinkTargetBlank

	//-- apply smooth scrolling to inner anchor tags
	var mySmoothScroll = new SmoothScroll({ links: '.bvSmoothAnchor' });

	//-- toggle 'Zip Code'/<blank> field value on blur/focus
	$$('.bvZipCodeField').set({
		'events': {
			'focus': function() {
				this.value = (this.value=="Enter ZIP code") ? "" : this.value;
			} // focus
			,
			'blur': function() {
				this.value = (this.value=="") ? "Enter ZIP code" : this.value;
			} // blur
		} // events
	}); // bvZipCodeField

	//-- Handle custom submit for MapPoint dealer locator form
	$$('.bvDealerLocatorForm').each( function(el) {
		el.onsubmit = function() {
			var zipFieldValue = el.getElement('input[type=text]').value;
			if((zipFieldValue=="") || (zipFieldValue=="Enter ZIP code")) {
				window.open('http://go.mappoint.net/harleydavidson/PrxInput.aspx?brand=b','dealer','width=610, height=500, scrollbars=yes, resizable=yes');
			} else {
				window.open('http://go.mappoint.net/harleydavidson/Geocode.aspx?LL=en-us&E=&AD4=USA&CITY=&STATE=&brand=b&ZIP='+zipFieldValue, 'locator', 'width=620, height=500, scrollbars=yes');
			} // if..else
			return false;
		} // onsubmit
	}); // bvDealerLocatorForm

	//-- provide dropdown redirect to different model/same section redirects
	$$('.bvModelSelectRedirect').set({
		'events': {
			'change': function() {
				urlParts = window.location.pathname.split('/');
				urlParts.splice(3, 1);
				urlParts[3] = this.options[this.selectedIndex].value; //-- model is at 5th pos in zero indexed array in URL
				window.location.pathname = urlParts.join("/");
			} // change
		} // events
	}); // bvModelSelectRedirect
}); // domready

//------------------------------------------------------------------------------
