﻿/*extern document, Event, window, YAHOO, alert */
/*global PIEDMONT */
/*members RootPath, Scope, addListener, close, closeEmail, emailPage, 
    getElementById, href, isNull, lang, location, mailWindow, onDOMReady, 
    onSearchBlur, onSearchFocus, open, title, value
*/
/* 2009-05-12 */



PIEDMONT = {
    searchText: null,
	onDOMReady: function () {
		var input = document.getElementById('layout_SearchField');
		this.searchText = input.value;

		Event.addListener(input, 'focus', this.onSearchFocus);
		Event.addListener(input, 'blur',  this.onSearchBlur);
	},


	onSearchFocus: function () {
		if (this.value.length > 0) {
			this.value = '';
		}
	},

	onSearchBlur: function () {
		if (this.value === '') {
			this.value = PIEDMONT.searchText;
		}
	},

	emailPage: {
		mailWindow: null,
		RootPath: '/Content/MailPage/',

		emailPage: function () {
			var sURL =
			this.RootPath +
			'Window-MailPage.asp' + 
			'?URL=' + encodeURIComponent(document.location.href) +
			'&Title=' + encodeURIComponent(document.title);

			this.mailWindow = window.open(sURL, 'MailPage', 'height=575,width=530,toolbar=no,scrollbars=yes,resizable=yes');

			if (YAHOO.lang.isNull(this.mailWindow) === false) {
				this.mailWindow.Scope = this;
			} else {
				alert('Your popup blocker has prevented us from opening a new window.\nPlease disable your popup blocker and try again.');
			}

		},
		closeEmail: function () {
			if (YAHOO.lang.isNull(this.mailWindow) === false) {
				this.mailWindow.close();
			}
		}

	}

};
Event.onDOMReady(PIEDMONT.onDOMReady, PIEDMONT, true);

