window.addEvent("domready", function(){
	
	new SmoothScroll({"links": $$(".scroll")});

	$$(".volatile").each(function(el){
		$(el).addEvent("focus", function(){
			if(this.getValue() == this.getProperty("title")) {
				this.value = "";
			}
		});
	});
	
	$$("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();
				}
			});
			
		}
	});
	
	// Homepage - Non Flash
	if($("hero")){
		
		var flashDiv = new Element('div', {
			'id': 'homeSlideshow'
		});
		
		flashDiv.injectInside('hero');
		
		$('showSectors').remove();
		$('placeholder').remove();
		
		$('podCol').setStyle('padding-top', '503px');
	}
	
	// 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("http://www.topdrawer.co.uk/_images/flash/registerNow.swf", "registerNowFlash", "128", "128", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("registerNow");
	}
	
	if($("countDown")){
		var flash = new FlashObject("http://www.topdrawer.co.uk/_images/flash/event_countdown.swf", "countdownFlash", "170", "72", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("countDown");
	}
	
	if($("homeSlideshow")){
		var flash = new FlashObject("http://www.topdrawer.co.uk/_images/flash/image-rotator-loader.swf", "homeSlideshowFlash", "550", "484", "9", "#ffffff");
		flash.addParam("menu","false");
		flash.addParam("quality","high");
		flash.addParam("WMODE","transparent");
		flash.write("homeSlideshow");
	}
	
				
});
