window.addEvent("domready", function(){
	
	new SmoothScroll({"links": $$(".scroll")});

	$$(".volatile").each(function(el){
		$(el).addEvent("focus", function(){
			if(this.getValue() == this.getProperty("title")) {
				this.value = "";
			}
		});
	});
	
	$$(".pageHighlights a, .bookStand").each(function(el){
		new ListItemSelector($(el),{ "fxMin": 1, "fxMax": 0.6 });
	});

	$$("a[rel*='external']").each(function(a){ 
		$(a).setProperty("target", "_blank");
	});
	
	$$("ul.showImages").each(function(el){ new Ticker(el, {"interval": 3500}) }); 
	
	$$(".faqlist li").each(function(el){
		var toggler = el.getElement(".expand");
		if(toggler){
			var slide = new Fx.Slide(el.getElement("div"),{"duration":350, "wait": false}).hide();
			toggler.addEvent("click", function(e){
				new Event(e).stop();
				if(this.hasClass("expand")){
					this.removeClass("expand").addClass("collapse");
					slide.slideIn();
				} else {
					this.removeClass("collapse").addClass("expand");
					slide.slideOut();
				}
			});
			
		}
	});
	
	// Initiate Dropdown
	$$("#nav li").each(function(el){
								
		el.addEvent("mouseover", function() {
			el.addClass("sfhover");
		});
	
		el.addEvent("mouseout", function() {
			el.removeClass("sfhover");
		});
	
	});
	
	// Create a new multibox and assign it to the mini basket object
	multibox = new MultiBox('multibox', {
		showControls:false,
		useOverlay:true,
		overlayColor: "#EEF1F0"
	});
	
	// Catch the close links for multibox popups
	$$(".multiboxClose").each(function(el){
		el.addEvent("click", function(e){
			new Event(e).stop();
			window.parent.miniBasket.multibox.close();
		});
	});		
	
	if($("registerNow")){
		var flash = new FlashObject("/_images/flash/registerNow.swf", "registerNowFlash", "150", "150", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("registerNow");
	}
	
	if($("countDown")){
		var flash = new FlashObject("/_images/flash/event_countdown.swf", "countdownFlash", "229", "78", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("countDown");
	}
	
	if($("homeSlideshow")){
		var flash = new FlashObject("/_images/flash/homeSlideshow.swf", "homeSlideshowFlash", "535", "381", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("homeSlideshow");
    }

    // Font replacement

	Cufon.replace('.subNav .topLevel', { fontFamily: 'Trade Gothic LT Std', hover: true });
    Cufon.now() 
	
	$("CloseEventFinished").addEvent("click", function(e){
		new Event(e).stop();
		var fadeout = new Fx.Style('EventFinished', 'opacity', {duration:1000});
		fadeout.start(1, 0);
	}); 

});
