/* === generic.js === */
var itemArray = new Array();
var linkArray = new Array();



function toggleItinerary(item, link) {
	var itineraryItem = document.getElementById(item);
	var itineraryLink = document.getElementById(link);
	
	for(var i=0; i<itemArray.length; i++) {
		itemArray[i].style.display = 'none';
		
	}
		
	for(var j=0; j<itemArray.length; j++) {
		linkArray[j].className = '';
	}
		
	if(itineraryItem.style.display == 'none' ) {
		itineraryItem.style.display = 'block';
		} else {
		itineraryItem.style.display = 'none';		
	}
	
	if(itineraryLink.className == '') {
		itineraryLink.className = 'current';
	} else {
		itineraryLink.className = '';
	}
	
	return false;
}

function toggleMiniMap() {
	var mapItem = document.getElementById('miniMap');
	
	if(mapItem.style.display == 'none') {
		mapItem.style.display = 'block';
	} else {
		mapItem.style.display = 'none';
	}
	
	return false;
	
}

/*****************************
*  Toggle font size functions 
*/

//Returns an array of child nodes from the passed in element that all have the passed in class name's (specific areas on page to affect only)
function getElementsByClass(theNode, toolClass, contentClass, navClass) {

	var cArray = [];
	var cArrayLoc = 0;
		
	function doTree(theNode) {
		if (theNode.className == toolClass || theNode.className == contentClass || theNode.className == navClass) {
			  cArray[cArrayLoc] = theNode;
			  cArrayLoc++;
		}
		for (var i=0, len=theNode.childNodes.length; i<len; i++) {
			  doTree(theNode.childNodes[i]);
		}
	}
		
	doTree(theNode);
	return cArray;
}

//assume user is not already on large text
var smallFont = true;

//Uses array to update all child nodes of element
function toggleFontSizes() {

	var fontSizeToggle = getElementsByClass(document.getElementById("fontSizeTarget"), "toolBar", "contentPane", "navPane");
	
	if (!fontSizeToggle) {
		return;
	}
	
	if(smallFont) {
		for (var i = 0; i < fontSizeToggle.length; i++) {
			fontSizeToggle[i].style.fontSize = "1.2em";
			smallFont = false;
		}
	}
	else {
		for (var i = 0; i < fontSizeToggle.length; i++) {
			fontSizeToggle[i].style.fontSize = "1em";
			smallFont = true;
		}
	}
}

/*****************************
*  Check the current domain an change the gmaps key and the search heading 
*/
function domainChecker(n) {
    var currURL = location.href;
    var googleKey;
    var googleIndex = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=";
    var searchHeading = "Listings Search";

        if(location.host.indexOf("www.staging2.discovertasmania.clients.squiz.net") != -1) {searchHeading = "Listings Search"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBQjBmYmlHDPN66QNDWOUytIvoFXBhTu_FKxqgHqwWv-yvOSn_hg3XuOOg";}
        if(location.host.indexOf("www.discovertasmania.com") != -1) {searchHeading = "Listings Search"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBRfVvUY5CTzCkkFgZdl3F6RANMB6hRYoG_MBcFuTLNF0PHsVxHK7MyvrA";}
        if(location.host.indexOf("it.discovertasmania.com") != -1) {searchHeading = "Prodotto di cerca"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBQO0u4ZUION4Mn2ryzPqOoz0vUXfhQsh5pi6wypQ4Ct5C_sAYuXjhnI6g";}
        if(location.host.indexOf("fr.discovertasmania.com")  != -1) {searchHeading = "Recherche de produits"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBTnhCZGoBzO0dmKpbe3GQ1C5cZSqhTAT3EmA09zWE4ZjFIS4RMOQtshvw";}
        if(location.host.indexOf("de.discovertasmania.com")  != -1) {searchHeading = "Produkte Suchen"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBTY4frWkpR0JuvPbkurS7d6NdrDhRTsD6QN-29J7sLIWtAnIsgTsKC8WA";}
        if(location.host.indexOf("ja.discovertasmania.com") != -1) {searchHeading = "商品検索"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBTm4zWxj-yDigTpNe2b5GowM7w9jRS-qtxXy-eURdNEAyVFIhyll_f9OA";}
        if(location.host.indexOf("ko.discovertasmania.com") != -1) {searchHeading = "상품검색"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBSQxrOGb1kks-2Qpzh5Au8X-mt62xR8b9WXtnrJ_4aZax3MbL5EVXzc-Q";}
        if(location.host.indexOf("zht.discovertasmania.com")  != -1) {searchHeading = "產品搜索"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBSufK5aJRrEZ6fcNG7DnTgG5H62cRQCGj3ZuwRavKOZ8NaISRIBfq8F9Q";}
        if(location.host.indexOf("zhs.discovertasmania.com")  != -1) {searchHeading = "产品搜索"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBR3vfS4yUxuoKqwo97mwE8ZUM3hahQTGywxnCb7R7Z4DGqWV4oQJZJMNg";}
        if(location.host.indexOf("ens.discovertasmania.com")  != -1) {searchHeading = "Listings Search"; googleKey = "ABQIAAAASO5sC7Svje_a30gKoYzpDBSR6EsW5zd1ui513t-nskhZtiA9NRQ9oMP_zz_g2ppodLMH7hVesqG10w";}

switch(n) {
    case 1 :
        document.write('<scr'+'ipt src='+googleIndex+googleKey+' type=\"text/javascript\"></scr'+'ipt>')
        break;
    case 2 :
        document.write(searchHeading)
    }
}

/* === towns.js === */
towns = new Array('Abbortsham', 'Aberdeen', 'Adventure Bay', 'Akaroa', 'Alcomie', 'Alonnah', 'Ansons Bay', 'Antill Ponds', 'Arthur River', 'Arthurs Lake', 'Avoca', 'Avondale', 'Baden', 'Bagdad', 'Balfour', 'Bangor', 'Barnes Bay', 'Barrington', 'Beaconsfield', 'Beaumaris', 'Beauty Point', 'Beechford', 'Bell Bay', 'Bellingham', 'Ben Lomond', 'Beulah', 'Beulah Lower', 'Bicheno', 'Binalong Bay', 'Birchs Bay', 'Birralee', 'Bishopsbourne', 'Black River', 'Blackmans Bay', 'Blackwall', 'Blackwood Creek', 'Blessington', 'Blue Rocks', 'Blythe', 'Boat Harbour', 'Boat Harbour Flinders', 'Bonnet Hill', 'Bothwell', 'Boyer', 'Bracknell', 'Branxholm', 'Breadalbane', 'Bream Creek', 'Bridgenorth', 'Bridport', 'Brighton', 'Brittons Swamp', 'Broadmarsh', 'Bronte Park', 'Bruny Island', 'Buckland', 'Burnie', 'Burns Creek', 'Bushy Park', 'Butlers Gorge', 'Cairns Bay', 'Calder', 'Campania', 'Campbell Town', 'Canena', 'Cape Barren Island', 'Cape Grim', 'Carlton', 'Carlton River', 'Carmentown', 'Carrick', 'Castle Forbes Bay', 'Catamaran', 'Caveside', 'Central Castra', 'Cethana', 'Chain Of Lagoons', 'Chasm Creek', 'Christmas Hills', 'Chudleigh', 'Clarence Point', 'Clarendon', 'Claude Road', 'Cleveland', 'Clifton Beach', 'Cluan', 'Cockle Creek', 'Colebrook', 'Coles Bay', 'Collins Cap', 'Conara Junction', 'Coningham', 'Connellys Marsh', 'Copping', 'Corinna', 'Cornwall', 'Cowrie Point', 'Crabtree', 'Cradle Mountain', 'Cradle Valley', 'Cradoc', 'Cranbrook', 'Crayfish Creek', 'Cremorne', 'Cressy', 'Cuckoo', 'Cuprona', 'Currie', 'Cygnet', 'Daisey Dell', 'Darlington', 'Deddington', 'Deep Bay', 'Deloraine', 'Dennes Point', 'Derby', 'Derwent Bridge', 'Desolation Bay', 'Deviot', 'Devon Hills', 'Devonport', 'Dilston', 'Dodges Ferry', 'Doo Town', 'Douglas River', 'Dover', 'Dromedary', 'Dulcot', 'Dunalley', 'Dunorlan', 'Dysart', 'Eaglehawk Neck', 'East Ulverstone', 'Edgcumbe Beach', 'Edith Creek', 'Egg Lagoon', 'Electrona', 'Elizabeth Town', 'Ellendale', 'Emita', 'Emita Beach', 'English Town', 'Epping', 'Epping Forest', 'Erriba', 'Esk Upper', 'Evandale', 'Exeter', 'Exton', 'Falmouth', 'Fentonbury', 'Fingal', 'Flinders Island', 'Flowerdale', 'Flowerpot', 'Flowery Gully', 'Forcett', 'Forest', 'Forester', 'Fortescue Bay', 'Forth', 'Four Mile Creek', 'Frankford', 'Frankford West', 'Franklin', 'Frenchmans Cap', 'Friendly Beaches', 'Garden Island Creek', 'Gardners Bay', 'Gawler', 'Geeveston', 'George Town', 'Gladstone', 'Glance Creek', 'Glaziers Bay', 'Glen Huon', 'Glendevie', 'Glenfern', 'Glengarry', 'Glenora', 'Golconda', 'Golden Valley', 'Gordon', 'Gormanston', 'Goshen', 'Goulds Country', 'Gowrie Park', 'Granton', 'Granville Harbour', 'Grassy', 'Gravelly Beach', 'Gray', 'Great Bay', 'Greens Beach', 'Gretna', 'Grindelwald', 'Grove', 'Guilford', 'Gunns Plains', 'Hadspen', 'Hagley', 'Hamilton', 'Hampshire', 'Harford', 'Hastings', 'Hawley Beach', 'Hayes', 'Heka', 'Herrick', 'Heybridge', 'Highclere', 'Highcroft', 'Hillwood', 'Hobart', 'Hollow Tree', 'Holwell', 'Howden', 'Howth', 'Huntingfield', 'Huonville', 'Ilfraville', 'Interlaken', 'Irishtown', 'Iron House Point', 'Isis', 'Jericho', 'Jetsonville', 'Judbury', 'Kamona', 'Kaoota', 'Karoola', 'Kayena', 'Kellevie', 'Kellyfield', 'Kelso', 'Kempton', 'Kettering', 'Killiecrankie', 'Killora', 'Kimberley', 'Kindred', 'King Island', 'Kingston', 'Kingston Beach', 'Kingston Heights', 'Koonya', 'Lachlan', 'Lackrana', 'Lady Barron', 'Lake Barrington', 'Lake Leake', 'Lake Margaret', 'Lake St Clair', 'Lalla', 'Lanena', 'Lapoinya', 'Latrobe', 'Launceston', 'Lawitta', 'Lebrina', 'Lefroy', 'Legana', 'Legerwood', 'Legunia', 'Leith', 'Lemana', 'Lemont', 'Leslie Vale', 'Levendale', 'Lewisham', 'Liena', 'Lietinna', 'Liffey', 'Lileah', 'Lilydale', 'Lilydale North', 'Lisle', 'Little Swanport', 'Llandaff', 'Lollara', 'London Lakes', 'Longford', 'Longley', 'Longley Lower', 'Lonnavale', 'Loongana', 'Loorana', 'Lorinna', 'Lottah', 'Low Head', 'Lower Barrington', 'Lower Snug', 'Lower Wattle Grove', 'Loyetea', 'Lucaston', 'Lulworth', 'Lunawanna', 'Lune River', 'Lymington', 'Lymwood', 'Macquarie Plains', 'Magra', 'Malbina', 'Mangalore', 'Mangana', 'Margate', 'Maria Island', 'Marion Bay', 'Marrawah', 'Mathinna', 'Mawbanna', 'Mayberry', 'Maydena', 'Meander', 'Melba Flats', 'Mella', 'Melrose', 'Melton Mowbray', 'Memana', 'Mengha', 'Merseylea', 'Middleton', 'Midway Point', 'Miena', 'Moina', 'Mole Creek', 'Molesworth', 'Moltema', 'Montagu', 'Montana', 'Montumana', 'Moogara', 'Mooreville', 'Moorina', 'Moriarty', 'Mount Direction', 'Mountain River', 'Mt Field National Park', 'Mt Lloyd', 'Mt Roland', 'Mt Seymour', 'Mt Wellington', 'Murdunna', 'Musselroe Bay', 'Myalla', 'Myrtle Bank', 'Nabageena', 'Nabowla', 'Naracoopa', 'Narrawa', 'National Park', 'Natone', 'Natone Upper', 'Needles', 'Neika', 'New Norfolk', 'Nicholls Rivulet', 'Nietta', 'Nile', 'Nook', 'North East', 'North Forest', 'North Motton', 'North West', 'Northdown', 'Notley Hills', 'Nowhere Else', 'Nubeena', 'Nugent', 'Nunamara', 'Oakwood', 'Oatlands', 'Oldina', 'Opossum Bay', 'Orford', 'Orielton', 'Ormley', 'Osmaston', 'Osterley', 'Ouse', 'Oyster Cove', 'Paloona', 'Paper Beach', 'Paradise', 'Parattah', 'Parenna', 'Parkham', 'Patersonia', 'Pats River', 'Pawleena', 'Pearshape', 'Pegarah', 'Pelverata', 'Penguin', 'Penna', 'Perth', 'Petcheys Bay', 'Pioneer', 'Pipers Brook', 'Pipers River', 'Plenty', 'Poatina', 'Police Point', 'Pontville', 'Port Arthur', 'Port Davey', 'Port Huon', 'Port Latta', 'Port Sorell', 'Powranna', 'Premaydena', 'Preston', 'Primrose Sands', 'Promised Land', 'Pyengana', 'Quamby Brook', 'Queenstown', 'Radnor', 'Railton', 'Raminea', 'Ranelagh', 'Ranga', 'Red Hills', 'Redpa', 'Reedy Marsh', 'Reekara', 'Rekuna', 'Relbia', 'Renison Bell', 'Retreat', 'Rheban', 'Riana', 'Riana South', 'Richmond', 'Ridgeway', 'Ridgley', 'Ringarooma', 'Robigana', 'Rocky Cape', 'Roger River', 'Roger River West', 'Roland', 'Rosebery', 'Rosegarland', 'Rosevale', 'Rosevears', 'Ross', 'Rossarden', 'Rowella', 'Runnymede', 'Salamanca Place', 'Saltwater River', 'Sandfly', 'Sandford', 'Sassafras', 'Sassafras East', 'Savage River', 'Scamander', 'Scamander Upper', 'Scotts Peak', 'Scottsdale', 'Scottsdale North', 'Scottsdale West', 'Sea Elephant', 'Selbourne', 'Seymour', 'Shannon', 'Shearwater', 'Sheffield', 'Sidmouth', 'Simpsons Bay', 'Sisters Beach', 'Sisters Creek', 'Smithton', 'Smokers Bank', 'Snug', 'Sorell', 'Sorell Creek', 'South Arm', 'South Bruny Island', 'South Forest', 'South Franklin', 'South Mt Cameron', 'South Nietta', 'South Preston', 'South Riana', 'Southern', 'Southport', 'Spalford', 'Sprent', 'Spreyton', 'Spring Beach', 'Springfield', 'Springfield South', 'Springhill Bottom', 'St Helens', 'St Marys', 'Stanley', 'Statewide', 'Staverton', 'Steppes', 'Stieglitz', 'Stoodley', 'Storeys Creek', 'Stormlea', 'Stowport', 'Stowport Upper', 'Strahan', 'Strathblane', 'Strathgordon', 'Strickland', 'Sulphur Creek', 'Sunnyside', 'Surges Bay', 'Swan Bay', 'Swan Island', 'Swansea', 'Swanwick', 'Table Cape', 'Takone', 'Takone West', 'Taranna', 'Targa', 'Tarraleah', 'Tayene', 'Tea Tree', 'Telita', 'Temma', 'Tewkesbury', 'Thirlstane', 'Three Hummock Island', 'Tinderbox', 'Tomahawk', 'Tonganah', 'Tower Hill', 'Trenah', 'Triabunna', 'Tulendeena', 'Tullah', 'Tunbridge', 'Tunnack', 'Tunnel', 'Turners Beach', 'Turners Marsh', 'Tyenna', 'Ulverstone', 'Underwood', 'Upper Blessington', 'Upper Castra', 'Upper Esk', 'Upper Mount Hicks', 'Uxbridge', 'Verona Sands', 'Via Smithton', 'Waddamana', 'Waratah', 'Warrentinna', 'Warringa', 'Waterhouse', 'Waterloo', 'Wayatinah', 'Weegena', 'Weetah', 'Weldborough', 'Wesley Vale', 'West Kentish', 'West Montagu', 'West Pine', 'West Ridgley', 'West Ulverstone', 'Westbury', 'Western Creek', 'Western Junction', 'Westerway', 'Westwood', 'Weymouth', 'White Beach', 'White Hills', 'Whitemark', 'Whitemore', 'Whitmore', 'Wihareja', 'Williamsford', 'Wilmot', 'Wilmot Lower', 'Wiltshire', 'Windermere', 'Winkleigh', 'Winnaleah', 'Woodbridge', 'Woodbury', 'Woodsdale', 'Woodstock', 'Woodstock Upper', 'Woolnorth', 'Wyena', 'Wynyard', 'Yambacoona', 'Yarlington', 'Yarra Creek', 'Yolla', 'Yorktown', 'Zeehan');

/* === common.js === */
/* Event Functions */

// Add an event to the obj given
// event_name refers to the event trigger, without the "on", like click or mouseover
// func_name refers to the function callback when event is triggered
function addEvent(obj,event_name,func_name){
	if (obj.attachEvent){
		obj.attachEvent("on"+event_name, func_name);
	}else if(obj.addEventListener){
		obj.addEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name] = func_name;
	}
}

// Removes an event from the object
function removeEvent(obj,event_name,func_name){
	if (obj.detachEvent){
		obj.detachEvent("on"+event_name,func_name);
	}else if(obj.removeEventListener){
		obj.removeEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name] = null;
	}
}

// Stop an event from bubbling up the event DOM
function stopEvent(evt){
	evt || window.event;
	if (evt.stopPropagation){
		evt.stopPropagation();
		evt.preventDefault();
	}else if(typeof evt.cancelBubble != "undefined"){
		evt.cancelBubble = true;
		evt.returnValue = false;
	}
	return false;
}

// Get the obj that starts the event
function getElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.currentTarget;
	}
}
// Get the obj that triggers off the event
function getTargetElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.target;
	}
}
// For IE only, stops the obj from being selected
function stopSelect(obj){
	if (typeof obj.onselectstart != 'undefined'){
		addEvent(obj,"selectstart",function(){ return false;});
	}
}

/*    Caret Functions     */

// Get the end position of the caret in the object. Note that the obj needs to be in focus first
function getCaretEnd(obj){
	if(typeof obj.selectionEnd != "undefined"){
		return obj.selectionEnd;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp = M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToEnd",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// Get the start position of the caret in the object
function getCaretStart(obj){
	if(typeof obj.selectionStart != "undefined"){
		return obj.selectionStart;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp = M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToStart",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// sets the caret position to l in the object
function setCaret(obj,l){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(l,l);
	}else if(obj.createTextRange){
		m = obj.createTextRange();		
		m.moveStart('character',l);
		m.collapse();
		m.select();
	}
}
// sets the caret selection from s to e in the object
function setSelection(obj,s,e){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(s,e);
	}else if(obj.createTextRange){
		m = obj.createTextRange();		
		m.moveStart('character',s);
		m.moveEnd('character',e);
		m.select();
	}
}

/*    Escape function   */
String.prototype.addslashes = function(){
	return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/* --- Escape --- */

/* Offset position from top of the screen */
function curTop(obj){
	toreturn = 0;
	while(obj){
		toreturn += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return toreturn;
}
function curLeft(obj){
	toreturn = 0;
	while(obj){
		toreturn += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return toreturn;
}
/* ------ End of Offset function ------- */

/* Types Function */

// is a given input a number?
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

/* Object Functions */

function replaceHTML(obj,text){
	while(el = obj.childNodes[0]){
		obj.removeChild(el);
	};
	obj.appendChild(document.createTextNode(text));
}


/* === actb.js === */
function actb(obj,ca){
	/* ---- Public Variables ---- */
	this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
	this.actb_lim = 4;    // Number of elements autocomplete can show (-1: no limit)
	this.actb_firstText = false; // should the auto complete be limited to the beginning of keyword?
	this.actb_mouse = true; // Enable Mouse Support
	this.actb_delimiter = new Array(';',',');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	this.actb_startcheck = 1; // Show widget only after this number of characters is typed in.
	/* ---- Public Variables ---- */

	/* --- Styles --- */
	this.actb_bgColor = '#888888';
	this.actb_textColor = '#FFFFFF';
	this.actb_hColor = '#000000';
	this.actb_fFamily = 'Verdana';
	this.actb_fSize = '11px';
	this.actb_hStyle = 'text-decoration:underline;font-weight="bold"';
	/* --- Styles --- */

	/* ---- Private Variables ---- */
	var actb_delimwords = new Array();
	var actb_cdelimword = 0;
	var actb_delimchar = new Array();
	var actb_display = false;
	var actb_pos = 0;
	var actb_total = 0;
	var actb_curr = null;
	var actb_rangeu = 0;
	var actb_ranged = 0;
	var actb_bool = new Array();
	var actb_pre = 0;
	var actb_toid;
	var actb_tomake = false;
	var actb_getpre = "";
	var actb_mouse_on_list = 1;
	var actb_kwcount = 0;
	var actb_caretmove = false;
	this.actb_keywords = new Array();
	/* ---- Private Variables---- */
	
	this.actb_keywords = ca;
	var actb_self = this;

	actb_curr = obj;
	
	addEvent(actb_curr,"focus",actb_setup);
	function actb_setup(){
		addEvent(document,"keydown",actb_checkkey);
		addEvent(actb_curr,"blur",actb_clear);
		addEvent(document,"keypress",actb_keypress);
	}

	function actb_clear(evt){
		if (!evt) evt = event;
		removeEvent(document,"keydown",actb_checkkey);
		removeEvent(actb_curr,"blur",actb_clear);
		removeEvent(document,"keypress",actb_keypress);
		actb_removedisp();
	}
	function actb_parse(n){
		if (actb_self.actb_delimiter.length > 0){
			var t = actb_delimwords[actb_cdelimword].trim().addslashes();
			var plen = actb_delimwords[actb_cdelimword].trim().length;
		}else{
			var t = actb_curr.value.addslashes();
			var plen = actb_curr.value.length;
		}
		var tobuild = '';
		var i;

		if (actb_self.actb_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}
		var p = n.search(re);
				
		for (i=0;i<p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "<font style='"+(actb_self.actb_hStyle)+"'>"
		for (i=p;i<plen+p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "</font>";
			for (i=plen+p;i<n.length;i++){
			tobuild += n.substr(i,1);
		}
		return tobuild;
	}
	function actb_generate(){
		if (document.getElementById('tat_table')){ actb_display = false;document.body.removeChild(document.getElementById('tat_table')); } 
		if (actb_kwcount == 0){
			actb_display = false;
			return;
		}
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.width='200px';
		a.style.position='absolute';
		a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
		a.style.left = curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id = 'tat_table';
		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actb_self.actb_mouse){
			a.onmouseout = actb_table_unfocus;
			a.onmouseover = actb_table_focus;
		}
		var counter = 0;
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){
				counter++;
				r = a.insertRow(-1);
				if (first && !actb_tomake){
					r.style.backgroundColor = actb_self.actb_hColor;
					first = false;
					actb_pos = counter;
				}else if(actb_pre == i){
					r.style.backgroundColor = actb_self.actb_hColor;
					first = false;
					actb_pos = counter;
				}else{
					r.style.backgroundColor = actb_self.actb_bgColor;
				}
				r.id = 'tat_tr'+(j);
				c = r.insertCell(-1);
				c.style.color = actb_self.actb_textColor;
				c.style.fontFamily = actb_self.actb_fFamily;
				c.style.fontSize = actb_self.actb_fSize;
				c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
				c.id = 'tat_td'+(j);
				c.setAttribute('pos',j);
				if (actb_self.actb_mouse){
					c.style.cursor = 'pointer';
					c.onclick=actb_mouseclick;
					c.onmouseover = actb_table_highlight;
				}
				j++;
			}
			if (j - 1 == actb_self.actb_lim && j < actb_total){
				r = a.insertRow(-1);
				r.style.backgroundColor = actb_self.actb_bgColor;
				c = r.insertCell(-1);
				c.style.color = actb_self.actb_textColor;
				c.style.fontFamily = 'arial narrow';
				c.style.fontSize = actb_self.actb_fSize;
				c.align='center';
				replaceHTML(c,'\\/');
				if (actb_self.actb_mouse){
					c.style.cursor = 'pointer';
					c.onclick = actb_mouse_down;
				}
				break;
			}
		}
		actb_rangeu = 1;
		actb_ranged = j-1;
		actb_display = true;
		if (actb_pos <= 0) actb_pos = 1;
	}
	function actb_remake(){
		document.body.removeChild(document.getElementById('tat_table'));
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
		a.style.left = curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id = 'tat_table';
		if (actb_self.actb_mouse){
			a.onmouseout= actb_table_unfocus;
			a.onmouseover=actb_table_focus;
		}
		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actb_rangeu > 1){
			r = a.insertRow(-1);
			r.style.backgroundColor = actb_self.actb_bgColor;
			c = r.insertCell(-1);
			c.style.color = actb_self.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'/\\');
			if (actb_self.actb_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actb_mouse_up;
			}
		}
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){
				if (j >= actb_rangeu && j <= actb_ranged){
					r = a.insertRow(-1);
					r.style.backgroundColor = actb_self.actb_bgColor;
					r.id = 'tat_tr'+(j);
					c = r.insertCell(-1);
					c.style.color = actb_self.actb_textColor;
					c.style.fontFamily = actb_self.actb_fFamily;
					c.style.fontSize = actb_self.actb_fSize;
					c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
					c.id = 'tat_td'+(j);
					c.setAttribute('pos',j);
					if (actb_self.actb_mouse){
						c.style.cursor = 'pointer';
						c.onclick=actb_mouseclick;
						c.onmouseover = actb_table_highlight;
					}
					j++;
				}else{
					j++;
				}
			}
			if (j > actb_ranged) break;
		}
		if (j-1 < actb_total){
			r = a.insertRow(-1);
			r.style.backgroundColor = actb_self.actb_bgColor;
			c = r.insertCell(-1);
			c.style.color = actb_self.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'\\/');
			if (actb_self.actb_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actb_mouse_down;
			}
		}
	}
	function actb_goup(){
		if (!actb_display) return;
		if (actb_pos == 1) return;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos--;
		if (actb_pos < actb_rangeu) actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_godown(){
		if (!actb_display) return;
		if (actb_pos == actb_total) return;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos++;
		if (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_movedown(){
		actb_rangeu++;
		actb_ranged++;
		actb_remake();
	}
	function actb_moveup(){
		actb_rangeu--;
		actb_ranged--;
		actb_remake();
	}

	/* Mouse */
	function actb_mouse_down(){
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos++;
		actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouse_up(evt){
		if (!evt) evt = event;
		if (evt.stopPropagation){
			evt.stopPropagation();
		}else{
			evt.cancelBubble = true;
		}
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos--;
		actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouseclick(evt){
		if (!evt) evt = event;
		if (!actb_display) return;
		actb_mouse_on_list = 0;
		actb_pos = this.getAttribute('pos');
		actb_penter();
	}
	function actb_table_focus(){
		actb_mouse_on_list = 1;
	}
	function actb_table_unfocus(){
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_table_highlight(){
		actb_mouse_on_list = 1;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos = this.getAttribute('pos');
		while (actb_pos < actb_rangeu) actb_moveup();
		while (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
	}
	/* ---- */

	function actb_insertword(a){
		if (actb_self.actb_delimiter.length > 0){
			str = '';
			l=0;
			for (i=0;i<actb_delimwords.length;i++){
				if (actb_cdelimword == i){
					prespace = postspace = '';
					gotbreak = false;
					for (j=0;j<actb_delimwords[i].length;++j){
						if (actb_delimwords[i].charAt(j) != ' '){
							gotbreak = true;
							break;
						}
						prespace += ' ';
					}
					for (j=actb_delimwords[i].length-1;j>=0;--j){
						if (actb_delimwords[i].charAt(j) != ' ') break;
						postspace += ' ';
					}
					str += prespace;
					str += a;
					l = str.length;
					if (gotbreak) str += postspace;
				}else{
					str += actb_delimwords[i];
				}
				if (i != actb_delimwords.length - 1){
					str += actb_delimchar[i];
				}
			}
			actb_curr.value = str;
			setCaret(actb_curr,l);
		}else{
			actb_curr.value = a;
		}
		actb_mouse_on_list = 0;
		actb_removedisp();
	}
	function actb_penter(){
		if (!actb_display) return;
		actb_display = false;
		var word = '';
		var c = 0;
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c == actb_pos){
				word = actb_self.actb_keywords[i];
				break;
			}
		}
		actb_insertword(word);
		l = getCaretStart(actb_curr);
	}
	function actb_removedisp(){
		if (actb_mouse_on_list==0){
			actb_display = 0;
			if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
			if (actb_toid) clearTimeout(actb_toid);
		}
	}
	function actb_keypress(e){
		if (actb_caretmove) stopEvent(e);
		return !actb_caretmove;
	}
	function actb_checkkey(evt){
		if (!evt) evt = event;
		a = evt.keyCode;
		caret_pos_start = getCaretStart(actb_curr);
		actb_caretmove = 0;
		switch (a){
			case 38:
				actb_goup();
				actb_caretmove = 1;
				return false;
				break;
			case 40:
				actb_godown();
				actb_caretmove = 1;
				return false;
				break;
			case 13: case 9:
				if (actb_display){
					actb_caretmove = 1;
					actb_penter();
					return false;
				}else{
					return true;
				}
				break;
			default:
				setTimeout(function(){actb_tocomplete(a)},50);
				break;
		}
	}

	function actb_tocomplete(kc){
		if (kc == 38 || kc == 40 || kc == 13) return;
		var i;
		if (actb_display){ 
			var word = 0;
			var c = 0;
			for (var i=0;i<=actb_self.actb_keywords.length;i++){
				if (actb_bool[i]) c++;
				if (c == actb_pos){
					word = i;
					break;
				}
			}
			actb_pre = word;
		}else{ actb_pre = -1};
		
		if (actb_curr.value == ''){
			actb_mouse_on_list = 0;
			actb_removedisp();
			return;
		}
		if (actb_self.actb_delimiter.length > 0){
			caret_pos_start = getCaretStart(actb_curr);
			caret_pos_end = getCaretEnd(actb_curr);
			
			delim_split = '';
			for (i=0;i<actb_self.actb_delimiter.length;i++){
				delim_split += actb_self.actb_delimiter[i];
			}
			delim_split = delim_split.addslashes();
			delim_split_rx = new RegExp("(["+delim_split+"])");
			c = 0;
			actb_delimwords = new Array();
			actb_delimwords[0] = '';
			for (i=0,j=actb_curr.value.length;i<actb_curr.value.length;i++,j--){
				if (actb_curr.value.substr(i,j).search(delim_split_rx) == 0){
					ma = actb_curr.value.substr(i,j).match(delim_split_rx);
					actb_delimchar[c] = ma[1];
					c++;
					actb_delimwords[c] = '';
				}else{
					actb_delimwords[c] += actb_curr.value.charAt(i);
				}
			}

			var l = 0;
			actb_cdelimword = -1;
			for (i=0;i<actb_delimwords.length;i++){
				if (caret_pos_end >= l && caret_pos_end <= l + actb_delimwords[i].length){
					actb_cdelimword = i;
				}
				l+=actb_delimwords[i].length + 1;
			}
			var ot = actb_delimwords[actb_cdelimword].trim(); 
			var t = actb_delimwords[actb_cdelimword].addslashes().trim();
		}else{
			var ot = actb_curr.value;
			var t = actb_curr.value.addslashes();
		}
		if (ot.length == 0){
			actb_mouse_on_list = 0;
			actb_removedisp();
		}
		if (ot.length < actb_self.actb_startcheck) return this;
		if (actb_self.actb_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}

		actb_total = 0;
		actb_tomake = false;
		actb_kwcount = 0;
		for (i=0;i<actb_self.actb_keywords.length;i++){
			actb_bool[i] = false;
			if (re.test(actb_self.actb_keywords[i])){
				actb_total++;
				actb_bool[i] = true;
				actb_kwcount++;
				if (actb_pre == i) actb_tomake = true;
			}
		}

		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
		actb_generate();
	}
	return this;
}


/* === mapwidget.js === */
var _ROOT_IMG_DIR_ = "/_designs/common/map_widget_images/";

function MapRegion(parent, id, formValue, name, coords) {
  
  this.id = id;
  this.formValue = formValue;
  this.name = name;
  this.coords = coords;
  this.parent = parent;
  this.__select = null;
  this.selected = false;
  this.__linkedLI = null;
  this.__linkedOpt = null;
  
  var img = document.createElement("img");
    img.setAttribute("width", "2075");
    img.setAttribute("height", "154");
    img.setAttribute("src", _ROOT_IMG_DIR_+"selects.gif");
  this.__select = img;
  this.parent.__selects.appendChild(this.__select);
  
  
  this.setLinkedLI = function(li) {
    this.__linkedLI = li;
    this.__linkedLI.onmouseover = (function(x) { return function () { return x.doRollOver() } })(this)
    this.__linkedLI.onmouseout = (function(x) { return function () { return x.doRollOut() } })(this)
    this.__linkedLI.getElementsByTagName("input")[0].onclick = (function(x) { return function () { x.toggleSelect(); } })(this)
  }
  
  this.setLinkedOption = function(opt) {
    this.__linkedOpt = opt;
    this.__linkedOpt.onclick = (function(x) { return function() { return x.toggleSelectThisOnly(); } })(this);
  }
  
  this.doRollOver = function() {
    this.parent.__hover.style.left = "-"+((this.id+1)*160+1)+"px";
    if (this.__linkedLI != null) {
      this.__linkedLI.className = "hover";
    }
    if (this.parent.__linkedTitleArea != null) { 
      this.parent.__linkedTitleArea.innerHTML = this.name;
    }
  }
  this.doRollOut = function() {
    this.parent.__hover.style.left = "0px";
    if (this.__linkedLI != null) {
      this.__linkedLI.className = "";
    }
  }
  
  this.doSelect = function() {
    this.__select.style.left = "-"+((this.id+1)*160+1)+"px";
    if (this.__linkedLI != null) {
      this.__linkedLI.getElementsByTagName("input")[0].checked = true;
    }
    this.parent.updateLinkedFormElm();
  }
  this.doUnselect = function() {
    this.__select.style.left = "0px";
    if (this.__linkedLI != null) {
      this.__linkedLI.getElementsByTagName("input")[0].checked = false;
    }
    this.parent.updateLinkedFormElm();
  }
  
  this.toggleSelectThisOnly = function() {
    this.parent.deselectAll();
    this.toggleSelect();
  }
  
  this.toggleSelect = function() {
    this.selected = !this.selected;
    if (this.selected) {
      this.doSelect();
    } else {
      this.doUnselect();
    }
    //return false;
  }
  
}

function MapWidget(Elm) {
  
  this.delimeter = " "; // delimeter used in linked form element string
  
  /* -- build self element -- */
  this.__self = Elm;
    this.__selects = document.createElement("div");
    this.__selects.className = "selects";
    this.__self.appendChild(this.__selects);
    var img = document.createElement("img");
      img.setAttribute("width", "2075");
      img.setAttribute("height", "154");
      img.setAttribute("src", _ROOT_IMG_DIR_+"hovers.gif");
    this.__hover = img;
    this.__self.appendChild(this.__hover);
      var img = document.createElement("img");
      img.setAttribute("width", "154");
      img.setAttribute("height", "154");
      img.setAttribute("src", _ROOT_IMG_DIR_+"map_blank.gif");
      img.setAttribute("usemap" , "#mwm",  0); // IE only 3rd param, work around for useMap known issue
    this.__self.appendChild(img);
    
    
    
    
  this.regions = null;
  this.__imap = null;
  this.__linkedFormElm = null;
  this.__linkedTitleArea == null;
  this.__linkedSelectBox = null;
  this.__linkedSelectBoxMulti = null;
  
  this.init = function() {
    this.regions = new Array();
    // SQUIZ can change the 3rd attribute of MapRegion to what ever is needed by the search //
        
    this.regions.push(new MapRegion(this, 3,  '9002719',  'Devonport, Cradle Mountain and the Great Western Tiers', "62,92,59,88,60,71,64,66,67,61,68,54,76,58,86,57,86,61,94,71,95,72,89,79,88,84,83,88,74,90,64,92"));
    this.regions.push(new MapRegion(this, 6,  '9002669',    'New Norfolk, Derwent Valley and Central Highlands', "63,122,62,117,62,95,68,92,78,90,85,89,88,87,90,83,90,80,93,84,95,88,97,92,97,114,98,117,94,121,90,126,85,130,70,129"));
    this.regions.push(new MapRegion(this, 7,  '9002675',  'Port Arthur, Tasman Peninsula and the South East', "110,114,109,106,116,102,118,108,124,112,125,117,122,120,126,123,126,126,124,128,125,131,126,130,126,135,120,136,116,130,116,126,117,124,116,122,112,120"));
    this.regions.push(new MapRegion(this, 9,  '9002673',  'Stanley and the North West', "40,75,35,67,35,64,33,55,30,54,33,48,33,43,34,40,35,30,41,30,40,34,36,33,36,38,34,38,34,40,34,41,38,42,40,38,44,42,40,42,44,45,44,45,51,45,51,46,57,47,68,54,66,62,60,71,53,74,48,76"));
    this.regions.push(new MapRegion(this, 1,  '9002670',     'Hobart & Surrounds', "98,120,101,117,103,116,110,116,113,123,115,126,112,128,109,129,108,128,106,129,98,125"));
    this.regions.push(new MapRegion(this, 10, '9002674',  'Strahan, Queenstown and the West Coast', "60,127,58,126,54,117,54,114,50,110,49,102,49,97,50,92,50,90,40,79,40,75,48,76,59,72,59,88,62,94,61,98,61,117,62,119,62,124"));
    this.regions.push(new MapRegion(this, 2,  '9002245',       'Coles Bay, Freycinet and the East Coast', "117,102,120,100,121,94,124,91,124,81,128,79,134,79,136,87,135,91,136,95,136,103,132,102,133,95,129,92,126,102,126,109,130,111,131,114,128,118,125,116,124,111,119,106"));
    this.regions.push(new MapRegion(this, 4,  '9002206 9002212',    'Flinders, King and other Islands', "8,21,9,15,8,13,9,9,8,6,11,3,11,0,16,4,16,11,120,11,123,8,124,4,126,4,132,12,138,13,136,15,137,24,140,29,141,33,138,33,135,31,133,36,130,36,128,32,126,30,127,27,138,26,136,24,134,22,132,22,132,24,128,25,128,18,123,15,124,12,120,11,16,11,17,16,16,16,16,18,10,22"));
    this.regions.push(new MapRegion(this, 8,  '9002677',   'Ross, Oatlands and the Midlands', "99,116,98,114,98,91,93,82,92,81,92,78,96,73,102,73,104,70,115,70,115,67,117,67,122,73,123,91,119,96,119,100,109,106,109,115"));
    this.regions.push(new MapRegion(this, 0,  '9002262',       'Huon, Bruny and the South West', "61,128,63,123,71,130,75,131,86,130,92,127,98,120,98,126,106,130,108,128,111,135,108,138,108,145,106,146,104,144,99,143,97,149,91,150,87,146,74,148,72,147,69,140,70,138,66,138"));
    this.regions.push(new MapRegion(this, 5,  '9002671', 'Launceston and Tamar Valley', "86,60,87,56,98,51,103,51,103,58,108,61,108,63,114,67,114,69,103,69,102,72,96,72"));
    this.regions.push(new MapRegion(this, 11, '9002672',   'St Helens and the North East', "103,51,108,50,111,53,113,51,116,44,122,47,124,46,126,41,136,51,136,55,134,55,135,61,136,64,134,71,136,75,135,78,124,78,122,72,117,66,114,66,108,62,108,59,104,57"));    
    
    this.createImap();
    this.createCheckList();
  }
  
  
  this.createImap = function() {
    var map = document.createElement("map");
    map.setAttribute("name", "mwm");
    map.setAttribute("id", "mwm");
    
    var area;
    //for (var ii in this.regions) {
    for (var ii=0; ii<this.regions.length; ii++) {
      area = document.createElement("area");
      area.setAttribute("alt", this.regions[ii].name);
      area.setAttribute("shape", "poly");
      area.setAttribute("coords", this.regions[ii].coords);
      area.setAttribute("href", "#");
      area.setAttribute("name", this.regions[ii].id);
      
      area.onmouseover = (function(x) { return function () { return x.doRollOver() } })(this.regions[ii])
      area.onmouseout = (function(x) { return function () { return x.doRollOut() } })(this.regions[ii])
      area.onclick = (function(x) { return function () { x.toggleSelect(); return false; } })(this.regions[ii]);
      map.appendChild(area);
    }
    this.__imap = map;
    this.__self.appendChild(this.__imap);
  }
  
  this.createCheckList = function() {
    var ul = document.createElement("ul");
    var li, label, input;
    //for (var ii in this.regions) {
    for (var ii=0; ii<this.regions.length; ii++) {
      li = document.createElement("li");
      input = document.createElement("input");
      input.setAttribute("type", "checkbox");
      input.setAttribute("id", "smcid"+ii);
        label = document.createElement("label");
        label.setAttribute("for", "smcid"+ii);
        label.innerHTML = this.regions[ii].name;
        li.appendChild(input);
        li.appendChild(label);
      ul.appendChild(li);
      this.regions[ii].setLinkedLI(li);
    }
    return ul;
  }
  
  this.linkToFormElement = function(elm) {
    this.__linkedFormElm = elm;
  }
  this.linkToTitleArea= function(elm) {
    this.__linkedTitleArea = elm;
  }
  this.updateLinkedFormElm = function() {
        if (this.__linkedFormElm == null) {
            this.updateLinkedFormElmSelect();
        } else {
            this.updateLinkedFormElmText();
        }
  }


  this.updateLinkedFormElmText = function() {
    if (this.__linkedFormElm == null) return;
    var val = "";
    //for (var ii in this.regions) {
    for (var ii=0; ii<this.regions.length; ii++) {
      if (!this.regions[ii].selected) continue;
      val += ((val != '') ? this.delimeter : '')+this.regions[ii].formValue;
    }
    this.__linkedFormElm.value = val;
  }
  
  
  this.linkToSelectBox = function(elm) {
    this.__linkedSelectBox = elm;
    var opt = null;
    
    for (var ii=0; ii<this.regions.length; ii++) {
      opt = document.createElement("option");
      opt.setAttribute("id", "smcid"+ii);
      opt.setAttribute("value", this.regions[ii].formValue);
      opt.innerHTML = this.regions[ii].name;
      this.__linkedSelectBox.appendChild(opt);
      this.regions[ii].setLinkedOption(opt);
    }
     opt = document.createElement("option");
     opt.setAttribute("id", "smcid"+"multi");
     opt.setAttribute("value", "multi");
     opt.innerHTML = "Multiple";
     this.__linkedSelectBoxMulti = opt;
     this.__linkedSelectBox.appendChild(this.__linkedSelectBoxMulti);
  }
  
  this.updateLinkedFormElmSelect = function() {
    if (this.__linkedSelectBox == null) return;
    var val = "";
    var count = 0;
    //for (var ii in this.regions) {
    for (var ii=0; ii<this.regions.length; ii++) {
      if (!this.regions[ii].selected) continue;
      count++;
      this.regions[ii].__linkedOpt.selected = true;
      val += ((val != '') ? this.delimeter : '')+this.regions[ii].formValue;
    }
    this.__linkedSelectBox.getElementsByTagName("option")[0].selected = (count == 0);
    this.__linkedSelectBoxMulti.selected = (count > 1);
    // this.__linkedSelectBoxMulti.disabled = !(this.__linkedSelectBoxMulti.selected);
    // this.__linkedSelectBox.disabled = (count > 1);
    this.__linkedSelectBoxMulti.setAttribute("value", val);
  }
  
  this.deselectAll = function() {
    for (var ii=0; ii<this.regions.length; ii++) {
      if (!this.regions[ii].selected) continue;
      this.regions[ii].toggleSelect();
    }
  }
  
  this.init();
}

/* === pagescrapers.js === */
/*
function _hbLink(a, b, c) {
  alert('hbx: '+"\n - "+a+"\n - "+b+"\n - "+c);
}
*/



/* method to link flash lightbox call, to sitewide lightbox call */
function launchLightbox(imgID) {
  LBpageAnchors[imgID].onclick();    
  // flashLightbox(img.src, img.alt); // GN think this will do the trick
}

function scrapeDealData(from) {
   try {
     var iElm = from; // input element (XHTML)
     var rElm = document.createElement("data"); // return element (XML for Flash)
     var tElm;
     var lis = iElm.getElementsByTagName("li");
     var li;
     for (var ii=0; ii<lis.length; ii++) {
       li = lis[ii];
       tElm = document.createElement("deal");
       
       if (li.getElementsByTagName("img")[0]) {
         tElm.setAttribute("imgsrc", li.getElementsByTagName("img")[0].getAttribute("src"));
       }
       if (li.getElementsByTagName("div")[0]) {
         tElm.setAttribute("title", li.getElementsByTagName("div")[0].innerHTML);
       }
       if (li.getElementsByTagName("a")[0]) {
         tElm.setAttribute("desc", li.getElementsByTagName("a")[0].innerHTML);       
         tElm.setAttribute("link", li.getElementsByTagName("a")[0].getAttribute("href"));
       }
       if (li.getElementsByTagName("var")[0]) {
         tElm.setAttribute("hbxposition", li.getElementsByTagName("var")[0].innerHTML);       
         tElm.setAttribute("hbxname", li.getElementsByTagName("var")[0].getAttribute("title"));
       }
       rElm.appendChild(tElm);
     }
          
     var temp = document.createElement("return");
     temp.appendChild(rElm);

     /* This regex is a hack for IE. If the strings passed to the above setAttribute
        functions do not contain any spaces, then IE will output the markup as:

         foo=bar

       This breaks the Flash object, which expects to see the string encapsulated
       within quotation marks. ie:

         foo="bar"

       We have to parse the final string using innerHTML and fix IE's output:
     */

     return temp.innerHTML.replace(/=(\w+)\s/gi, "=\"$1\" ");


   } catch (e) {
     // data scrape failed, return null !!!
     return null;
   }
}
 
    
function scrapePageHeader(from) {
  try {
    var iElm = from; // input element (XHTML)
    var rElm = document.createElement("header"); // return element (XML for Flash)
    
    if (iElm.getElementsByTagName("img").length == 0) return 'homepage'; // no header image supplied so fall back to animated headers
    
    rElm.setAttribute("imgsrc", iElm.getElementsByTagName("img")[0].getAttribute("src"));
    //alert(iElm.getElementsByTagName("img")[0].getAttribute("src")+'<<');
    rElm.setAttribute("photographer", iElm.getElementsByTagName("img")[0].getAttribute("alt"));
    rElm.setAttribute("title", iElm.getElementsByTagName("h2")[0].innerHTML+' ');
    if (iElm.getElementsByTagName("h2")[0].className != null && iElm.getElementsByTagName("h2")[0].className.lastIndexOf("hex_") != -1) {
      rElm.setAttribute("color", (iElm.getElementsByTagName("h2")[0].className.replace(/hex_/, '')));
    }
    
    var temp = document.createElement("return");
    temp.appendChild(rElm);
    return temp.innerHTML;
  } catch (e) {
    // data scrape failed, return null !!!
    return null;
  }
}

var LBpageAnchors = new Array();
function scrapeImageData(from) {
  try {
    var iElm = from; // input element (XHTML)
    var rElm = document.createElement("thumbs"); // return element (XML for Flash)
    
    var tElm, tImg; // tmp
    
    for (var ii=0; ii<iElm.childNodes.length; ii++) {
      tElm = document.createElement("thumb");
      
      if (iElm.childNodes[ii].nodeName != 'LI') continue; // TO DO .... use getElementsByTagName in place of this
      tImg = iElm.childNodes[ii].getElementsByTagName("img")[0];
      tElm.setAttribute("imgsrc", tImg.getAttribute("src"));
      LBpageAnchors.push(iElm.childNodes[ii].getElementsByTagName("a")[0]);
      tElm.setAttribute("link", LBpageAnchors.length-1);
      rElm.appendChild(tElm);
      
    }
    var temp = document.createElement("return");
    temp.appendChild(rElm);
    return temp.innerHTML;
  } catch (e) {
    // data scrape failed, return null !!!
    return null;
  }
}


function scrapeWeatherData(from) {
  try {
    var iElm = from; // input element (XHTML)
    var rElm = document.createElement("weather"); // return element (XML for Flash)
  
    rElm.setAttribute("date", iElm.getElementsByTagName("thead")[0].getElementsByTagName("th")[0].innerHTML);
    rElm.setAttribute("btnlink", document.getElementById("weatherLink").getAttribute("href"));
    var dElm; // tmp
    
    dElm = iElm.getElementsByTagName("tbody")[0];
    for (var ii=0; ii<4; ii++) {
      tElm = document.createElement("data");   
      tElm.setAttribute("loc", dElm.getElementsByTagName("tr")[ii].getElementsByTagName("th")[0].innerHTML);
      tElm.setAttribute("summary", dElm.getElementsByTagName("tr")[ii].getElementsByTagName("td")[0].innerHTML);
      tElm.setAttribute("min", dElm.getElementsByTagName("tr")[ii].getElementsByTagName("td")[1].innerHTML);
      tElm.setAttribute("max", dElm.getElementsByTagName("tr")[ii].getElementsByTagName("td")[2].innerHTML);
      tElm.setAttribute("imgsrc", dElm.getElementsByTagName("tr")[ii].getElementsByTagName("td")[3].getElementsByTagName("img")[0].getAttribute("src"));
      rElm.appendChild(tElm);
    }
      
    
    var temp = document.createElement("return");
    temp.appendChild(rElm);
    return temp.innerHTML;
  } catch (e) {
    // data scrape failed, return null !!!
    return null;
  }
}




function scrapeFactData(from) {
  try {
    var iElm = from; // input element (XHTML)
    var rElm = document.createElement("facts"); // return element (XML for Flash)
    
    var dElm; // tmp
    
    dElm = iElm;
    for (var ii=0; ii<4; ii++) {
      tElm = document.createElement("fact");   
      tElm.setAttribute("link", dElm.getElementsByTagName("li")[ii].getElementsByTagName("a")[0].getAttribute("href"));
      tElm.setAttribute("text", dElm.getElementsByTagName("li")[ii].getElementsByTagName("a")[0].innerHTML);
      tElm.setAttribute("hbxname", dElm.getElementsByTagName("li")[ii].getElementsByTagName("var")[0].getAttribute("title"));
      tElm.setAttribute("hbxposition", dElm.getElementsByTagName("li")[ii].getElementsByTagName("var")[0].innerHTML);
      
      rElm.appendChild(tElm);
    }
      
    
    var temp = document.createElement("return");
    temp.appendChild(rElm);
    return temp.innerHTML;
  } catch (e) {
    // data scrape failed, return null !!!
    return null;
  }
}

function scrapeTabXML(from) {
  try {
    var iElm = from; // input element (XHTML)
    var rElm = document.createElement("data"); // return element (XML for Flash)
    
    var dElm; // tmp
    
    dElm = iElm;
    
    for (var ii=0; ii<4; ii++) {
      tElm = document.createElement("tab");
      tElm.setAttribute("id", dElm.getElementsByTagName("var")[ii].getAttribute("id")+' ');
      tElm.setAttribute("pos", dElm.getElementsByTagName("var")[ii].innerHTML);
      tElm.setAttribute("title", dElm.getElementsByTagName("var")[ii].getAttribute("title"));
      rElm.appendChild(tElm);
    }
    
    var temp = document.createElement("return");
    temp.appendChild(rElm);
    return temp.innerHTML;
  } catch (e) {
    return null;
  }
}



/* === swfobject.js === */
/**
 * SWFObject v1.4.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){return q.substring(q.indexOf("=",_2d)+1,_2e);}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){
var _2f=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2f.length;i++){
for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=null;}}}};
if(typeof window.onunload=="function"){
var oldunload=window.onunload;
window.onunload=function(){deconcept.SWFObjectUtil.cleanupSWFs();oldunload();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}
if(Array.prototype.push==null){
Array.prototype.push=function(_32){
this[this.length]=_32;
return this.length;};}

var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for backwards compatibility
var SWFObject = deconcept.SWFObject;

