/*****************************************************
	Live Chat code
	Provides code to:
	(1)	Open Live Chat window; and
	(2)	Track use through Omniture.
	
	NOTES:
	(1)	Requires form on the page with default user
		details.
	(2)	The _validate_input function may no longer be
		necessary.
\*****************************************************/



/** *** ***
Tracks the use of the Live Chat window through Omniture
*** *** ***/
function trackChat(sourceLink) {
	if(typeof s.tl=='function') {
		// Only proceed with tracking if the Omniture code has loaded
		s.events="event16";
		s.eVar50=s.pageName;
		s.t();
	}
}


/** *** ***
Opens the window for Live Chat
*** *** ***/
function openChat() {
	form = document._chat;
	if (navigator.platform != 'MacPPC') {
		if (navigator.appName == "Microsoft Internet Explorer") { width=238;height=245 }
		else if (parseInt(navigator.appVersion) > 4) { width=600;height=450 }
		else { width=800;height=600 }
	}
	else {
		if (navigator.appName == "Microsoft Internet Explorer") { width=525;height=500 }
		else if (parseInt(navigator.appVersion) > 4) { width=525;height=500 }
		else { width=850;height=475 }
	}
	_input_ok = true;
	for (i = 0; i < form.elements.length; i++) {
		if (_input_ok && form.elements[i].type == "text") {
			_input_ok = _validate_input(form.elements[i]);
		}
	}
	if (_input_ok) {
		_rnl_chat = window.open("","rnl_chat_window", "resizable=yes,scrollbars=no,width="+width+",height="+height);
		if (_rnl_chat.document.title.length == 0) {
			form.submit();
		}
		_rnl_chat.focus();
	}
}


/** *** ***
Checks that the user has made a selection from the list.
*** *** ***/
function _validate_input(element) {
	_prompt = "Enter data here";
	if ((element.value == '') || (element.value == _prompt)) {
		element.value = _prompt;
		element.select();
		return(false);
	}
	else {
		return(true);
	}
}
