
function init(imageMode)
{
	setHeight(document.getElementById('bodyBlock'));
	if (imageMode==1) realImage();
	initScroll();
}


/*** COLUMN HEIGHTS ***/

function getHeight(theEl)
{
	return (theEl.currentStyle) ? theEl.offsetHeight : stripPX(document.defaultView.getComputedStyle(theEl,'').height);
}
function stripPX(theValue)
{
	return (theValue.substring(0, theValue.length - 2) - 0);
}
function setHeight(element)
{
	var contentColumnHeight = getHeight(document.getElementById("mainCol"));
	var leftSideHeight  	= getHeight(document.getElementById("leftCol"));
	var rightCol 			= document.getElementById("rightCol")
	var rightSideHeight 	= 0;
	if (rightCol!=null) 	rightSideHeight 	= getHeight(rightCol);

	tallestColumn   	= (leftSideHeight > rightSideHeight)	? leftSideHeight	: rightSideHeight;
	tallestColumn   	= (tallestColumn > contentColumnHeight) ? tallestColumn 	: contentColumnHeight;

	if (element.style.minHeight)
	{
		element.style.minHeight = tallestColumn+"px";
	}
	else
	{
		element.style.height	= tallestColumn+"px";
	}
}

/*** GENERAL FORM CHECKING TOOLS ***/

function isFieldEmpty(theField)
{
	return (theField.value.length < 1) ? true : false;
}
function isFieldBadEmail(theField)
{
	theEmail = theField.value;
	if (theEmail.indexOf('@')==-1 || theEmail.indexOf('.')==-1 || theEmail.length<6) return true;
	return false;
}
function clearQuotes(theForm)
{
	for (i = 0; i < theForm.elements.length; i++)
	{
		if (theForm.elements[i].value) theForm.elements[i].value = theForm.elements[i].value.replace(/'/gi,"`");
	}
}


/*** SET IMAGES TO REAL SIZE ***/

function realImage() {
	var imageArray = document.getElementById('bodyBlock').getElementsByTagName('img');
	for (i=0;i<imageArray.length;i++) {
		thisImage = imageArray[i];
		thisImage.removeAttribute('width');
		thisImage.removeAttribute('height');
	}
}

/*** POPUP IMAGES FOR LEVEL 3 ***/

function imagePop(theID) {
	var popWin32 = window.open("http://www.cruiseplanet.com.au/components/level3_image_popup.php?file="+theID,"popWin33","height=320,width=290,left=20,top=20,resizable=yes,screenX=20,screenY=20,scrollbars=yes");
}


/******* TAB CODE - It's Taberrific! ********/

function showTab(theButton,theID) {

	// get hold of the target tab
	var thisTab = document.getElementById(theID);
	if (thisTab && thisTab.className.indexOf("tabOn")==-1 ) {

		// get hold of all other tabs
		var tabList = document.getElementById('tabHolder').getElementsByTagName('div');
		if (tabList.length>1) {

			// work through tabs one by one, adding or removing "tabOn" class as necessary
			for (i=0;i<tabList.length;i++) {
				if (tabList[i]==thisTab) {
					tabList[i].className = tabList[i].className+" tabOn";
				} else {
					tabList[i].className = tabList[i].className.replace("tabOn","");
				}
			}

			// change the buttons

			// get hold of all buttons
			var liList = document.getElementById('tabIndex').getElementsByTagName('li');
			if (liList.length>1) {

				// work through buttons one by one, adding or removing "tabIndexOn" class as necessary
				for (i=0;i<liList.length;i++) {
					if (liList[i]==theButton.parentNode) {
						liList[i].className = liList[i].className+" tabIndexOn";
					} else {
						liList[i].className = liList[i].className.replace("tabIndexOn","");
					}
				}

			}

			// rebuild page because explorer just can't cope
			// setHeight(document.getElementById('bodyBlock'));  not needed with new layout
		}
	}
}

/**** WACKY TEXT SCROLLING CODE ****/

var scr1;
var scr2;
var scrOffset;
var scrMove = 2;
var scrDelay = 50;
var scrTime;
var undef;

function getWidth(theEl)
{
	return (theEl.currentStyle) ? theEl.offsetWidth : stripPX(document.defaultView.getComputedStyle(theEl,'').width);
}
function initScroll() {
	scr1 = document.getElementById('scroll1');
	scr2 = document.getElementById('scroll2');
	if (scr1!=undef && scr2!=undef) {
		scrOffset = getWidth(scr1);
		scr2.style.left=scrOffset+"px";
		scrTime = setInterval("doScroll()",scrDelay);
	}
}
function doScroll() {
	var curLeft = stripPX(scr1.style.left)-0;
	scr1.style.left = (curLeft-scrMove)+"px";
	var newLeft = stripPX(scr1.style.left)-0;
	if (newLeft < (0-scrOffset)) scr1.style.left = scrOffset+"px";

	var curLeft = stripPX(scr2.style.left)-0;
	scr2.style.left = (curLeft-scrMove)+"px";
	var newLeft = stripPX(scr2.style.left)-0;
	if (newLeft < (0-scrOffset)) scr2.style.left = scrOffset+"px";
}	
