/**********************************
Title: RACQ SCRIPTS
Function: Extending jquery
Author: Warren Prasek
Date: 25 Nov 2009
Version: 1.0a
**********************************/



/**********************************
RESTORE DEFAULT FORM INPUT VALUES by  Rob Schmitt - webdeveloper.beforeseven.com
**********************************/

/*** Editable vars */
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#aaa'; // Colour of default text

/*** Do not edit below this line */
$(document).ready(function() {
  $("input.default-value").css("color", inactive_color);
  var default_values = new Array();
  $("input.default-value").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });
  if($('#nav-1 li')[0] != null){$('#nav-1 li')[0].className = $('#nav-1 li')[0].className + ' first-child';}
  applyHovers();
  if($('#introRHS')[0]!=null){
     if($('#introRHS')[0].innerHTML.length < 2){$('#introRHS')[0].style.display='none';};
  }
  applyImgClasses();
  $("a.anchorLink").anchorAnimate();
  $("input.anchorLink").anchorAnimateInput();
  //Fix IE6 bug on panel hovers
  $('#productPanels li img').after('<span class=\"hide\">&nbsp;</span>');
  $('#productPanelsAlt li img').after('<span class=\"hide\">&nbsp;</span>');
});


/**********************************
ADD CLASS TO LAST MENU LIST ITEM
**********************************/
$(document).ready(function() {
  var menuUls = $("ul.top_nav_sub");
  for(var i=0;i<menuUls.length;i++){
     var childLis = menuUls[i].getElementsByTagName('li'); 
     childLis[childLis.length-1].className = 'lastItem';
  }
});


/**********************************
SIMPLE IMAGE ROLLOVER
by Brad Harris - Selfcontained.us
--> modded by 'Don' for xhtml compliance
--> image must have class "hover"
--> image filenames must be in format blah_std.xxx and blah_ovr.xxx
**********************************/
$('img.hover').hover(
	function() {
		$(this).attr('src', $(this).attr('src').replace( /-std/i, '-ovr' ));
	alert('rollover');
	}, 
	function() {
		$(this).attr('src', $(this).attr('src').replace( /-ovr/i, '-std' ));
});






/*************************************
DYNAMIC TEXT RESIZE
shopdev.co.uk
*************************************/

$(document).ready(function(){
  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    $('html').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
    $('html').css('font-size', newFontSize);
    return false;
  });
});


/********************************************************************************/
// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
// (c) 2008-2009 Angus Turnbull http://www.twinhelix.com

// This is licensed under the GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

var IEPNGFix = window.IEPNGFix || {};

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			elm: elm,
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = Math.max(0, xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = Math.max(0, yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = (xPos - parseInt(elm.currentStyle.paddingLeft)) + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};


IEPNGFix.update = function() {
	// Update all PNG backgrounds.
	for (var i in IEPNGFix.data) {
		var t = IEPNGFix.data[i].tiles;
		if (t && t.elm && t.src) {
			IEPNGFix.tileBG(t.elm, t.src);
		}
	}
};
IEPNGFix.update.timer = 0;

if (window.attachEvent && !window.opera) {
	window.attachEvent('onresize', function() {
		clearTimeout(IEPNGFix.update.timer);
		IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
	});
}



/************************* SWFOBJECT MOD ************************************/

/*!	SWFObject v2.0 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

var swfobject = function() {
	
	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",
		
		win = window,
		doc = document,
		nav = navigator,
		
		domLoadFnArr = [],
		regObjArr = [],
		timer = null,
		storedAltContent = null,
		storedAltContentId = null,
		isDomLoaded = false,
		isExpressInstallActive = false;
	
	/* Centralized function for browser feature detection
		- Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
		- User agent string detection is only used when no alternative is possible
		- Is executed directly for optimal performance
	*/	
	var ua = function() {
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF && typeof doc.appendChild != UNDEF && typeof doc.replaceChild != UNDEF && typeof doc.removeChild != UNDEF && typeof doc.cloneNode != UNDEF,
			playerVersion = [0,0,0],
			d = null;
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d) {
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try { 
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";  // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");  // Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}
		var u = nav.userAgent.toLowerCase(),
			p = nav.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = false,
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);
		/*@cc_on
			ie = true;
			@if (@_win32)
				windows = true;
			@elif (@_mac)
				mac = true;
			@end
		@*/
		return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
	}();

	/* Cross-browser onDomLoad
		- Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
		- Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
	*/ 
	var onDomLoad = function() {
		if (!ua.w3cdom) {
			return;
		}
		addDomLoadEvent(main);
		if (ua.ie && ua.win) {
			try {  // Avoid a possible Operation Aborted error
				doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors 
				var s = getElementById("__ie_ondomload");
				if (s) {
					s.onreadystatechange = function() {
						if (this.readyState == "complete") {
							this.parentNode.removeChild(this);
							callDomLoadFunctions();
						}
					};
				}
			}
			catch(e) {}
		}
		if (ua.webkit && typeof doc.readyState != UNDEF) {
			timer = setInterval(function() { if (/loaded|complete/.test(doc.readyState)) { callDomLoadFunctions(); }}, 10);
		}
		if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
		}
		addLoadEvent(callDomLoadFunctions);
	}();
	
	function callDomLoadFunctions() {
		if (isDomLoaded) {
			return;
		}
		if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
			var s = createElement("span");
			try { // Avoid a possible Operation Aborted error
				var t = doc.getElementsByTagName("body")[0].appendChild(s);
				t.parentNode.removeChild(t);
			}
			catch (e) {
				return;
			}
		}
		isDomLoaded = true;
		if (timer) {
			clearInterval(timer);
			timer = null;
		}
		var dl = domLoadFnArr.length;
		for (var i = 0; i < dl; i++) {
			domLoadFnArr[i]();
		}
	}
	
	function addDomLoadEvent(fn) {
		if (isDomLoaded) {
			fn();
		}
		else { 
			domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
		}
	}
	
	/* Cross-browser onload
		- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
		- Will fire an event as soon as a web page including all of its assets are loaded 
	 */
	function addLoadEvent(fn) {
		if (typeof win.addEventListener != UNDEF) {
			win.addEventListener("load", fn, false);
		}
		else if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("load", fn, false);
		}
		else if (typeof win.attachEvent != UNDEF) {
			win.attachEvent("onload", fn);
		}
		else if (typeof win.onload == "function") {
			var fnOld = win.onload;
			win.onload = function() {
				fnOld();
				fn();
			};
		}
		else {
			win.onload = fn;
		}
	}
	
	/* Main function
		- Will preferably execute onDomLoad, otherwise onload (as a fallback)
	*/
	function main() { // Static publishing only
		var rl = regObjArr.length;
		for (var i = 0; i < rl; i++) { // For each registered object element
			var id = regObjArr[i].id;
			if (ua.pv[0] > 0) {
				var obj = getElementById(id);
				if (obj) {
					regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
					regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
					if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
						if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements
							fixParams(obj);
						}
						setVisibility(id, true);
					}
					else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
						showExpressInstall(regObjArr[i]);
					}
					else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
						displayAltContent(obj);
					}
				}
			}
			else {  // If no fp is installed, we let the object element do its job (show alternative content)
				setVisibility(id, true);
			}
		}
	}
	
	/* Fix nested param elements, which are ignored by older webkit engines
		- This includes Safari up to and including version 1.2.2 on Mac OS 10.3
		- Fall back to the proprietary embed element
	*/
	function fixParams(obj) {
		var nestedObj = obj.getElementsByTagName(OBJECT)[0];
		if (nestedObj) {
			var e = createElement("embed"), a = nestedObj.attributes;
			if (a) {
				var al = a.length;
				for (var i = 0; i < al; i++) {
					if (a[i].nodeName.toLowerCase() == "data") {
						e.setAttribute("src", a[i].nodeValue);
					}
					else {
						e.setAttribute(a[i].nodeName, a[i].nodeValue);
					}
				}
			}
			var c = nestedObj.childNodes;
			if (c) {
				var cl = c.length;
				for (var j = 0; j < cl; j++) {
					if (c[j].nodeType == 1 && c[j].nodeName.toLowerCase() == "param") {
						e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
					}
				}
			}
			obj.parentNode.replaceChild(e, obj);
		}
	}
	
	/* Fix hanging audio/video threads and force open sockets and NetConnections to disconnect
		- Occurs when unloading a web page in IE using fp8+ and innerHTML/outerHTML
		- Dynamic publishing only
	*/
	function fixObjectLeaks(id) {
		if (ua.ie && ua.win && hasPlayerVersion("8.0.0")) {
			win.attachEvent("onunload", function () {
				var obj = getElementById(id);
				if (obj) {
					for (var i in obj) {
						if (typeof obj[i] == "function") {
							obj[i] = function() {};
						}
					}
					obj.parentNode.removeChild(obj);
				}
			});
		}
	}
	
	/* Show the Adobe Express Install dialog
		- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
	*/
	function showExpressInstall(regObj) {
		isExpressInstallActive = true;
		var obj = getElementById(regObj.id);
		if (obj) {
			if (regObj.altContentId) {
				var ac = getElementById(regObj.altContentId);
				if (ac) {
					storedAltContent = ac;
					storedAltContentId = regObj.altContentId;
				}
			}
			else {
				storedAltContent = abstractAltContent(obj);
			}
			if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
				regObj.width = "310";
			}
			if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
				regObj.height = "137";
			}
			doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
			var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
				dt = doc.title,
				fv = "MMredirectURL=" + win.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt,
				replaceId = regObj.id;
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			if (ua.ie && ua.win && obj.readyState != 4) {
				var newObj = createElement("div");
				replaceId += "SWFObjectNew";
				newObj.setAttribute("id", replaceId);
				obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
				obj.style.display = "none";
				win.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
			}
			createSWF({ data:regObj.expressInstall, id:EXPRESS_INSTALL_ID, width:regObj.width, height:regObj.height }, { flashvars:fv }, replaceId);
		}
	}
	
	/* Functions to abstract and display alternative content
	*/
	function displayAltContent(obj) {
		if (ua.ie && ua.win && obj.readyState != 4) {
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			var el = createElement("div");
			obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
			el.parentNode.replaceChild(abstractAltContent(obj), el);
			obj.style.display = "none";
			win.attachEvent("onload", function() { obj.parentNode.removeChild(obj); });
		}
		else {
			obj.parentNode.replaceChild(abstractAltContent(obj), obj);
		}
	}	

	function abstractAltContent(obj) {
		var ac = createElement("div");
		if (ua.win && ua.ie) {
			ac.innerHTML = obj.innerHTML;
		}
		else {
			var nestedObj = obj.getElementsByTagName(OBJECT)[0];
			if (nestedObj) {
				var c = nestedObj.childNodes;
				if (c) {
					var cl = c.length;
					for (var i = 0; i < cl; i++) {
						if (!(c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param") && !(c[i].nodeType == 8)) {
							ac.appendChild(c[i].cloneNode(true));
						}
					}
				}
			}
		}
		return ac;
	}
	
	/* Cross-browser dynamic SWF creation
	*/
	function createSWF(attObj, parObj, id) {
		var r, el = getElementById(id);
		if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
			attObj.id = id;
		}
		if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
			var att = "";
			for (var i in attObj) {
				if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
					if (i == "data") {
						parObj.movie = attObj[i];
					}
					else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						att += ' class="' + attObj[i] + '"';
					}
					else if (i != "classid") {
						att += ' ' + i + '="' + attObj[i] + '"';
					}
				}
			}
			var par = "";
			for (var j in parObj) {
				if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
					par += '<param name="' + j + '" value="' + parObj[j] + '" />';
				}
			}
			el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
			fixObjectLeaks(attObj.id); // This bug affects dynamic publishing only
			r = getElementById(attObj.id);	
		}
		else if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
			var e = createElement("embed");
			e.setAttribute("type", FLASH_MIME_TYPE);
			for (var k in attObj) {
				if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
					if (k == "data") {
						e.setAttribute("src", attObj[k]);
					}
					else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						e.setAttribute("class", attObj[k]);
					}
					else if (k != "classid") { // Filter out IE specific attribute
						e.setAttribute(k, attObj[k]);
					}
				}
			}
			for (var l in parObj) {
				if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
					if (l != "movie") { // Filter out IE specific param element
						e.setAttribute(l, parObj[l]);
					}
				}
			}
			el.parentNode.replaceChild(e, el);
			r = e;
		}
		else { // Well-behaving browsers
			var o = createElement(OBJECT);
			o.setAttribute("type", FLASH_MIME_TYPE);
			for (var m in attObj) {
				if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
					if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						o.setAttribute("class", attObj[m]);
					}
					else if (m != "classid") { // Filter out IE specific attribute
						o.setAttribute(m, attObj[m]);
					}
				}
			}
			for (var n in parObj) {
				if (parObj[n] != Object.prototype[n] && n != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
					createObjParam(o, n, parObj[n]);
				}
			}
			el.parentNode.replaceChild(o, el);
			r = o;
		}
		return r;
	}
	
	function createObjParam(el, pName, pValue) {
		var p = createElement("param");
		p.setAttribute("name", pName);	
		p.setAttribute("value", pValue);
		el.appendChild(p);
	}
	
	function getElementById(id) {
		return doc.getElementById(id);
	}
	
	function createElement(el) {
		return doc.createElement(el);
	}
	
	function hasPlayerVersion(rv) {
		var pv = ua.pv, v = rv.split(".");
		v[0] = parseInt(v[0], 10);
		v[1] = parseInt(v[1], 10);
		v[2] = parseInt(v[2], 10);
		return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
	}
	
	/* Cross-browser dynamic CSS creation
		- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
	*/	
	function createCSS(sel, decl) {
		if (ua.ie && ua.mac) {
			return;
		}
		var h = doc.getElementsByTagName("head")[0], s = createElement("style");
		s.setAttribute("type", "text/css");
		s.setAttribute("media", "screen");
		if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
			s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
		}
		h.appendChild(s);
		if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
			var ls = doc.styleSheets[doc.styleSheets.length - 1];
			if (typeof ls.addRule == OBJECT) {
				ls.addRule(sel, decl);
			}
		}
	}
	
	function setVisibility(id, isVisible) {
		var v = isVisible ? "visible" : "hidden";
		if (isDomLoaded) {
			getElementById(id).style.visibility = v;
		}
		else {
			createCSS("#" + id, "visibility:" + v);
		}
	}
	
	function getTargetVersion(obj) {
	    if (!obj)
	        return 0;
		var c = obj.childNodes;
		var cl = c.length;
		for (var i = 0; i < cl; i++) {
			if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "object") {
			    c = c[i].childNodes;
			    cl = c.length;
			    i = 0;
			}     
			if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param" && c[i].getAttribute("name") == "swfversion") {
			   return c[i].getAttribute("value"); 
			}
		}
		return 0;
	}
    
	function getExpressInstall(obj) {
	    if (!obj)
	        return "";
		var c = obj.childNodes;
		var cl = c.length;
		for (var i = 0; i < cl; i++) {
			if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "object") {
			    c = c[i].childNodes;
			    cl = c.length;
			    i = 0;
			}     
			if (c[i].nodeType == 1 && c[i].nodeName.toLowerCase() == "param" && c[i].getAttribute("name") == "expressinstall") { 
			    return c[i].getAttribute("value"); 
			}	       
		}
		return "";
	}
    
	return {
		/* Public API
			- Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
		*/ 
		registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
			if (!ua.w3cdom || !objectIdStr) {
				return;
			}
			var obj = document.getElementById(objectIdStr);
			var xi = getExpressInstall(obj);
			var regObj = {};
			regObj.id = objectIdStr;
			regObj.swfVersion = swfVersionStr ? swfVersionStr : getTargetVersion(obj);
			regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : ((xi != "") ? xi : false);
			regObjArr[regObjArr.length] = regObj;
			setVisibility(objectIdStr, false);
		},
		
		getObjectById: function(objectIdStr) {
			var r = null;
			if (ua.w3cdom && isDomLoaded) {
				var o = getElementById(objectIdStr);
				if (o) {
					var n = o.getElementsByTagName(OBJECT)[0];
					if (!n || (n && typeof o.SetVariable != UNDEF)) {
				    	r = o;
					}
					else if (typeof n.SetVariable != UNDEF) {
						r = n;
					}
				}
			}
			return r;
		},
		
		embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
			if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
				return;
			}
			widthStr += ""; // Auto-convert to string to make it idiot proof
			heightStr += "";
			if (hasPlayerVersion(swfVersionStr)) {
				setVisibility(replaceElemIdStr, false);
				var att = (typeof attObj == OBJECT) ? attObj : {};
				att.data = swfUrlStr;
				att.width = widthStr;
				att.height = heightStr;
				var par = (typeof parObj == OBJECT) ? parObj : {};
				if (typeof flashvarsObj == OBJECT) {
					for (var i in flashvarsObj) {
						if (flashvarsObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
							if (typeof par.flashvars != UNDEF) {
								par.flashvars += "&" + i + "=" + flashvarsObj[i];
							}
							else {
								par.flashvars = i + "=" + flashvarsObj[i];
							}
						}
					}
				}
				addDomLoadEvent(function() {
					createSWF(att, par, replaceElemIdStr);
					if (att.id == replaceElemIdStr) {
						setVisibility(replaceElemIdStr, true);
					}
				});
			}
			else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) {
				setVisibility(replaceElemIdStr, false);
				addDomLoadEvent(function() {
					var regObj = {};
					regObj.id = regObj.altContentId = replaceElemIdStr;
					regObj.width = widthStr;
					regObj.height = heightStr;
					regObj.expressInstall = xiSwfUrlStr;
					showExpressInstall(regObj);
				});
			}
		},
		
		getFlashPlayerVersion: function() {
			return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
		},
		
		hasFlashPlayerVersion:hasPlayerVersion,
		
		createSWF: function(attObj, parObj, replaceElemIdStr) {
			if (ua.w3cdom && isDomLoaded) {
				return createSWF(attObj, parObj, replaceElemIdStr);
			}
			else {
				return undefined;
			}
		},
		
		createCSS: function(sel, decl) {
			if (ua.w3cdom) {
				createCSS(sel, decl);
			}
		},
		
		addDomLoadEvent:addDomLoadEvent,
		
		addLoadEvent:addLoadEvent,
		
		getQueryParamValue: function(param) {
			var q = doc.location.search || doc.location.hash;
			if (param == null) {
				return q;
			}
		 	if(q) {
				var pairs = q.substring(1).split("&");
				for (var i = 0; i < pairs.length; i++) {
					if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
						return pairs[i].substring((pairs[i].indexOf("=") + 1));
					}
				}
			}
			return "";
		},
		
		// For internal usage only
		expressInstallCallback: function() {
			if (isExpressInstallActive && storedAltContent) {
				var obj = getElementById(EXPRESS_INSTALL_ID);
				if (obj) {
					obj.parentNode.replaceChild(storedAltContent, obj);
					if (storedAltContentId) {
						setVisibility(storedAltContentId, true);
						if (ua.ie && ua.win) {
							storedAltContent.style.display = "block";
						}
					}
					storedAltContent = null;
					storedAltContentId = null;
					isExpressInstallActive = false;
				}
			} 
		}
		
	};
	
	
	


/********************** HOVER INTENT FOR SUPERFISH **************************/
(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);

/************************* END HOVERINTENT **********************************/

/**************************** BGIFRAME JQUERY FOR SUPERFISH ******************/
/* fixes z-index problems with SELECT dropdowns in IE6 - must be called on document ready */
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-06-19 20:25:28 -0500 (Tue, 19 Jun 2007) $
 * $Rev: 2111 $
 *
 * Version 2.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&parseInt($.browser.version)<=6){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};if(!$.browser.version)$.browser.version=navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1];})(jQuery);
}



/********* TOGGLE ITEM VISIBILITY *************/
function toggle(whichItem){
	obj = document.getElementById(whichItem);
	
	if(obj.style.display == 'none'){
		obj.style.display = '';
	}else{
		obj.style.display = 'none';
	}
}


/********* SHOW OR HIDE ITEMS *************/
function show(whichItem){
	obj = document.getElementById(whichItem);
	obj.style.display = '';
}

function hide(whichItem){
	obj = document.getElementById(whichItem);
	obj.style.display = 'none';
}

function hideAllSublinks(){
	hide('task1sublinks');
	hide('task2sublinks');
	hide('task3sublinks');
	hide('task4sublinks');
	}
	
function hideAllPanelLinks(){
	hide('panel1links');
	hide('panel2links');
	hide('panel3links');
	hide('panel4links');
	hide('panel5links');
	hide('panel6links');
	}
	
function hideAllPanelAltLinks(){
	hide('panelAlt1links');
	hide('panelAlt2links');
	hide('panelAlt3links');
	}



/********* CHANGE CLASS *************/
function setClass(whichItem, whichClass){
	obj = document.getElementById(whichItem);
	obj.className = whichClass;
}


/********* TOGGLE RHS PANEL VISIBILITY *************/
function togglePanel(whichItem){
	toggle(whichItem);
	obj = document.getElementById(whichItem);
	objHdr = (whichItem + "Hdr");
	
	if(obj.style.display == 'none'){
		setClass(objHdr,'off');
	}else{
		setClass(objHdr,'on');
	}
}

/* selectOpen opens a window loading the page specified by a parameter passed from a select list */
function selectOpen(thelink)
{
window.open(thelink, 'quotewindow','toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,width=1024,height=600');
         return false;
}


/* scrolltotop moves the screen position to the top left corner of the page 
   This is benificial for i frame navigation
   use onload="scrolltotop(x,y)" in iframe to keep the page from displaying blank
   content at in the middle of a large i-frame. 
*/
var scrollRun = false;
	
function scrolltotop(xpos,ypos)
{
         if (scrollRun) // No need to scroll on the first load
                  window.scrollTo(xpos,ypos);
         scrollRun = true; // Force Scrolling after the first run
}

function openRedirector(siteId, extraParams) {
         // build the url to open
         var redirectUrl = "http://www2.racq.com.au/apps/redirect/redirect.cfm?siteid=" + siteId; 
         // if we have extra params, then append those
         if (extraParams) {
                  redirectUrl += "&" + extraParams;
         } // if
         // open the new window
         var newWindow = window.open(redirectUrl, "onlineservices", "height=600,width=800,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no"); 
         // if we opened the new window, then set focus to it
         if (newWindow) {
                  newWindow.focus();
         } // if
} // openRedirector

function openPopup(url){
// open the new window
    var newWindow = window.open(url, "onlineservices", "height=800,width=1024,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no"); 
    // if we opened the new window, then set focus to it
    if (newWindow) {
        newWindow.focus();
    } // if
}

function openPopupFull(url){
// open the new window
    var newWindow = window.open(url, "onlineservices", "height=800,width=1024,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes"); 
    // if we opened the new window, then set focus to it
    if (newWindow) {
        newWindow.focus();
    } // if
}

/********* BARTS ADDED SCRIPTS *************/
//Resize iframe size
function calcHeight(theObjId){
  //find the height of the internal page
  var the_height=document.getElementById(theObjId).contentWindow.document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById(theObjId).height=the_height;
}
function runAdditionalFunctions(){
// Apply ID to last sub nav list item in left menu
   if(document.getElementById('nav-2')!=null){
      var lis = document.getElementById('nav-2').getElementsByTagName('li');
      lis[lis.length-1].id='lastSubnavLink';
   }

// Convert any span tags with convertDate in them to custom date format
   var dates = $('span.convertDate'); 
   var months = new Array(" ","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
   for(var i=0;i<dates.length;i++){
      var theDate = dates[i].innerHTML.split('/');
      dates[i].innerHTML = months[parseInt(theDate[1],10)] + ' ' + parseInt(theDate[0],10) + ':';
   }
   var dates2 = $('span.convertDate2'); 
   for(var i=0;i<dates2.length;i++){
      var theDate2 = dates2[i].innerHTML.split('/');
      dates2[i].innerHTML = parseInt(theDate2[0],10) + ' ' + months[parseInt(theDate2[1],10)] + ' ' + theDate2[2];
   }
}

//function for swapping tabs between fuel prices on homepage
function swapPrices(theObject){
   $("li#current")[0].id="";
   theObject.id="current";
}
//apply mouse hovering js show and hide effects
function applyHovers(){
   var hoverPanels = $('li.panel-hover');
   for(var i=0;i<hoverPanels.length;i++){
      hoverPanels[i].onmouseover = function(){this.className='open'};
      hoverPanels[i].onmouseout =  function(){this.className=''};
   }
}
//Pop up window event
//function windowOpen(thelink){
//   window.open(thelink, 'quotewindow','toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=0,width=1024,height=600'); 
//   return false;
//}

//Pop up window event
function windowOpen(thelink){
var rexp = /^http\:\/\/(www|cms)/;
   if (rexp.test(thelink))
   {
	   window.location = thelink;
   }
   else
   {
	   window.open(thelink, 'quotewindow','toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=0,width=1024,height=600'); 
	   return false;
   }
}

//Applies classes to images within normal content pages
function applyImgClasses(){
   $('#default-content img').each(function(i){
      this.style.border='';
      if(this.align == 'right'){
         this.className = 'float-right';
      }else if(this.align == 'left'){
         this.className = 'float-left';
      }
   });
}



/**********	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
*****/


jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

jQuery.fn.anchorAnimateInput = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("alt")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

/********** Greg Roberts - Membership Selector Functions May 2011   ***/

function changeClass(obj) {

var labelID = "" + obj.id;
var labelID2 = "";

   if (labelID.indexOf('_1') != '-1') {  
      labelID2 = labelID.replace("_1", "");
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
   }
   else {  
      labelID2 = labelID + "_1";
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
   }   
}

function changeClassMultiList(obj) {

var labelID = "" + obj.id;
var labelID2 = "";
var labelID3 = "";
var labelID4 = "";
var labelID5 = "";

   if (labelID.indexOf('_1') != '-1') {  
      labelID2 = labelID.replace("_1", "");
      labelID3 = labelID.replace("_1", "_2");
      labelID4 = labelID.replace("_1", "_3");
      labelID5 = labelID.replace("_1", "_4");
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
      $('label[for=' + labelID3 + ']').removeClass();
      $('label[for=' + labelID3 + ']').addClass('blackText');
      $('label[for=' + labelID4 + ']').removeClass();
      $('label[for=' + labelID4 + ']').addClass('blackText');
      $('label[for=' + labelID5 + ']').removeClass();
      $('label[for=' + labelID5 + ']').addClass('blackText');
   }
   if (labelID.indexOf('_2') != '-1') {  
      labelID2 = labelID.replace("_2", "");
      labelID3 = labelID.replace("_2", "_1");
      labelID4 = labelID.replace("_2", "_3");
      labelID5 = labelID.replace("_2", "_4");
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
      $('label[for=' + labelID3 + ']').removeClass();
      $('label[for=' + labelID3 + ']').addClass('blackText');
      $('label[for=' + labelID4 + ']').removeClass();
      $('label[for=' + labelID4 + ']').addClass('blackText');
      $('label[for=' + labelID5 + ']').removeClass();
      $('label[for=' + labelID5 + ']').addClass('blackText');
   }
   if (labelID.indexOf('_3') != '-1') {  
      labelID2 = labelID.replace("_3", "");
      labelID3 = labelID.replace("_3", "_1");
      labelID4 = labelID.replace("_3", "_2");
      labelID5 = labelID.replace("_3", "_4");
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
      $('label[for=' + labelID3 + ']').removeClass();
      $('label[for=' + labelID3 + ']').addClass('blackText');
      $('label[for=' + labelID4 + ']').removeClass();
      $('label[for=' + labelID4 + ']').addClass('blackText');
      $('label[for=' + labelID5 + ']').removeClass();
      $('label[for=' + labelID5 + ']').addClass('blackText');
   }
   if (labelID.indexOf('_4') != '-1') {  
      labelID2 = labelID.replace("_4", "");
      labelID3 = labelID.replace("_4", "_1");
      labelID4 = labelID.replace("_4", "_2");
      labelID5 = labelID.replace("_4", "_3");
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
      $('label[for=' + labelID3 + ']').removeClass();
      $('label[for=' + labelID3 + ']').addClass('blackText');
      $('label[for=' + labelID4 + ']').removeClass();
      $('label[for=' + labelID4 + ']').addClass('blackText');
      $('label[for=' + labelID5 + ']').removeClass();
      $('label[for=' + labelID5 + ']').addClass('blackText');
   }
   else {  
      labelID2 = labelID + "_1";
      labelID3 = labelID + "_2";
      labelID4 = labelID + "_3";
      labelID5 = labelID + "_4";
      $('label[for=' + labelID + ']').removeClass();
      $('label[for=' + labelID + ']').addClass('orangeText'); 
      $('label[for=' + labelID2 + ']').removeClass();
      $('label[for=' + labelID2 + ']').addClass('blackText');
      $('label[for=' + labelID3 + ']').removeClass();
      $('label[for=' + labelID3 + ']').addClass('blackText');
      $('label[for=' + labelID4 + ']').removeClass();
      $('label[for=' + labelID4 + ']').addClass('blackText');
      $('label[for=' + labelID5 + ']').removeClass();
      $('label[for=' + labelID5 + ']').addClass('blackText');
   } 
}

function showFeedback (membershipSelected) {

   if (flag== '0') {
      
      var targetURL = 'http://www.racq.com.au/membership/membership_selector/content_feedback?membership=' + membershipSelected;
      document.getElementById('info_helpful').style.display = 'block'; 
      document.getElementById('feedbackFrame').src = targetURL;
      flag = 1;
      
      $("document").ready(function() {
      $('html, body').animate({
         scrollTop: $(".productDone").offset().top
         }, 2000);				   
      });
   }
}

function hideFeedback (anchorLink) {

   if (anchorLink != '1') {
  
      var anchorString = "." + anchorLink;   

      $("document").ready(function() {
         $('html, body').animate({
            scrollTop: $(anchorString).offset().top
         }, 2000);				   
      });
   }
   
   if (flag == '1') {
   
      document.getElementById('info_helpful').style.display = 'none'; 
      flag = 0;
   }
}

function resetSelector () {

   $('label[for=q65384]').removeClass();
   $('label[for=q65384]').addClass('blackText'); 
   $('label[for=q65384_1]').removeClass();
   $('label[for=q65384_1]').addClass('blackText');
   
   if (flag == '1') {
      document.getElementById('info_helpful').style.display = 'none'; 
      flag = 0;
   }
}

function anchorLinkage (anchorLink) {

   var anchorString = "." + anchorLink;   

      $("document").ready(function() {
         $('html, body').animate({
            scrollTop: $(anchorString).offset().top
         }, 2000);				   
      });
}


<!-- START LOAN CALCULATOR -->

function openLoanCalculator (triggerDivId) {


      if (document.getElementById('loanAmount').value.indexOf('Amount') != -1) {
         document.getElementById('loanAmount').value = '';
      }
      if (document.getElementById('loanRate').value.indexOf('Rate') != -1) {
         document.getElementById('loanRate').value = '';
      }
      document.getElementById('loanCalculatorRHS').style.height = '318px';
      document.getElementById('loanCalculatorDisplayPanel').style.display = 'block';

}

function roundTo2Decimals(n) {
	nStr = Math.round(n * 100) / 100;

	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
         if (x2.length < 3) {
            x2 = x2 + '0';
         }
	return x1 + x2;
	 
}

function isNumeric(object) {
	var strString = object.value;
	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;

	if (strString.length == 0 || strString.indexOf('Enter') != -1) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}

	if (blnResult == false) {
		object.style.color = "#FF0000";
	} else {
		object.style.color = "#000000";
	}

	checkAmount();
}

function loanCalculate() {
	var P = document.getElementById('loanAmount').value;
         P = P.replace(/,/gi, "");
         P = parseFloat(P);
         	var rate = parseFloat(document.getElementById('loanRate').value)/100;
	var RPA = parseFloat(document.getElementById('loanFrequency').value);
	var term = parseFloat(document.getElementById('loanTerm').value);
	var base = 1 + (rate / RPA);
	var exponent = -1 * (RPA * term);
	var Repayments = P * (rate / RPA) / (1 - Math.pow(base, exponent));
	var total = Repayments * RPA * term;

         	if (document.getElementById('loanAmount').value == "" || document.getElementById('loanRate').value == "" || (document.getElementById('loanRate').value).indexOf('Enter') != -1) {
		document.getElementById('monthlyRepayment').innerHTML = "$0";
		document.getElementById('totalRepayment').innerHTML = "$0";
	} else {
		document.getElementById('monthlyRepayment').innerHTML = "$" + roundTo2Decimals(Repayments);
		document.getElementById('totalRepayment').innerHTML = "$" + roundTo2Decimals(total);
	}
}

function roundTo2Decimals(n) {
	nStr = Math.round(n * 100) / 100;

	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
         if (x2.length < 3) {
            x2 = x2 + '0';
         }
	return x1 + x2;

}
function checkAmount() {
	var amount = document.getElementById("loanAmount").value;
	if (amount < 5000) {
		document.getElementById("loanAmount").style.color="#FF0000";
	} else {
		document.getElementById("loanAmount").style.clor="#000000";
	}
}
function changeRepaymentText() {
	if (document.getElementById('loanFrequency').value == "12") {
		document.getElementById('repaymentText').innerHTML = "Monthly Repayments";
	} else {
		document.getElementById('repaymentText').innerHTML = "Fortnightly Repayments";
	}
}



function setMonthly() {

	document.getElementById("paymentFrequency").value="12";
	document.getElementById("monthlyPayments").innerHTML = r2(document.getElementById("hidden_payments").value);
	recalculate();
	recalculate();
	return false;
}
function setFortnightly() {

	document.getElementById("paymentFrequency").value="26";
	recalculate();
	recalculate();
	return false;
}
function calculateNow() {


	if ((document.getElementById("loanAmount").value != '') && (document.getElementById("interestRate").value != '')) {

	if (document.all==false) {
            setMonthly(); /*This causes an error if using IE for some reason*/
	} else {
            document.getElementById("paymentFrequency").value="12";
            document.getElementById("monthlyPayments").innerHTML = 0;
            document.getElementById("hidden_duration").value = 0;
            document.getElementById("hidden_repayments").value = 0;
        }
	var PV = document.getElementById("loanAmount").value;
	var pf = parseFloat(paymentFrequency());
	var I = parseFloat(document.getElementById("interestRate").value) / (pf*100);
	var m = 0; var n = parseInt(document.getElementById("loanDuration").value);
	var result = calculate_payment(PV, I, n); document.getElementById("totalRepayments").innerHTML = "$" + r2(result * (n*pf));
	document.getElementById("monthlyPayments").innerHTML = r2(result);
	document.getElementById("hidden_duration").value = n;
	document.getElementById("hidden_repayments").value = r2(result * (n*pf));
	document.getElementById("hidden_payments").value = result;
	document.getElementById("hidden_fort_payments").value = (result / 2);
        recalculate();
        recalculate();
        changeFreq();
	return false;
	}
}
function calculate_duration(PV, I, m) {
	var divisor;
	var numerator;
	var denominator;
	if (paymentFrequency()==12) {
		divisor = 12;
	} else {
		divisor = 26;
	}
	numerator = Math.log(1/(1-((PV*I)/m)));
	denominator = Math.log(1+I);
	return ((numerator/denominator)/divisor);
}
function calculate_payment(PV, I, n) {
	var part1 = 1 + I;
	var part2 = n * paymentFrequency();
	var num = parseFloat(PV * I);
	var denom = 1 - (1/Math.pow(part1,part2));
	var monthly_repayment = num/denom;
	return monthly_repayment;
}
function recalculate() {
	var PV = document.getElementById("loanAmount").value;
	var pf = parseFloat(paymentFrequency());
	var I = parseFloat(document.getElementById("interestRate").value) / (pf*100);
	if (pf==12) {
		var m = document.getElementById("hidden_payments").value;
	} else {
		var m = document.getElementById("hidden_fort_payments").value;
	}
	var n = document.getElementById("hidden_duration").value;
	var result = calculate_duration(PV, I, m);
	document.getElementById("hidden_duration").value = result;
	document.getElementById("hidden_repayments").value = r2(m * (n*pf));
	
      var totalRepaymentsString = "" + r2(m * (n*pf));
      if (totalRepaymentsString.indexOf('Infinity') == -1) {
	   document.getElementById("totalRepayments").innerHTML = "$" + roundTo2Decimals(r2(m * (n*pf)));    
      }
      else {
         document.getElementById("totalRepayments").innerHTML = "N/A";
      }
	calculateCharts();
	return false;
}
function calculateCharts() {
	// var dial1range = parseInt(document.getElementById("dial1").clientWidth);
	// var dial1value = parseInt(document.getElementById("dial1_value").clientWidth);
	var loanAmount = document.getElementById("loanAmount").value;
	var I = parseFloat(document.getElementById("interestRate").value) / (paymentFrequency()*100);
	var loanDuration = document.getElementById("hidden_duration").value * paymentFrequency();
	var maxPayment = calculate_payment(loanAmount, I, 1);
	var minPayment = calculate_payment(loanAmount, I, 7);
	if (document.getElementById("hidden_payments").value > 0) {
		if (paymentFrequency()==12) {
			var current_payment = document.getElementById("hidden_payments").value;
		} else {
			var current_payment = document.getElementById("hidden_fort_payments").value;
		}
	} else {
		var current_payment = document.getElementById("monthlyPayments").innerHTML;
	}
	if (current_payment.substring(0)=="$") current_payment = current_payment.substring(1);
	// if (maxPayment > 0 && dial1range > 0) {
	//	var dial_ratio = dial1range / maxPayment;
	// }
	// var dial1_newValue = parseInt(dial_ratio * current_payment) + "px";
	// document.getElementById("dial1_value").style.width = dial1_newValue;
	document.getElementById("current_repayments").innerHTML = "$" + roundTo2Decimals(r2(current_payment));
	// var dial2range = parseInt(document.getElementById("dial2").clientWidth);
	// dial2ratio = dial2range / (7*paymentFrequency());
	// dial2value = dial2ratio * loanDuration;
	// document.getElementById("dial2_value").style.width = dial2value+"px";
	// if (paymentFrequency()==12) {
	//	var years = parseInt(loanDuration / 12);
	//	var months = Math.round(parseFloat(loanDuration % 12));
	//	if (months >= 12) {
	//		months = months - 12;
	//		years = years + 1;
	//	}
	//	if (years != 1 ) {
	//		var text = years + " Years and ";
	//	} else {
	//		var text = years + " Year and ";
	//	}
	//	if (months != 1) {
	//		text = text + months + " Months";
	//	} else {
	//		text = text + months + " Month";
	//	}
	//	document.getElementById("vari_loanDuration").innerHTML = text;
	// } else {
	//	var years = parseInt(loanDuration / 26);
	//	var forts = parseFloat(loanDuration % 26);
	//	var months = Math.round(parseFloat((forts * 13) / 26));
	//	if (months >= 12) {
	//		months = months - 12;
	//		years = years + 1;
	//	}
	//	if (years != 1 ) {
	//		var text = years + " Years and ";
	//	} else {
	//		var text = years + " Year and ";
	//	}
	//	if (months != 1) {
	//		text = text + months + " Months";
	//	} else {
	//		text = text + months + " Month";
	//	}
	//	document.getElementById("vari_loanDuration").innerHTML = text;
	// }
	var loanRepayments = document.getElementById("hidden_repayments").value;
	var maxRepayments = calculate_payment(loanAmount, I, 7);
	if (paymentFrequency()==12) {
		maxRepayments = maxRepayments * (7*12);
	} else {
		maxRepayments = maxRepayments * (7*26);
	}
	// var dial3range = document.getElementById("dial3").clientWidth;
	// var dial3ratio = dial3range / maxRepayments;
	// var dial3value = dial3ratio * loanRepayments;
	// document.getElementById("dial3_value").style.width = parseInt(dial3value)+"px";
	// document.getElementById("vari_totalRepayments").innerHTML = "$" + r2(loanRepayments);
}
function paymentFrequency() {
	return document.getElementById("paymentFrequency").value;
}
function resetNow() {
	document.getElementById("loanAmount").value = "5000";
	document.getElementById("loanDuration").value = "3";
	document.getElementById("interestRate").value = "10.5";
	document.getElementById("dial1_value").style.width = 0;
	document.getElementById("dial2_value").style.width = 0;
	document.getElementById("dial3_value").style.width = 0;
	return false;
}
function r2(n) {
	ans = Math.round(n * 100) / 100;
	return ans;
}
function generateReport() {
	document.getElementById("report_amount").innerHTML = document.getElementById("loanAmount").value;
	document.getElementById("report_ir").innerHTML = document.getElementById("interestRate").value;
	if (paymentFrequency()==12) {
		document.getElementById("report_repayment").innerHTML = "$" + r2(document.getElementById("hidden_payments").value);
	} else {
		document.getElementById("report_repayment").innerHTML = "$" + r2(document.getElementById("hidden_fort_payments").value);
	}
	document.getElementById("report_term").innerHTML = r2(document.getElementById("hidden_duration").value) + " years";
	if (paymentFrequency()==12) {
		document.getElementById("report_freq").innerHTML = "monthly";
	} else {
		document.getElementById("report_freq").innerHTML = "fortnightly";
	}
	document.getElementById("report_total").innerHTML = "$" + r2(document.getElementById("hidden_repayments").value);
	document.getElementById("calculator").style.display = "none";
	document.getElementById("report").style.display = "block"; return;
}


function changeFreq() {

  var freqValue = document.getElementById('loanFrequency').value;
   if (freqValue == "12") {
      document.getElementById('repaymentText').innerHTML = "Monthly Repayments";
      return setMonthly();
   }
   else {
      document.getElementById('repaymentText').innerHTML = "Fortnightly Repayments";
      return setFortnightly();
   }
}


<!-- END LOAN CALCULATOR-->


function insuranceToggleDisplay (divToDisplay,buttonToDisplay) {
   document.getElementById('features').style.display = "none";
   document.getElementById('benefits').style.display = "none";
   document.getElementById('options').style.display = "none";
   document.getElementById('discounts').style.display = "none";
   document.getElementById(divToDisplay).style.display = "block";
   document.getElementById('featuresButton').style.backgroundPosition = "0px -0px";
   document.getElementById('benefitsButton').style.backgroundPosition = "-140px -140px";
   document.getElementById('optionsButton').style.backgroundPosition = "-140px -140px";
   document.getElementById('discountsButton').style.backgroundPosition = "-140px -280px";
   
   if (buttonToDisplay.indexOf('features') != -1) { 
      document.getElementById(buttonToDisplay).style.backgroundPosition = "0px 0px";
      document.getElementById('benefitsButton').style.backgroundPosition = "-140px -140px";
   }
   if (buttonToDisplay.indexOf('discounts') != -1) { 
      document.getElementById(buttonToDisplay).style.backgroundPosition = "0px -280px";
      document.getElementById('optionsButton').style.backgroundPosition = "-280px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-140px 0px";

   }
   if (buttonToDisplay.indexOf('benefits') != -1) { 
      document.getElementById(buttonToDisplay).style.backgroundPosition = "0px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-280px -0px";
   }
   if (buttonToDisplay.indexOf('options') != -1) { 
      document.getElementById(buttonToDisplay).style.backgroundPosition = "0px -140px";
      document.getElementById('benefitsButton').style.backgroundPosition = "-280px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-140px -0px";
   }
}

function insuranceToggleDisplayOnHover (divToDisplay,buttonToDisplay) {

   var divDisplayed;
   if (document.getElementById('features').style.display == "block") { divDisplayed = 'features'; }
   if (document.getElementById('benefits').style.display == "block") { divDisplayed = 'benefits'; }
   if (document.getElementById('options').style.display == "block") { divDisplayed = 'options'; }
   if (document.getElementById('discounts').style.display == "block") { divDisplayed = 'discounts'; }
  
   if (divDisplayed != divToDisplay) {
      if (buttonToDisplay.indexOf('discount') != -1) {
         if (divDisplayed == "options") {
            document.getElementById('optionsButton').style.backgroundPosition = "-0px -180px";
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -320px";   
         }
         else {        
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -320px";   
            document.getElementById('optionsButton').style.backgroundPosition = "-280px -280px";   
         }
      }
      if (buttonToDisplay.indexOf('options') != -1) {
         if (divDisplayed == "discounts") {
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-280px -180px";
            document.getElementById('benefitsButton').style.backgroundPosition = "-280px -280px";   
         }
         else if (divDisplayed == "benefits") {
            document.getElementById('optionsButton').style.backgroundPosition = "-140px -180px";
            document.getElementById('benefitsButton').style.backgroundPosition = "-0px -180px";
         }
         else {        
            document.getElementById('benefitsButton').style.backgroundPosition = "-280px -280px";   
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -180px";   
         }
      }
   
      if (buttonToDisplay.indexOf('benefits') != -1) {
         if (divDisplayed == "features") {
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -180px";
            document.getElementById('featuresButton').style.backgroundPosition = "0px -40px";
         }
         else if (divDisplayed == "options") {
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-280px -180px";
            document.getElementById('featuresButton').style.backgroundPosition = "-280px -360px";
         }
         else {        
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -180px";
            document.getElementById('featuresButton').style.backgroundPosition = "-280px -360px";
         }
      }
      if (buttonToDisplay.indexOf('features') != -1) {
         if (divDisplayed == "benefits") {
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-280px -40px";
         }
         else {        
            document.getElementById(buttonToDisplay).style.backgroundPosition = "-140px -40px";
         }
      }

   }
}

function insuranceToggleDisplayOnMouseOut (mouseOutButton) {

   var divDisplayed;
   if (document.getElementById('features').style.display == "block") { divDisplayed = 'features'; }
   if (document.getElementById('benefits').style.display == "block") { divDisplayed = 'benefits'; }
   if (document.getElementById('options').style.display == "block") { divDisplayed = 'options'; }
   if (document.getElementById('discounts').style.display == "block") { divDisplayed = 'discounts'; }
   document.getElementById('featuresButton').style.backgroundPosition = "0px -0px";
   document.getElementById('benefitsButton').style.backgroundPosition = "-140px -140px";
   document.getElementById('optionsButton').style.backgroundPosition = "-140px -140px";
   document.getElementById('discountsButton').style.backgroundPosition = "-140px -280px";
  
    if (divDisplayed.indexOf('features') != -1) { 
      document.getElementById('featuresButton').style.backgroundPosition = "0px 0px";
      document.getElementById('benefitsButton').style.backgroundPosition = "-140px -140px";
   }
   if (divDisplayed.indexOf('discounts') != -1) { 
      document.getElementById('discountsButton').style.backgroundPosition = "0px -280px";
      document.getElementById('optionsButton').style.backgroundPosition = "-280px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-140px 0px";

   }
   if (divDisplayed.indexOf('benefits') != -1) { 
      document.getElementById('benefitsButton').style.backgroundPosition = "0px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-280px -0px";
   }
   if (divDisplayed.indexOf('options') != -1) { 
      document.getElementById('optionsButton').style.backgroundPosition = "0px -140px";
      document.getElementById('benefitsButton').style.backgroundPosition = "-280px -140px";
      document.getElementById('featuresButton').style.backgroundPosition = "-140px -0px";
   }
}


function enterEvent(e, searchType, whichWidget){

if(e){
   e = e 
} else {
   e = window.event
} 

if(e.which){ 
   var keycode = e.which
} else {
   var keycode = e.keyCode 
}

if(keycode == 13) {
   goTripPlanner(searchType, whichWidget);
   }
}



function goTripPlanner(searchType, whichWidget){
	resetTripPlannerErrors();
	
	defaultFrom = 'eg. Brisbane';
	defaultTo = 'eg. Gold Coast';
	defaultPlaceName = 'eg. Noosa';
	
 
	// Get Directions
 
	if (whichWidget == '2' && searchType == 'route') {
		startPoint = document.getElementById('tripPlanner2From').value;
		endPoint = document.getElementById('tripPlanner2To').value;	
		
		if (startPoint == defaultFrom || startPoint == ' '){
		errorTripPlanner(whichWidget, 'from');
		startOK = 0;
		}else{startOK =1; }
	
		if (endPoint == defaultTo || endPoint == ' '){
			errorTripPlanner(whichWidget, 'to');
			endOK = 0;
		}else{endOK =1; }
		
		if (startOK == 1 && endOK == 1){
         firstTracker._trackPageview('/Links/TripPlanner/HPWidget/Directions');
         targetURL = 'http://www.racq.com.au/travel/Maps_and_Directions/trip_planner#directions:route/' + startPoint + '/' + endPoint;
	
	window.location.href=targetURL;
	}
}

         if (whichWidget == '3' && searchType == 'route') {
		startPoint = document.getElementById('tripPlanner3From').value;
		endPoint = document.getElementById('tripPlanner3To').value;	
		
		if (startPoint == defaultFrom || startPoint == ' '){
		errorTripPlanner(whichWidget, 'from');
		startOK = 0;
		}else{startOK =1; }
	
		if (endPoint == defaultTo || endPoint == ' '){
			errorTripPlanner(whichWidget, 'to');
			endOK = 0;
		}else{endOK =1; }
		
		if (startOK == 1 && endOK == 1){
         firstTracker._trackPageview('/Links/TripPlanner/HPTabs/Directions');
	targetURL = 'http://www.racq.com.au/travel/Maps_and_Directions/trip_planner#directions:route/' + startPoint + '/' + endPoint;
	
	window.location.href=targetURL;
	}
}
	
 
	// Find a place
		
	if (whichWidget == '2' && searchType == 'find') {
		
		placeName = document.getElementById('tripPlanner2Find').value;
						
		if (placeName == defaultPlaceName || placeName == ' '){
			errorTripPlanner(whichWidget, 'find');
			placeNameOK = 0;
			}else{placeNameOK =1; }
	
		if (placeNameOK == 1){
                  firstTracker._trackPageview('/Links/TripPlanner/HPWidget/Place');
		targetURL = 'http://www.racq.com.au/travel/Maps_and_Directions/trip_planner#search:find/' + placeName;
		
		window.location.href=targetURL;
		}
	}
         if (whichWidget == '3' && searchType == 'find') {
		
		placeName = document.getElementById('tripPlanner3Find').value;
						
		if (placeName == defaultPlaceName || placeName == ' '){
			errorTripPlanner(whichWidget, 'find');
			placeNameOK = 0;
			}else{placeNameOK =1; }
	
		if (placeNameOK == 1){
                  firstTracker._trackPageview('/Links/TripPlanner/HPTabs/Place');
		targetURL = 'http://www.racq.com.au/travel/Maps_and_Directions/trip_planner#search:find/' + placeName;
		window.location.href=targetURL;
		}
	}

}
	
function errorTripPlanner(whichWidget, whichInput){
	if (whichWidget == '2'){
		
		if (whichInput == 'from'){
			document.getElementById('tripPlanner2From').style.borderColor='#900';
			document.getElementById('tripPlanner2From').style.color='#900';
			}
		
		if (whichInput == 'to'){
			document.getElementById('tripPlanner2To').style.borderColor='#900';
			document.getElementById('tripPlanner2To').style.color='#900';
		}
		
		if (whichInput == 'find'){
			document.getElementById('tripPlanner2Find').style.borderColor='#900';
			document.getElementById('tripPlanner2Find').style.color='#900';
		}
		
		
	}
         if (whichWidget == '3'){
		
		if (whichInput == 'from'){
			document.getElementById('tripPlanner3From').style.borderColor='#900';
			document.getElementById('tripPlanner3From').style.color='#900';
			}
		
		if (whichInput == 'to'){
			document.getElementById('tripPlanner3To').style.borderColor='#900';
			document.getElementById('tripPlanner3To').style.color='#900';
		}
		
		if (whichInput == 'find'){
			document.getElementById('tripPlanner3Find').style.borderColor='#900';
			document.getElementById('tripPlanner3Find').style.color='#900';
		}
		
		
	}

		
}
	
function resetTripPlannerErrors(){
	document.getElementById('tripPlanner2From').style.borderColor='#aaa';
	document.getElementById('tripPlanner2From').style.color='#666';
	document.getElementById('tripPlanner2To').style.borderColor='#aaa';	
	document.getElementById('tripPlanner2To').style.color='#666';	
	
	document.getElementById('tripPlanner2Find').style.borderColor='#aaa';	
	document.getElementById('tripPlanner2Find').style.color='#666';	
	document.getElementById('tripPlanner3From').style.borderColor='#aaa';
	document.getElementById('tripPlanner3From').style.color='#666';
	document.getElementById('tripPlanner3To').style.borderColor='#aaa';	
	document.getElementById('tripPlanner3To').style.color='#666';	
	
	document.getElementById('tripPlanner3Find').style.borderColor='#aaa';	
	document.getElementById('tripPlanner3Find').style.color='#666';	

	}
	
function toggle(whichItem){
	el = document.getElementById(whichItem);
	
	if(el.style.display == 'none'){
		el.style.display='';
		}else{
		el.style.display='none';	
			}
	}
	
function switchTripPlannerTabs(whichPanel,whichWidget){

    if (whichWidget == '2'){

                	tab1 = document.getElementById('tabDirections2');
		tab2 = document.getElementById('tabFindPlace2');

		if ((tab1.className == "tabCurrent" && whichPanel == "place") || (tab2.className == "tabCurrent" && whichPanel == "directions")) {

                  toggle('tripWidgetFrom2');
		toggle('tripWidgetTo2');
		toggle('tripWidgetPlace2');
		toggle('btnTripPlannerGo2');
		toggle('btnTripPlannerGo2b');
		
		
		if(tab1.className == "tabCurrent" ){tab1.className = ""; tab2.className = "tabCurrent";}
		else {tab1.className = "tabCurrent"; tab2.className = "";}
             }

         }
    if (whichWidget == '3'){

                  	tab1 = document.getElementById('tabDirections3');
		tab2 = document.getElementById('tabFindPlace3');


		if ((tab1.className == "tabCurrent" && whichPanel == "place") || (tab2.className == "tabCurrent" && whichPanel == "directions")) {

                  toggle('tripWidgetFrom3');
		toggle('tripWidgetTo3');
		toggle('tripWidgetPlace3');
		toggle('btnTripPlannerGo3');
		toggle('btnTripPlannerGo3b');
		
		if(tab1.className == "tabCurrent"){tab1.className = ""; tab2.className = "tabCurrent";}
		else{tab1.className = "tabCurrent"; tab2.className = "";}
                  }
         }
}

