/*
 * CORNISH CRUISING
 *
 * Subject to copyright.
 *
 * Web Design - Hudson Armstrong Design
 * mailto: info@hudsonarmstrong.co.uk
 * http://www.hudsonarmstrong.com
 *
 * Web Development - LOOKsystems Limited
 * mailto:info@looksystems.ltd.uk
 * http://www.looksystems.ltd.uk
 *
 */

// POPUP SUPPORT

var popups = new Object;
var popups_child;

function popups_initialise() {
	if (!document.links.length) return;
	var a = 0;
	while (a < document.links.length) {
		var id = document.links[a].id;
		if (!popups[id]) id = document.links[a].id;
		if (!popups[id] && id.substring(0, 5) == 'popup') id = 'popup';
		if (popups[id] != null || id == 'popup') {
			var href = document.links[a].href;
			document.links[a].href = "javascript:popup('"+id+"','"+href+"')";
			document.links[a].target = "_self";
		}
		a++;
	}
}

function popup(id, url) {
	var name, features;
	if (popups != null) features = popups[id];
	if (features != null) {
		name = features[0];
		var x = features[1];
		var y = features[2];
		var w = features[3];
		var h = features[4];
		if (x < 0) x = (window.screen.availWidth - w) / 2;
		else if (window.screenX != null) x += window.screenX;
		if (y < 0) y = (window.screen.availHeight - h) / 2;
		else if (window.screenY != null) y += window.screenY;
		features = features[5];
		if (features != "") features += ",";
		features += "width="+w+",height="+h;
		features += ",screenX="+x+",screenY="+y;
		features += ",left="+x+",top="+y;
	}
	if (popups_child != null) {
		if (popups_child.close != null) popups_child.close();
		else name = '';
	}
	popups_child = window.open(url, name, features);
	if (popups_child != null && popups_child.focus != null) popups_child.focus();
}

// MENUS

var mcTimer = false;

function mi(item) {

	var navigation = document.getElementById('skip_navigation');
	if (navigation != null && navigation.style.visibility != 'hidden') return;

	var children = item.parentNode.parentNode.getElementsByTagName('ul');
	for (c = 0; c < children.length; ++c) {
		if (children[c] != item) children[c].style.visibility = 'hidden';
	}
	children = item.parentNode.getElementsByTagName('ul');
	if (children.length) children[0].style.visibility = 'visible';

	if (!mcTimer) return;
	clearTimeout(mcTimer);
	mcTimer = false;

}

function mo() {
	var navigation = document.getElementById('skip_navigation');
	if (navigation != null && navigation.style.visibility != 'hidden') return;
	mcTimer = setTimeout("mc()", 250);
}

function mc() {

	mcTimer = false;
	var menu = document.getElementById('menu');
	if (!menu) return;

	var children = menu.getElementsByTagName('ul');
	for (c = 1; c < children.length; ++c) {
		children[c].style.visibility = 'hidden';
	}

}

// DOCUMENT FOCUS

function sf() {
	var e = 0;
	if (!document.forms.length) return;
	var myform = document.forms[0];
	while (e < myform.elements.length) {
		if (myform.elements[e].type == "text" || myform.elements[e].type == "textarea") {
			myform.elements[e].focus();
			break;
		}
		e++;
	}
}

// DOCUMENT INITIALISE

function init() {
	popups_initialise();
	sf();
}