function showHide(id) {
	el = $(id);
	
	if (el.className == 'extraInfoShow') {
		el.className = 'extraInfo';
	} else {
		el.className = 'extraInfoShow';
		message = $$('#' + id + ' div.loadingMessageText');
		for (var i = 0; i < message.length ; i++ ) {
			messNode = message[i];

			messNode.parentNode.style.height = '' + (messNode.parentNode.parentNode.offsetHeight ) + 'px';
			messNode.style.height = '' + (messNode.parentNode.offsetHeight ) + 'px';
		}
	}
}

function showLoading(id, message) {
	// get the span
	messages = $$('#' + id + ' div.loadingMessageText span.loadingMessageContent');
	messSpan = messages[0];
	
	// set the message and show element
	messSpan.innerHTML = message;
	$(id).style.visibility = 'visible';
}

function hideLoadingTimer(id, message, timer) {
	// get the span
	messages = $$('#' + id + ' div.loadingMessageText span.loadingMessageContent');
	messSpan = messages[0];
	
	// set the message and show element
	messSpan.innerHTML = message;
	
	// start timer to hide the div
	setTimeout('$(\'' + id + '\').style.visibility = \'hidden\';', timer);
}

function sitesOpenClose(el) {
	cont = el.parentNode;
	
	nodes = cont.childNodes;
	
	for (i = 0; i < nodes.length ; i++) {
		if (nodes[i].className == 'attractionsSiteList') {
			showHideNode(nodes[i], el);
			break;
		} 
	}
}

function showHideNode(el, img) {
	// the element is the site listing container, so display it
	if (el.style.display != 'none') {
		el.style.display = 'none';
	} else {
		el.style.display = 'block';
	}
	
	temp = img.src;
	img.src = img.alt;
	img.alt = temp;
}
function checkSites(attid, plotid) {
	pldiv = $('attrLotsDiv_' + attid + '_' + plotid);
	plcheck = $('attrLotsCheck_' + attid + '_' + plotid);
	plsites = $('attrLotsSitesDiv_' + attid + '_' + plotid);
	if (plcheck.checked) {
		pldiv.style.backgroundColor = '#77FF77';
		checks = plsites.childNodes;
		for (i = 0; i < checks.length ; i++ ) {
			if ( (checks[i].nodeName == 'INPUT') && (checks[i].type == 'checkbox') ) {
				checks[i].checked = true;
			}
		}
		if (plsites.style.display == 'none') {
			img = $('attrLotsImg_' + attid + '_' + plotid);
			showHideNode(plsites, img);
		}
	} else {
		pldiv.style.backgroundColor = '#EEEEEE';
		checks = plsites.childNodes;
		for (i = 0; i < checks.length ; i++ ) {
			if ( (checks[i].nodeName == 'INPUT') && (checks[i].type == 'checkbox') ) {
				checks[i].checked = false;
			}
		}
	}
}

function checkSite(sitecheck, attid, plotid) {
	pldiv = $('attrLotsDiv_' + attid + '_' + plotid);
	plcheck = $('attrLotsCheck_' + attid + '_' + plotid);
	plsites = $('attrLotsSitesDiv_' + attid + '_' + plotid);
	if (sitecheck.checked) {
		pldiv.style.backgroundColor = '#77FF77';
		plcheck.checked = true;
		
		if (plsites.style.display == 'none') {
			img = $('attrLotsImg_' + attid + '_' + plotid);
			showHideNode(plsites, img);
		}
	} else {
		//checks = plsites.childNodes;
		checks = $$('#attrLotsSitesDiv_' + attid + '_' + plotid+' input');
		
		var turnoff = true;
		for (i = 0; i < checks.length ; i++ ) {
			if ( (checks[i].nodeName == 'INPUT') && (checks[i].type == 'checkbox') && ( checks[i].checked == true ) ) {
				turnoff = false;
				break;
			}
		}
		if (turnoff) {
			pldiv.style.backgroundColor = '#EEEEEE';
			plcheck.checked = false;
		}
	}
}

function nextObject(n) {
	//var n = this;
	do 
		n = n.nextSibling;
	while (n && n.nodeType != 1 && n.nodeName != 'INPUT');
	return n;
}

function previousObject(p) {
	//var p = this;
	do 
		p = p.previousSibling;
	while (p && p.nodeType != 1 );
	return p;
}

function moveUp(node) {
	p = previousObject(node);
	idfld = nextObject(node);
	if (p) {
		node.parentNode.insertBefore(node,previousObject(p));
		node.parentNode.insertBefore(idfld, previousObject(p));
	}
}

function moveDown(node) {
	n = nextObject(nextObject(node));
	
	if (n) {
		idfld = nextObject(n);
		node.parentNode.insertBefore(n, node);
		node.parentNode.insertBefore(idfld, node);
	}
}

function removeImgNode(node) {
	node.parentNode.removeChild(nextObject(node));
	node.parentNode.removeChild(node);
}
