function addEvent(el, ev, func){
	el.attachEvent(ev,'on' + func) || el.addEventListener(ev,func,false);
	return true;
}

function autoscroll(el_id){
	this.el = document.getElementById(el_id);
	var text = this.el.innerHTML;
	
	this.inner = document.createElement('div');
	this.inner.innerHTML = text;
	this.el.scroll = true;
	
	this.el.innerHTML = '';
	this.el.appendChild(this.inner);
	this.el.inner = this.inner;
	
	// css
	with(this.el.style){
		position='relative';
		overflow='hidden';
	}
	
	with(this.inner.style){
		position='absolute';
		top='0px';
	}
	
	this.inner.y = 0;
	this.el.scrollAmount = 1;
	
	this.el.onmouseover=function(){
		this.scroll = false;
	}
	
	this.el.onmouseout=function(){
		this.scroll = true;
	}
	
	setTimeout("autoscroll_animate('" + el_id + "')",2000);
}

function autoscroll_animate(el_id){
	var as = document.getElementById(el_id);
	
	as.inner.y += as.scrollAmount * as.scroll;
	if(as.inner.y >= as.inner.offsetHeight){
		as.inner.y = 0 - as.offsetHeight;
		as.scrollAmount = 4;
	}
	
	if(as.scrollAmount==4 && as.inner.y > 0){
		autoscroll_reset(el_id);
	}
	
	as.inner.style.top = 0-as.inner.y + 'px';
	
	setTimeout("autoscroll_animate('" + el_id + "')",30);
	
}

function autoscroll_slow(el_id){
	var as = document.getElementById(el_id);
	as.scrollAmount = 1;
}

function autoscroll_reset(el_id){
	var as = document.getElementById(el_id);
	as.scrollAmount = 0;
	setTimeout("autoscroll_slow('" + el_id + "')",2000);
}

function changeColor_on(arg0){
	var el = document.getElementById(arg0);
	el.style.backgroundColor="#FFFFDD";
}

function changeColor_out(arg0){
	var el = document.getElementById(arg0);
	el.style.backgroundColor="transparent";
}

function optionButton(name,id,val){
	text = '<input type="radio" name="' + name + '" id="' + id + '" value="' + val + '" class="optionButton" /><label id="' + id + '_label" for="' + id + '" class="optionButton">' + val + '</label>';
	document.write(text);
	
	this.input = document.getElementById(id);
	this.input.label = document.getElementById(id + '_label');
	
	this.input.onclick=function(){
		var el = this.parentNode.getElementsByTagName('input');
		for(i=0;i<el.length;i+=1){
			if(el[i].type=="radio" && el[i].name==this.name){
				//options are in the same group
				el[i].label.className = 'optionButton';
			}
		}
		this.label.className = 'optionButton checked';
	}
}

function enquiry(popurl){var enquirywindow=window.open(popurl,"","width=480,height=460,")}
function openPage(page) {window.open(page,null,"height=400,width=430,status=yes,toolbar=no,menubar=no,location=no");}

function checkForm(){
	var error = false;
	
	if(document.getElementById('form_email').value==''){
		error = true;
		document.getElementById('form_email').focus();
	}
	
	if(document.getElementById('form_name').value==''){
		error = true;
		document.getElementById('form_name').focus();
	}
	
	if(error){
		alert('You appear to have missed some fields');
		return false;
	}else{
		return true;
	}
}