
function init()
{
	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);
}

/*** 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.holidayplanet.com.au/phpsite/components/level3_image_popup.php?file="+theID,"popWin33","height=320,width=290,left=20,top=20,resizable=yes,screenX=20,screenY=20,scrollbars=yes");
}


/*** SWITCHING LINKS AROUND IN "PLAN AND BOOK ONLINE" ***/

function switcher(theNum) {
	if (isNaN(theNum)) theNum=1;
	if (document.getElementById("switch1")!=null) {
		for (i=2;i<4;i++) {
			theH4 = document.getElementById("switch"+i);
			theUl = document.getElementById("switch"+i+"0");
			if (theUl) {
				if (i==theNum) {
					theH4.className="switchOn";
					theUl.className="switchOn";
				} else {
					theH4.className="";
					theUl.className="";
				}
			}
		}
	}
}


/*** NEW HORIZONS ***/
function newHorizons(theURL) {
	var popWin32 = window.open(theURL,"popWin33","height=500,width=800,left=0,top=0,resizable=yes,screenX=0,screenY=0,scrollbars=yes");
	popWin32.focus();
}




/******* 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";
}	



