

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

JavaScript Library for EcoRealtyInc.ca

Copyright (c) 2010 Eco Realty Inc. All rights reserved.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Misc */

if ((window.event + '') == 'undefined') {
 	// event = null;
 	event = '';
}

// var bannerBackground = 0;
var testMode = 0;
var WTF = 'What the #$%@&*?!?';

function doNothing() {}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jQuery extensions */

jQuery.fn.exists = function() {return (this.length > 0);}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code for determining current URL, file name, path, protocol, etc. */

var URL = location.href;
var URLProtocol = location.protocol;
var URLHostName = location.hostname;
var URLPort = location.port;
var URLPath = location.pathname;
var URLHash = location.hash;
var URLSearch = location.search;
var URLMinusQueryString = URL;

if (URL.indexOf('?') != -1) {
	URLMinusQueryStringTemp = URL.split('\\');
	URLMinusQueryString = URLMinusQueryStringTemp[0];
}

var webServerName = URLProtocol + '\/\/' + URLHostName;

if (URLPort != '') {
	webServerName += (':' + URLPort);
}
	

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Query string detection */

function getParameter(parameterName) {
	var queryString = window.top.location.search.substring(1);
	parameterName = parameterName + '=';

	if (queryString.length > 0) {
		begin = queryString.indexOf(parameterName);

		if (begin != -1) {
			begin += parameterName.length;
			end = queryString.indexOf('&', begin);

			if (end == -1) {
				end = queryString.length;
			}
			return unescape(queryString.substring(begin, end));
		}
	}
	return null;
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Browser and platform detection */

var agent = '';

if (navigator.userAgent) { 
	agent = navigator.userAgent.toLowerCase();
} else { 
	agent = navigator.appVersion.toLowerCase();
}

var is_ie = (agent.indexOf('msie') != -1);
var is_ie7 = (is_ie && (agent.indexOf('msie 7.0') != -1));
var is_ie8 = (is_ie && (agent.indexOf('msie 8.0') != -1));
var is_ie7up = (is_ie && (is_ie7 || is_ie8));

var is_webkit = (agent.indexOf('webkit') != -1);
var is_safari = (agent.indexOf('safari') != -1);
var is_chrome = (agent.indexOf('chrome') != -1);

if (is_chrome) {
	is_safari = false;
}

var is_ipad = (agent.indexOf('ipad') != -1);
var is_iphone = (agent.indexOf('iphone') != -1);
var is_ipod = (agent.indexOf('ipod') != -1);

if (is_ipod || is_ipad) {
	is_iphone = 0;
}

var is_mozilla = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('netscape') == -1) && (agent.indexOf('navigator') == -1)) && !is_ie);

var is_firefox = (is_mozilla && (agent.indexOf('firefox') != -1));
var is_firefox1r0 = (is_firefox && (agent.indexOf('firefox\/1.0') != -1));
var is_firefox1r5 = (is_firefox && (agent.indexOf('firefox\/1.5') != -1));
var is_firefox2r0 = (is_firefox && (agent.indexOf('firefox\/2.') != -1));
var is_firefox2up = (is_firefox && !is_firefox1r0 && !is_firefox1r5);
var is_firefox3r0 = (is_firefox && (agent.indexOf('firefox\/3.0') != -1));
var is_firefox3r5 = (is_firefox && (agent.indexOf('firefox\/3.5') != -1));
var is_firefox3r6 = (is_firefox && (agent.indexOf('firefox\/3.6') != -1));
var is_firefox3up = (is_firefox && !is_firefox1r0 && !is_firefox1r5 && !is_firefox2r0);
var is_firefox4r0 = (is_firefox && (agent.indexOf('firefox\/4.0') != -1));
var is_firefox3r5up = (is_firefox && (is_firefox3r5 || is_firefox3r6 || is_firefox4r0));

var is_win = (agent.indexOf('windows') != -1);
var is_linux = (agent.indexOf('linux') != -1);
var is_mac = (agent.indexOf('mac') != -1);


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Writing CSS into the page */

var iSSHTML = '';

// Banner stuff
iSSHTML += ' body.entry #banner { opacity: 0; }';


// Browser/OS specific styles
if (is_ie) {
}


if (is_webkit) {
	//iSSHTML += ' #search #searchTop input#doSearchButton { padding-top: 3px; padding-bottom: 3px; }';
	//iSSHTML += ' div.jumpToPrice { margin-top: 17px; } input.jumpToPriceInput { padding: 3px 5px 3px 5px; }';
	//iSSHTML += ' div.searchResults ol li span.numBedBaths { margin-top: 20px; }';

	if (is_safari) {
		if (is_win) {
			//iSSHTML += ' #search #searchTop input#doSearchButton { padding-top: 1px; padding-bottom: 1px; }';
		}
	}
}

if (is_iphone || is_ipod || is_ipad) {
	iSSHTML += ' input[type="text"], input[type="password"], input.textField, textarea { background-image: url(\/gui\/images\/blank\/blank_transparent.gif); }'; // cursor: pointer !important; 
}

if (is_iphone) {
	iSSHTML += ' a.tel, a.tel:link, a.tel:active, a.tel:hover, a.tel:visited { color: #497493; border-bottom: 1px dotted #497493; }'; // cursor: pointer !important; 
}

if (is_ipad) {

}

// Case specific styles
// testMode = 0;
if (testMode) {
	iSSHTML += ' #header { background-color: lime; }';
	iSSHTML += ' #logoContainer { background-color: red; }';
	iSSHTML += ' #crossSiteNav { background-color: pink }';
	iSSHTML += ' #utilityNav { background-color: orange; }';

	iSSHTML += ' #content { background-color: lime; }';
	iSSHTML += ' #leftColumn { background-color: red; }';
	iSSHTML += ' #centerColumn { background-color: pink }';
	iSSHTML += ' #rightColumn { background-color: orange; }';

	iSSHTML += ' div.taggedArticle div.taggedArticleDate { background: yellow; }'
	iSSHTML += ' div.taggedArticle div.taggedArticleImage { background: orange }';
	iSSHTML += ' div.taggedArticle div.taggedArticleCopy { background: pink; }';
	iSSHTML += ' div.taggedArticle div.taggedArticleCitation { background: lime; }';
}

// Write this CSS into the page
iSSHTML = '<style type="text\/css"><!-' + '-\n' + iSSHTML + '\n-' + '-><\/style>'; // media="screen"
if (document.write) {
	document.write(iSSHTML);
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Image functions/preloading */

var blank_transparent_image = new Image();


var bannerContainerBackground = new Image();

if (document.images) {
	blank_transparent_image.src = '\/gui\/images\/blank\/blank_transparent.gif';
}

// Image roll-over
function ERI_imageRollover(e_currentImage) {
	// if (document.images) {
		if (e_currentImage) {
			e_currentImage.src = eval(e_currentImage.id + '_on.src');

			if ((is_ie) && (!is_ie7up) && (hasClass(e_currentImage, 'transparentPNG'))) {
				CSI_rTPNGI(e_currentImage);
			}
		}
	// }
}

// Image roll-out
function ERI_imageRollout(e_currentImage) {
	// if (document.images) {
		if (e_currentImage) {
			e_currentImage.src = eval(e_currentImage.id + '_off.src');

			if ((is_ie) && (!is_ie7up) && (hasClass(e_currentImage, 'transparentPNG'))) {
				CSI_rTPNGI(e_currentImage);
			}
		}
	// }
}

// Restyle transparent PNG images (for IE6)
function ERI_rTPNGI(e_currentImage) {
	// if (document.images) {
	if (is_ie && !is_ie7up) {
		// If a particular image element has been specified...
		if (e_currentImage) {
			e_currentImage.css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=' + e_currentImage.src + ')');
			e_currentImage.attr('src', blank_transparent_image.src);

		// Otherwise run through all of the transparentPNG classed images in the document...
		} else if (e_allImageTags) {
			e_allImageTags.each( function(loopCounter) {
				e_currentImage = e_allImageTags.eq(loopCounter);

				if (e_currentImage.attr('usemap') != '') {
					e_currentImage.css('border', 'none');
				}

				if (e_currentImage.hasClass('transparentPNG')) {
					imgWidth = e_currentImage.attr('width');
					imgHeight = e_currentImage.attr('height');
					imgSrc = e_currentImage.attr('src');

					e_currentImage.attr('width', imgWidth);
					e_currentImage.attr('height', imgHeight);
					e_currentImage.css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src=' + imgSrc + ')');

					e_currentImage.attr('src', blank_transparent_image.src);
				}
			});
		}
	}
	// }
}

// Image swap... with cross-fade transition to come later
function ERI_imageCrossFade(e_currentImage, imageToSwapIn) {
    if (e_currentImage.exists()) {
        imgWidth = e_currentImage.attr('width');
        imgHeight = e_currentImage.attr('height');
        imgSrc = e_currentImage.attr('src');

        e_currentImage.attr('width', imgWidth);
        e_currentImage.attr('height', imgHeight);

        if (imgSrc != imageToSwapIn) {
            e_currentImage.width = imgWidth;
            e_currentImage.height = imgHeight;
            e_currentImage.attr('src', imageToSwapIn);
        }
    }
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Search functions */

// Toggle display of the search section
function ERI_tDSS(showSwitch) {
	if (e_search && e_searchTop && e_sampleSearch && e_sampleSearchLinkBar && e_searchLeft && e_searchRight && e_searchBottom) {
		if (showSwitch) {
			e_sampleSearchLinkBar.fadeOut();
            $(e_searchBottom).slideDown(400);
			setTimeout('e_sampleSearchLinkBar.html(collapseSearchSectionLinkHTML); e_sampleSearchLinkBar.fadeIn();', 600);
                        _gaq.push(['_trackEvent', 'Find Listings by Region', 'Find Listings by Region Tray Expaned', 'Find Listings by Region Tray Expaned']);
		} else {
			e_sampleSearchLinkBar.fadeOut();
            $(e_searchBottom).slideUp(400);
			setTimeout('e_sampleSearchLinkBar.html(expandSearchSectionLinkHTML); e_sampleSearchLinkBar.fadeIn();', 600);
                        _gaq.push(['_trackEvent', 'Find Listings by Region', 'Find Listings by Region Tray Collapsed', 'Find Listings by Region Tray Collapsed']);
		}
	}
}

var defaultSearchValue = '';

function focusSearch(){
	e_searchValue.focus();
	e_searchValue.css('background-color', '#f4a732');
	window.setTimeout(
		function f(){
			e_searchValue.css('background-color', '');
		}, 500);
}

function URLDecode(encodedString) {
	var plusSigns = /\+/g;
	return unescape(encodedString.replace(plusSigns, ' '));
}

function ERI_colourFader(r, g, b) {
	this.r = r;
	this.g = g;
	this.b = b;

	var deltaR = r/30.0;
	var deltaG = g/30.0;
	var deltaB = b/30.0;

	var tempR = r;
	var tempG = g;
	var tempB = b;

	function fade(element) {
		element.css('color', 'rgb(' + Math.max(0, Math.round(tempR)) + ',' + Math.max(0, Math.round(tempG)) + ',' + Math.max(0, Math.round(tempB)) + ')');
		if ((tempR + tempG + tempB) > 0) {
			tempR -= deltaR;
			tempG -= deltaG;
			tempB -= deltaB;
			setTimeout(function() { 
				fade(element)
			}, 30);
		}
	};

	this.fadeToBlack = function(element) {
		fade(element);
	};
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Page initialization and finalization */


// Restyle the header
function ERI_pI_rH() {
	if (e_header) {
		// Logo
		if (e_logo) {
			e_logo.addClass('transparentPNG');
		}

		// Restyle the search section
		ERI_pI_rSS();
	}
}

// Restyle the search section
var collapseSearchSectionLinkText = 'Hide regions';
var collapseSearchSectionLinkTitle = 'Collapse this section and just show the search...';
var collapseSearchSectionLinkHTML = '<span id="toggleSearchSection"><a href="#topOfPage" onclick="ERI_tDSS(0); return false;" oncontextmenu="return false;" title="' + collapseSearchSectionLinkTitle + '">' + collapseSearchSectionLinkText + '<\/a> &nbsp; <span id="toggleSearchSectionIcon" onclick="ERI_tDSS(0); return false;" title="' + collapseSearchSectionLinkTitle + '"><\/span><\/span>';

var expandSearchSectionLinkText01 = 'Search tips';
var expandSearchSectionLinkTitle01 = 'Tips and examples for getting the most out of our search...';
var expandSearchSectionLinkText02 = 'Find listings by region';
var expandSearchSectionLinkTitle02 = 'Search for real estate listings by region...';
//var expandSearchSectionLinkHTML = '<span id="toggleSearchSection"><a href="#topOfPage" onclick="ERI_tDSS(1); return false;" oncontextmenu="return false;" title="' + expandSearchSectionLinkTitle01 + '">' + expandSearchSectionLinkText01 + '<\/a> &nbsp; <span id="searchTipsIcon" onclick="ERI_tDSS(1); return false;" title="' + expandSearchSectionLinkTitle01 + '"><\/span> &nbsp; | &nbsp; <a href="#topOfPage" onclick="ERI_tDSS(1); return false;" oncontextmenu="return false;" title="' + expandSearchSectionLinkTitle02 + '">' + expandSearchSectionLinkText02 + '<\/a> &nbsp; <span id="viewAllRegionsIcon" onclick="ERI_tDSS(1); return false;" title="' + expandSearchSectionLinkTitle02 + '"><\/span><\/span>';

var expandSearchSectionLinkHTML = '<span id="toggleSearchSection"><a href="#topOfPage" onclick="ERI_tDSS(1); return false;" oncontextmenu="return false;" title="' + expandSearchSectionLinkTitle02 + '">' + expandSearchSectionLinkText02 + '<\/a> &nbsp; <span id="viewAllRegionsIcon" onclick="ERI_tDSS(1); return false;" title="' + expandSearchSectionLinkTitle02 + '"><\/span><\/span>';

var validSearchTextString = 'Please enter your search criteria here and try again...';

function ERI_pI_rSS() {
	if (e_search) {
		// Initialize the search section (including adding links for expanding/collapsing the search section)
		if (e_sampleSearch && e_sampleSearchLinkBar) {
			e_sampleSearchLinkBar.appendTo(e_sampleSearch);

			if (e_body.hasClass('entry')) {
				e_sampleSearchLinkBar.html(collapseSearchSectionLinkHTML);
			} else {
				e_sampleSearchLinkBar.html(expandSearchSectionLinkHTML);
			}
		}

		// Attach functionality to the search value field
		if (e_searchValue) {
			// Populate the search text field with the query string contents
			queryStringValue = getParameter('q');
			if (queryStringValue != null) {
				e_searchValue.attr('value', URLDecode(queryStringValue));
			}

			e_searchValue.attr('defaultSearchValue', e_searchValue.attr('title'));
			defaultSearchValue = e_searchValue.attr('defaultSearchValue');

			if (e_searchValue.attr('value') == e_searchValue.attr('title')) {
				e_searchValue.css('color', '#808080');
			}

			e_searchValue.bind('focus', function() {
				// e_searchValue.addClass('active');

                                e_searchInputWrapper.addClass('active');

				e_searchValue.css('color', '#000000');
				//e_searchValue.css('border-color', '#aaaaaa');

				if ((e_searchValue.attr('value') == e_searchValue.attr('defaultSearchValue')) || (e_searchValue.attr('value') == validSearchTextString)) {
					e_searchValue.attr('value', '');
				}
			});

			e_searchValue.bind('blur', function() {

                                e_searchInputWrapper.removeClass('active');

				if ((e_searchValue.attr('value') == '') || (e_searchValue.attr('value') == ' ') || (e_searchValue.attr('value') == validSearchTextString)) {
					e_searchValue.attr('value', e_searchValue.attr('defaultSearchValue'));

					e_searchValue.css('color', '#808080');

					// e_searchValue.removeClass('active');
				} else {
					e_searchValue.css('color', '#000000');
				}

				//e_searchValue.css('border-color', '#7D7C73');

				// e_searchValue.removeClass('active');
			});
		}


		// Attach functionality to the search submit button
		if (e_searchValue && e_searchButton) {

                e_searchButton.bind("mouseover", function() {
                    e_searchButton.addClass("hover");
                });

                e_searchButton.bind("mouseout", function() {
                    e_searchButton.removeClass("hover");
                    e_searchButton.removeClass("active");
                });

                e_searchButton.bind("mousedown", function() {
                    e_searchButton.addClass("active");
                });

                e_searchButton.bind("mouseup", function() {
                    e_searchButton.removeClass("active");
                });

			e_searchButton.bind('click', function() {
				//e_searchButton.blur();

				// Has valid search criteria been entered?
				if ((e_searchValue.attr('value') == e_searchValue.attr('defaultSearchValue')) || (e_searchValue.attr('value') == '') || (e_searchValue.attr('value') == ' ') || (e_searchValue.attr('value') == validSearchTextString)) {
					e_searchValue.addClass('active');
					e_searchValue.attr('value', validSearchTextString);

					return false;
				}
			});
		}

		// Search text field highlighting code
		if (getParameter('highlight') != null) {
			e_searchValue.css('color', 'rgb(244, 167, 50)');

			setTimeout("(new ERI_colourFader(244, 167, 50)).fadeToBlack(e_searchValue)", 750);
		}
	}
}

// Restyle the content
function ERI_pI_rC() {
		// Add background-color change on hover to search results
		if ($('div.searchResults ol').exists()) {
			e_searchResultsItemsThumbnails = $('div.searchResults ol li a:first-child img');

			e_searchResultsItemsThumbnails.bind('mouseover', function() {
				$(this).parent().parent().addClass('hover');
			});

			e_searchResultsItemsThumbnails.bind('mouseout', function() {
				$(this).parent().parent().removeClass('hover');
			});

			e_searchResultsItemsHeadings = $('div.searchResults ol li div.searchDetails h2:first-child a');
			e_searchResultsItemsHeadings.bind('mouseover', function() {
				$(this).parent().parent().parent().addClass('hover');
			});

			e_searchResultsItemsHeadings.bind('mouseout', function() {
				$(this).parent().parent().parent().removeClass('hover');
			});
		}

		// Add listing image switching on click
		if ($('div.listing').exists()) {
			e_listingImage = $('#expandedImage');
			e_listingThumbnailLinks = $('div.listing div.imageArea a.thumbnail');

			if (e_listingThumbnailLinks.exists()) {
				e_listingThumbnailLinks.bind('click', function(eventObject) {
					// Re-write thumbnail links
					ERI_imageCrossFade(e_listingImage, $(this).attr('href'));
					return false;
				});
			}
		}

		// Right column
		if (e_rightColumn) {
			e_content.addClass(e_rightColumn.attr('id'));
		}
}

// Restyle the footer
function ERI_pI_rF() {
	if (e_footer) {
		e_footerNavColumns = $('div.footerNavColumn');
		if (e_footerNavColumns) {
			e_footerNavColumns.each( function(loopCounter) {
				if ((loopCounter != 0) && ((loopCounter % 3) == 0)) {
					e_footerNavColumns.eq(loopCounter).addClass('clear');
				}
				if ((loopCounter % 3) == 2) {
					e_footerNavColumns.eq(loopCounter).addClass('last');

					if (is_ie) {
						e_footerNavColumns.eq(loopCounter).after('<br class="clear" />');
					}
				} else {
					// ?
				}
			});
		}
	}
}

// Restyle the links
function ERI_pI_rL() {
	e_allAnchorTags.each( function(loopCounter) {
		e_currentLink = e_allAnchorTags.eq(loopCounter);

		// Fake links
		if (e_currentLink.hasClass('fake')) {
			e_currentLink.bind('click', function() {
				return false;
			});
		}

		// Cloaked email links
		if (e_currentLink.hasClass('cloakedEmail')) {
			if (e_currentLink.attr('href').indexOf('%28-at-%29') != -1) {
				emailAddressHTMLTemp = e_currentLink.attr('href').split('%28-at-%29');
				emailAddressHTML = emailAddressHTMLTemp[0] + '@' + emailAddressHTMLTemp[1];
				e_currentLink.attr('href', emailAddressHTML);

				if ((e_currentLink.children().size() == 0) && (e_currentLink.text().indexOf('%28-at-%29') != -1)) {
					e_currentLink.text(emailAddressHTML.split('mailto:')[1]);
				}
			}

			if (e_currentLink.attr('href').indexOf('(-at-)') != -1) {
				emailAddressHTMLTemp = e_currentLink.attr('href').split('(-at-)');
				emailAddressHTML = emailAddressHTMLTemp[0] + '@' + emailAddressHTMLTemp[1];
				e_currentLink.attr('href', emailAddressHTML);

				if ((e_currentLink.children().size() == 0) && (e_currentLink.text().indexOf('(-at-)') != -1)) {
					e_currentLink.text(emailAddressHTML.split('mailto:')[1]);
				}
			}
		}
	});

	// e_allFooterLinks = $('#footer #footerNav div.footerNavColumn a');
	e_allFooterLinks = $('#footer a');
	e_allFooterLinks.each( function(loopCounter) {
		e_currentLink = e_allFooterLinks.eq(loopCounter);

		if ((e_currentLink.attr('href') == URL) || ((webServerName + e_currentLink.attr('href')) ==  URL)) {
			e_currentLink.addClass('footerNavLinkOn');

			e_currentLink.bind('click', function() {
				return false;
			});
		}
	});
}

// Show the banner
function ERI_pI_sB() {
	if (e_banner) {
		// if (e_bannerContainer) {
			// e_bannerContainer.css('background-image', 'url(' + bannerContainerBackground.src + ')');
		// }

		if (!(is_ie && e_banner.hasClass('transparentPNG'))) {
			// e_banner.fadeTo(1000, 1);
			setTimeout('e_banner.fadeTo(' + "'slow', 1" + ');', 300);
		}
	}
}

// Page initialization
function ERI_pI() {
	// if (true) {
    // Single tags
    e_html = $('html');
    e_head = $('head');
    e_body = $('body');

    // Collections of tags
    e_allAnchorTags = $('a');
    e_allDivTags = $('div');
    e_allIframeTags = $('iframe');
    e_allImageTags = $('img');
    e_allListItemTags = $('li');
    e_allObjectTags = $('object');
    e_allParagraphTags = $('p');
    e_allSpanTags = $('span');
    e_allHorizontalRuleTags = $('hr');

    // Get elements by id
    e_header = $('#header');
    e_logo = $('#logo');
    e_crossSiteNav = $('#crossSiteNav');
    e_bannerContainer = $('#bannerContainer');
    e_banner = $('#banner');
    e_search = $('#search');
    e_searchTop = $('#searchTop');
    e_searchValue = $('#searchValue');
    e_searchInputWrapper = $('#searchInputWrapper');
    e_searchButton = $('#doSearchButton');
    e_sampleSearch = $('.sampleSearch');
    e_searchLeft = $('#searchLeft');
    e_searchRight = $('#searchRight');
    e_searchBottom = $('#searchBottom');
    e_utilityNav = $('#utilityNav');
    e_content = $('#content');
    e_leftColumn = $('#leftColumn');
    e_centerColumn = $('#centerColumn');
    e_rightColumn = $('#rightColumn');
    e_footer = $('#footer');

    // Create elements
    e_pageContainerOuter = $('<div id="pageContainerOuter"></div>');
    e_pageContainerInnerTop = $('<div id="pageContainerInnerTop"></div>');
    e_contentContainer = $('<div id="contentContainer"></div>');
    e_leftColumnContainer = $('<div id="leftColumnContainer"></div>');
    e_rightColumnContainer = $('<div id="rightColumnContainer"></div>');
    e_pageContainerInnerBottom = $('<div id="pageContainerInnerBottom"></div>');
    e_sampleSearchLinkBar = $('<span id="sampleSearchLinkBar"></span>');

		// Restyle the header
		ERI_pI_rH();

		// Restyle the content
		ERI_pI_rC();

		// Restyle the footer
		ERI_pI_rF();

		// Restyle the links
		ERI_pI_rL();

		// Show banner
		ERI_pI_sB();

		// Restyle transparent PNG images (for IE6's benefit)
		ERI_rTPNGI();

		// Make the page visible
		// setTimeout('e_body.css(' + "'visibility', 'visible'" + ');', 100);
	// }
}


// Additional page initialization
function ERI_aPI() {
	// doNothing();
}

// Restyle images
function ERI_rI() {
	if (is_ie) {
		e_imagesToBeRestyled = $('img.photoOfTheDay, img.taggedArticleImage, img.realtorPhoto');
		if (e_imagesToBeRestyled) {
			e_imagesToBeRestyled.each( function(loopCounter) {
				e_imagesToBeRestyled.eq(loopCounter).addClass('restyled');
			});
		}
	}
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Window/document level events */

$(document).ready(function() {
	ERI_pI(); 	// pageInitialization
	ERI_aPI(); 	// additionalPageInitialization
        $(".sampleSearchText").textShadow();
        $("#toggleSearchSection a").textShadow();
        $("#featuredListings .listingDetails a").textShadow();
        $("#newsAndArticles .newsAndArticlesHeading a").textShadow();
});

window.onload = function() {
	ERI_rI(); 	// restyleImages
}


/* Created by Martin Hintzmann 2008 martin [a] hintzmann.dk
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 *
 * Version: 0.2
 * Requires: jQuery 1.2+
 * http://plugins.jquery.com/project/textshadow
 *
 */
	$.fn.textShadow = function(option) {
		if (!$.browser.msie) return;
		var IE6 = $.browser.version < 7;
		return this.each(function() {
			var el = $(this);
			var shadow = el.textShadowParse(this.currentStyle["text-shadow"]);
			shadow = $.extend(shadow, option);

			el.textShadowRemove();

			if (shadow.x == 0 && shadow.y == 0 && shadow.radius == 0) return;

			if (el.css("position")=="static") {
				el.css({position:"relative"});
			}
			el.css({zIndex:"0"});
			if (IE6) {
				el.css({zoom:"1"});
			}

			var span=document.createElement("span");
			$(span).addClass("jQueryTextShadow");
			$(span).html(el.html());
			$(span).css({
				padding:		this.currentStyle["padding"],
				width:		el.width(),
				position:	"absolute",
				zIndex:		"-1",
				color:		shadow.color!=null?shadow.color:el.css("color"),
				left:			(-parseInt(shadow.radius)+parseInt(shadow.x))+"px",
				top:			(-parseInt(shadow.radius)+parseInt(shadow.y))+"px"
			});

			if (shadow.radius != 0) {
				if (shadow.opacity != null) {
					$(span).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelradius="+parseInt(shadow.radius)+", enabled='true', makeShadow='true', ShadowOpacity="+shadow.opacity+")");
				} else {
					$(span).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelradius="+parseInt(shadow.radius)+", enabled='true')");
				}
			}
			el.append(span);

	  });
	};

	$.fn.textShadowParse = function(value)
	{
		value = String(value)
			.replace(/^\s+|\s+$/gi, '')
			.replace(/\s*!\s*important/i, '')
			.replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3/$4)')
			.replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3)')

		var shadow = {
			x      : 0,
			y      : 0,
			radius : 0,
			color  : null
		};

		if (value.length > 1 || value[0].toLowerCase() != 'none') {
			value = value.replace(/\//g, ',');
			var color;
			if ( value.match(/(\#[0-9a-f]{6}|\#[0-9a-f]{3}|(rgb|hsb)a?\([^\)]*\)|\b[a-z]+\b)/i) && (color = RegExp.$1) ) {
				shadow.color = color.replace(/^\s+/, '');
				value = value.replace(shadow.color, '');
			}

			value = value
				.replace(/^\s+|\s+$/g, '')
				.split(/\s+/);

		    textShadowMap(value, function(item) {
					return (item || '').replace(/^0[a-z]*$/, '') ? item : 0 ;
				});

			switch (value.length)
			{
				case 1:
					shadow.x = shadow.y = value[0];
					break;
				case 2:
					shadow.x = value[0];
					shadow.y = value[1];
					break;
				case 3:
					shadow.x = value[0];
					shadow.y = value[1];
					shadow.radius = value[2];
					break;
			}
			if ((!shadow.x && !shadow.y && !shadow.radius) || shadow.color == 'transparent') {
				shadow.x = shadow.y = shadow.radius = 0;
				shadow.color = null;
			}
		}

		return shadow;
	};

	$.fn.textShadowRemove = function() {
		if (!$.browser.msie) return;
		return this.each(function() {
			$(this).children("span.jQueryTextShadow").remove();
		});
	};

	textShadowMap = function(value, fnc) {
		var a = new Array(value.length);
		for (var i = 0; i < value.length; i++) {
			a[i] = fnc(value[i]);
		}
		return a;
	}

