var isOpera = (navigator.userAgent.indexOf('Opera') != -1)? true : false;
var isIE = (document.all)? true : false; 

var more_info_table = {
	obj: false,
	init: function() {
		if(document.getElementById('north-wales-info-table')) {
			this.obj = document.getElementById('north-wales-info-table');
			this.obj.style.display = 'none';
			return true;
		}
		return false;
	},
	show: function() {
		if(!this.obj)
			this.init();
		this.obj.style.display = '';
		if(document.all)
			this.obj.parentNode.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity = 70)";
		else
			this.obj.parentNode.style.MozOpacity = "0.5";
	},
	hide: function() {
		if(!this.obj)
			this.init();
		this.obj.style.display = 'none';
		if(document.all)
			this.obj.parentNode.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity = 100)";
		else
			this.obj.parentNode.style.MozOpacity = "1";
	},
	hover_on: function(cell) {
		if(cell) {
			cell.style.backgroundColor = '#27A448';
			cell.getElementsByTagName('a').item(0).style.color = '#ffffff';
		}
	},
	hover_off: function(cell) {
		if(cell) {
			cell.style.backgroundColor = '#ffffff';
			cell.getElementsByTagName('a').item(0).style.color = '#27A448';
		}
	}
}
if(document.addEventListener){
	window.addEventListener("load", more_info_table.init, true);
} else {
	window.attachEvent("onload",more_info_table.init);
}

var box_link = {
	bubble: true,
	hover: function(obj) {
		var href = this.check_bubble(obj);
		var new_window = (arguments[1])? true : false;
		obj.onclick = function() {
			box_link.click(href, new_window);
		};
		obj.onmouseout = function() {
			box_link.reset_status();
		};
		obj.style.cursor = 'pointer';
	},
	reset_status: function() {
		box_link.bubble = true;
		window.status = '';
	},
	click: function(href, new_window) {
		if(this.bubble && href) {
			if(new_window)
				popit = window.open(href, "_blank", "location=1, menubar=1, resizable=1, scrollbars=1, status=1, titlebar=1, toolbar=1");
			else
				location.href = href;
			return;
		}
	},
	check_bubble: function(obj) {
		if(obj) {
			var a = obj.getElementsByTagName('a');
			for(i=0; i<a.length; i++) {
				a.item(i).onclick = function() {
					box_link.bubble = false;
					return true;
				}
				a.item(i).onmouseover = function() {
					window.status = this.innerHTML.replace(/<.+?>/gi, ' ');
				}
				a.item(i).onmouseout = function() {
					box_link.reset_status();
				}
			}
			if(a.item(0)) {
				window.status = a.item(0).innerHTML.replace(/<.+?>/gi, ' ');
				return a.item(0).href;
			}
		}
		return false;
	}
}

var login = {
	timer: false,
	login_box: false,
	login_form: false,
	login_link: false,
	init: function() {
		this.login_box = document.getElementById('login_box');
		this.login_form = document.login_form;
		this.login_link = document.getElementById('login_link');
		login_link.removeAttribute('href');
		this.login_link.onmouseover = function() {
			login.show();
		}
		this.login_link.onmouseout = function() {
			login.hide(7000);
		}
		this.login_box.onmouseover = function() {
			login.cancel();
		}
		this.login_box.onmouseout = function() {
			login.hide(2000);
		}
		this.show();
	},
	show: function() {
		login.cancel();
		this.login_box.style.display = 'inline';
		this.login_form.company.focus();
	},
	hide: function(wait) {
		login.cancel();
		this.timer = setTimeout("login.login_box.style.display = 'none';", wait);
	},
	cancel: function() {
		if(this.timer)
			window.clearTimeout(this.timer);
	}
}


function mail() {
	var prefix = (arguments[0])? arguments[0] : "info";
	var suffix = (arguments[1])? arguments[1] : "adventure-northwales.com";
	if(prefix && suffix) {
		document.write("<a href=\"mailto:"+prefix+"@"+suffix+"\">"+prefix+"@"+suffix+"</a>");
		return true;
	}
}

var timer = false;
function brochure_link(obj) {
	span = obj.getElementsByTagName('span').item(0);
	span.style.display = 'inline';
	span.style.position = 'absolute';
	if(0)
		span.style.left = (obj.offsetLeft + obj.parentNode.offsetLeft + 10);
	if(isOpera) {
		span.style.top = (span.offsetTop + 10);
	}
	obj.onmouseover = function() {
		if(timer)
			window.clearTimeout(timer);
		obj.getElementsByTagName('span').item(0).style.display = 'inline';
	}
	obj.onmouseout = function() {
		timer = setTimeout("document.getElementById('brochure_link').getElementsByTagName('span').item(0).style.display = 'none';", 3000);
	}
}
