//function initFlash() {
	//var so = new SWFObject("/assets/flash/home.swf","mymovie","544","410","#ff0000");
	//so.addParam("wmode","opaque");
//	so.addParam("FlashVars","urlLink=/michelintruck/services/AdvantageProgram.jsp");
	//so.write("flash_movie");                      
//}

var dealerForm = new function() {
	this.init = function() {
		var errBubble = document.getElementById("dealer_bubble");
		errBubble.style.display="none";
	}
	
	this.hideBubble = function() {
		var errBubble = document.getElementById("dealer_bubble");
		errBubble.style.display="none";
		errBubble.innerHTML = "";
	}
	
	
	this.submit = function() {
		//nclick="document.forms[0].submit()"
		//make sure none of the selects in the form are set to index 0
		var dealerInput = document.getElementById("zip_code");
		var errBubble = document.getElementById("dealer_bubble");
		
		//reset the error
		errBubble.innerHTML = "";
		
		var match = /^(\d{5}([\-]\d{4})?|[a-zA-Z][0-9][a-zA-Z]\s?[0-9][a-zA-Z][0-9])$/;
		//var matchPostal = [A-Z][0-9][A-Z]\s[0-9][A-Z][0-9]/;

		if(match.test(dealerInput.value)) {
//			dealerLocator.launch(dealerInput.value);
		  window.open("http://locator.michelintruck.com/Default.aspx?address=" + dealerInput.value,'locatorwindow');
			return false;
		} else {
			dealerInput.onclick = dealerForm.hideBubble;
			var errList = document.createElement("ul");
			var errItem = document.createElement("li");
			errItem.innerHTML = dealerInput.title;
			errList.appendChild(errItem);
			errBubble.appendChild(errList);
			Effect.Appear(errBubble, {duration:0.5});
			return false;
		}
		
	}
}

var badgeLink = function() {

	var linkIds = ["badge1","badge2","badge3"];

	function attachLinks() {
		Event.addEvent(linkIds,"click",simulateClick, this);
		Event.addEvent(linkIds,"mouseover",function(){this.style.cursor="pointer";});
		Event.addEvent(linkIds,"mouseout",function(){this.style.cursor="default";});
	}
	
	function simulateClick(e,obj) {
		var linkTag = this.getElementsByTagName("a");
		window.location = linkTag[0].getAttribute("href");
	}
	
	return {
		init: function() {
			attachLinks();
		}
	};
}();

function Confirmnav(link) {
  if (confirm("This link leaves the Michelin site.  Do you want to continue?")) {
    document.location.href = link;
  }
}

function callLocator(myid) {
  var inputbox = document.getElementById(myid);
  if (inputbox)
    window.open('http://locator.michelintruck.com//default.aspx?address=' + inputbox.value,'locatorwindow');  
}

//function initBannerFlash() {
  //var so = new SWFObject("/assets/flash/richMediaBanner1MillTires.swf", "myoverlay", "795", "795", "#ff0000");
  //so.addParam("wmode", "transparent");
  //var version = 0;
 // if (navigator.appName.indexOf("Internet Explorer") != -1) {
    //var temp = navigator.appVersion.split("MSIE");
    //version = parseFloat(temp[1]);
 // }
  //if (version == 6) {
    //so.addParam("FlashVars", "ie6=true");
  //}
  //else {
    //so.addParam("FlashVars", "ie6=false");
  //}
  //so.write("FlashOverlay");
//}

function hideDiv(elementID) {
  if (document.getElementById && document.getElementById(elementID)) {
    document.getElementById(elementID).style.visibility = 'hidden';
    document.getElementById(elementID).style.display = 'none';
  }
  var version = 0;
  if(navigator.appName.indexOf("Internet Explorer") != -1) {
    var temp = navigator.appVersion.split("MSIE");
    version = parseFloat(temp[1]);
  }
  if (version == 6) {
    HideIFrameCanvas("position-wrapper");
  }
}


Event.addEvent(window,"load",dealerForm.init);
//Event.addEvent(window,"load",initFlash);
//Event.addEvent(window, "load", initBannerFlash);
Event.addEvent(window, "load", badgeLink.init);

