

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
		}
	}
}

/******* HOME TAB CODE ********/

function homeTabs(which) {
	var b1 = document.getElementById('htab1');
	var b2 = document.getElementById('htab2');
	var b3 = document.getElementById('htab3');
	var t1 = document.getElementById('tab1');
	var t2 = document.getElementById('tab2');
	var t3 = document.getElementById('tab3');

	b1.className=""; b2.className=""; b3.className="";
	t1.className="specialTab"; t2.className="specialTab"; t3.className="specialTab";

	switch(which) {
		case 1: b1.className="on"; t1.className+=" on"; break;
		case 2: b2.className="on"; t2.className+=" on"; break;
		case 3: b3.className="on"; t3.className+=" on"; break;
	}

}

/******* MENU CODE ********/

var menuList = new Array();
function switchdMenu(c) {
	if (menuList.length==0) {
		menuList = document.getElementById('subMenu').getElementsByTagName('div');
	}
	for (i=0;i<menuList.length;i++) {
		menuList[i].className="";
	}
	document.getElementById('sub'+c).className="on";
}




