soundManager.url = '/wp-content/themes/ontrack/swf/';
soundManager.flashVersion = 8; // optional: shiny features (default = 8)
soundManager.useFlashBlock = false; // optionally, enable when you're ready to dive in
// enable HTML5 audio support, if you're feeling adventurous. iPad/iPhone will always get this.
// soundManager.useHTML5Audio = true;
var trainsound;
var gotoUrl = "/";
var showDropdownLoginBox = function(e) {
	jQuery("#dropdownLoginBox").slideToggle();
	jQuery("#username").focus();
	e.preventDefault();
}
var positionDropdownLoginBox = function() {
	var loginPosition = jQuery("#menu-item-34").offset();
	jQuery("#dropdownLoginBox").css("top",loginPosition.top + jQuery("#menu-item-34").height() + "px");
	jQuery("#dropdownLoginBox").css("left",loginPosition.left + "px");
	if(loginPosition.left + jQuery("#dropdownLoginBox").width() > jQuery("body").width()) {
		jQuery("#dropdownLoginBox").css("left",(loginPosition.left + (jQuery("#menu-item-34").width() - jQuery("#dropdownLoginBox").width())) + "px");		
	}
}
jQuery(document).ready(function($) {
	jQuery(".sf-menu").supersubs({
		minWidth: 20, 
		maxWidth: 30,
		extraWidth: 1
	}).superfish({
		autoArrows: false
	});//.find("ul").bgIframe({opacity:false});
	jQuery("#menu-item-34 a").click(showDropdownLoginBox);
	positionDropdownLoginBox();
	jQuery(window).resize(positionDropdownLoginBox);
	soundManager.onready(function() {
		trainsound = soundManager.createSound({
			id: 'mySound',
			url: '/wp-content/themes/ontrack/Train_Honk_Horn_2x.mp3',
			autoLoad: true,
			autoPlay: false,
			volume: 50,
			onfinish: function() {
				if (typeof("ishomepage") !== "undefined"){
					window.location = gotoUrl;			
				}
			}
		});
		jQuery("#Logo").click(function(e) {
			gotoUrl = jQuery(this).attr("href");
			trainsound.play();
			e.preventDefault();
		});
	});
});

