var HillBilly = {
	
	initialize: function(tickercontents){
	
		this.tickercontents = tickercontents;

		this.tickdelay = 5000; //delay btw messages
		this.highlightspeed = 5; //10 pixels at a time.

		////Do not edit past this line////////////////

		this.currentmessage = 0;
		this.clipwidth = 0;
		
		this.start_ticking();
	
	},
	
	loadData: function(){
	
	},
	
	changetickercontent: function(){
		this.crosstick.innerHTML = this.tickercontents[this.currentmessage];
		this.crosstick.style.clip="rect(0px 0px auto 0px)";
		this.highlightmsg();
	},
	
	highlightmsg: function(){
		var msgwidth=this.crosstick.offsetWidth;
		if (this.clipwidth < 774) {
			this.clipwidth += this.highlightspeed;
			this.crosstick.style.clip="rect(0px "+this.clipwidth+"px auto 0px)";
			this.beginclip = setTimeout("HillBilly.highlightmsg()",20);
		}
		else {
			this.clipwidth=0;
			clearTimeout(this.beginclip);
			if (this.currentmessage == this.tickercontents.length-1) {
				this.currentmessage=0;
			}
			else {
				this.currentmessage++;
			}
			setTimeout("HillBilly.changetickercontent()",this.tickdelay);
		}
	},
	
	start_ticking: function(){
		this.crosstick = document.getElementById? document.getElementById("highlighter") : document.all.highlighter;
		this.crosstickParent = this.crosstick.parentNode? this.crosstick.parentNode : this.crosstick.parentElement;
		if (parseInt(this.crosstick.offsetHeight) > 0) {
			//this.crosstickParent.style.height = this.crosstick.offsetHeight+'px';
			this.crosstickParent.style.height = '15px';
		}
		else {
			setTimeout("HillBilly.crosstickParent.style.height = HillBilly.crosstick.offsetHeight+'px'",100); //delay for Mozilla's sake
		}
		this.changetickercontent();
	}

}

//window.addEvent("domready", function(){

	//var links = $$("a");
	new SmoothScroll();
	new Lightbox();

	$$(".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");
	});
	


	if($("customLink")) {
		var customLink = new Fx.Slide("customContent",{ "duration":1200, "transition": Fx.Transitions.Bounce.easeOut });
		customLink.hide();
		$("customLink").addEvent("click", function(e){
			new Event(e).stop();
			customLink.toggle();
		});
	}


	new Accordion($$(".formopen"), $$(".addressforms li"), { "alwaysHide":true, "show":-1 });


	new Tips($$(".tooltip"), {
		"initialize": function(){
			this.fx = new Fx.Style(this.toolTip, "opacity", {"wait": false});
		},
		"onHide": function(){
			this.fx.start(0);
		},
		"onShow": function(){
			this.fx.start(1);
		},
		"offsets":{
			"x":-20,
			"y":-130
		}
	});


	new Accordion($$(".faqlist li h2"), $$(".faqlist li div"), { "alwaysHide":true, "show":-1 });


	if($("lookup")){
		$("lookup").addEvent("click", function(e){
			new Event(e).stop();
			
			var formName = $("RegistrationForm") ? "RegistrationForm" : "myform";
			var postCode = $E("input[name=PostCode]",formName).getValue();
			var houseNumber = $E("input[name=Line1]",formName).getValue();
			
			new Ajax("/postcode/postcode.asp?form=" + formName + "&housenumber=" + houseNumber + "&PCode=" + postCode + "&nocache=" + Date.parse(new Date()),{
				"method":"get", 
				"onComplete": function(response){
					var jsonObj = Json.evaluate(response);
					if(jsonObj.status){
						//if($E("input[name=Line1]",$(jsonObj.form))){
						//	$E("input[name=Line1]",$(jsonObj.form)).value = jsonObj.address1;
						//} else {
							$E("input[name=Line2]",$(jsonObj.form)).value = jsonObj.address1;
						//}
							
						$E("input[name=Town]",$(jsonObj.form)).value = jsonObj.town;
						$E("input[name=County]",$(jsonObj.form)).value = jsonObj.county;
					}
				}
			}).request();
		});
	}

	if ($('highlighter')) {
		var tickercontents = new Array();
		
		$$('.tickeritem').each(function(el) {
			tickercontents[parseInt(el.id.substring(el.id.indexOf("_") + 1))] = document.getElementById(el.id).innerHTML;
		});
		
		HillBilly.initialize(tickercontents);
	}
	


		var fo2 = new FlashObject("/_images/general/logo2.swf", "viewer", "186", "45", "9", "#ffffff");
		fo2.addParam("menu","false");
		fo2.addParam("quality","high");
		fo2.write("logo");



//});

window.addEvent("load", function(){



});



