var gService = false;
var gTimeZone = -6;
// Code section for Enable First-Party Cookie Tracking
// Code section for Use the new first-party cookie generated with this tag.
var gFpc="WT_FPC";
var gWtId="";
var gTempWtId="";
var gConvert=true;

var gImages=new Array;
var gIndex=0;
var DCS=new Object();
var WT=new Object();
var DCSext=new Object();
var gQP=new Array();

// Added by JJA - 11/14/07
// Array stores what fields have been tracked and is used to surpress duplicate submissions.
var fieldsTracked=new Array();

function dcsCookie(){
	if (typeof(dcsOther)=="function"){
		dcsOther();
	}
	else if (typeof(dcsPlugin)=="function"){
		dcsPlugin();
	}
	else if (typeof(dcsFPC)=="function"){
		dcsFPC(gTimeZone);
	}
}
function dcsGetCookie(name){
	var pos=document.cookie.indexOf(name+"=");
	if (pos!=-1){
		var start=pos+name.length+1;
		var end=document.cookie.indexOf(";",start);
		if (end==-1){
			end=document.cookie.length;
		}
		return unescape(document.cookie.substring(start,end));
	}
	return null;
}
function dcsGetCrumb(name,crumb){
	var aCookie=dcsGetCookie(name).split(":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsGetIdCrumb(name,crumb){
	var cookie=dcsGetCookie(name);
	var id=cookie.substring(0,cookie.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsFPC(offset){
	if (typeof(offset)=="undefined"){
		return;
	}
	var name=gFpc;
	var dCur=new Date();
	dCur.setTime(dCur.getTime()+(dCur.getTimezoneOffset()*60000)+(offset*3600000));
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	if (document.cookie.indexOf(name+"=")!=-1){
		var id=dcsGetIdCrumb(name,"id");
		var lv=parseInt(dcsGetCrumb(name,"lv"));
		var ss=parseInt(dcsGetCrumb(name,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	else{
		var tmpname=name+"_TMP=";
		document.cookie=tmpname+"1";
		if (document.cookie.indexOf(tmpname)!=-1){
			document.cookie=tmpname+"; expires=Thu, 01-Jan-1970 00:00:01 GMT";
			if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
				WT.co_f=gWtId;
			}
			else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
				WT.co_f=gTempWtId;
				WT.vt_f="1";
			}
			else{
				WT.co_f="2";
				var cur=dCur.getTime().toString();
				for (var i=2;i<=(32-cur.length);i++){
					WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
				}
				WT.co_f+=cur;
				WT.vt_f="1";
			}
			if (typeof(gWtAccountRollup)=="undefined"){
				WT.vt_f_a="1";
			}
			WT.vt_f_s="1";
			WT.vt_f_d="1";
		}
		else{
			WT.vt_f="2";
			WT.vt_f_a="2";
			return;
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vt_sid=WT.co_f+"."+dSes.getTime();
	var expiry="; expires="+dExp.toGMTString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+dCur.getTime().toString()+":ss="+dSes.getTime().toString()+expiry+"; path=/"+(((typeof(gFpcDom)!="undefined")&&(gFpcDom!=""))?("; domain="+gFpcDom):(""));
}


function dcsAdv(){
	dcsFunc("dcsET");
	dcsFunc("dcsCookie");
	dcsFunc("dcsAdSearch");
	dcsFunc("dcsTP");
}

// WebTrends SmartSource Data Collector
// Copyright (c) 1996-2005 WebTrends Inc. All rights reserved.
// $DateTime: 2005/05/03 12:06:24 $
function dcsMultiTrack(){
    for (var i=0;i<arguments.length;i++){
        if (arguments[i].indexOf('WT.')==0){
            // Added by JJA - 11/14/07
            // Surpress duplicate web form field submissions.
            if (arguments[i].substring(3).indexOf('ti')==0)
            {
                if (arguments[i+1].substring(0, 3).indexOf('###') == 0)
                {
					if (wasFieldTracked(arguments[i+1])) {
						return;
					}
					else
					{
						fieldsTracked[fieldsTracked.length]=arguments[i+1];
						
						WT[arguments[i].substring(3)]=arguments[i+1].substring(3);
					}
                }
                else
                {
					WT[arguments[i].substring(3)]=arguments[i+1];
				}
            }
            else
			{
				WT[arguments[i].substring(3)]=arguments[i+1];
			}
			
            i++;
        }
        if (arguments[i].indexOf('DCS.')==0){
            DCS[arguments[i].substring(4)]=arguments[i+1];
            i++;
        }
        if (arguments[i].indexOf('DCSext.')==0){
            DCSext[arguments[i].substring(7)]=arguments[i+1];
            i++;
        }
    }
    var dCurrent=new Date();
    DCS.dcsdat=dCurrent.getTime();
    dcsTag();
}

function dcsVar(){
	var dCurrent=new Date();
	WT.tz=dCurrent.getTimezoneOffset()/60*-1;
	if (WT.tz==0){
		WT.tz="0";
	}
	WT.bh=dCurrent.getHours();
	WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
	if (typeof(screen)=="object"){
		WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
		WT.sr=screen.width+"x"+screen.height;
	}
	if (typeof(navigator.javaEnabled())=="boolean"){
		WT.jo=navigator.javaEnabled()?"Yes":"No";
	}
	if (document.title){
		WT.ti=document.title;
	}
	WT.js="Yes";
	if (typeof(gVersion)!="undefined"){
		WT.jv=gVersion;
	}
	if (document.body&&document.body.addBehavior){
		document.body.addBehavior("#default#clientCaps");
		if (document.body.connectionType){
			WT.ct=document.body.connectionType;
		}
		document.body.addBehavior("#default#homePage");
		WT.hp=document.body.isHomePage(location.href)?"1":"0";
	}
	if (parseInt(navigator.appVersion)>3){
		if ((navigator.appName=="Microsoft Internet Explorer")&&document.body){
			WT.bs=document.body.offsetWidth+"x"+document.body.offsetHeight;
		}
		else if (navigator.appName=="Netscape"){
			WT.bs=window.innerWidth+"x"+window.innerHeight;
		}
	}
	WT.fi="No";
	if (window.ActiveXObject){
		if ((typeof(gFV)!="undefined")&&(gFV.length>0)){
			WT.fi="Yes";
			WT.fv=gFV;
		}
	}
	else if (navigator.plugins&&navigator.plugins.length){
		for (var i=0;i<navigator.plugins.length;i++){
			if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1){
				WT.fi="Yes";
				WT.fv=navigator.plugins[i].description.split(" ")[2];
				break;
			}
		}
	}
	WT.sp="@@SPLITVALUE@@";
	DCS.dcsdat=dCurrent.getTime();
	DCS.dcssip=window.location.hostname;
	DCS.dcsuri=window.location.pathname;
	if (window.location.search){
		DCS.dcsqry=window.location.search;
		if (gQP.length>0){
			for (var i=0;i<gQP.length;i++){
				var pos=DCS.dcsqry.indexOf(gQP[i]);
				if (pos!=-1){
					var front=DCS.dcsqry.substring(0,pos);
					var end=DCS.dcsqry.substring(pos+gQP[i].length,DCS.dcsqry.length);
					DCS.dcsqry=front+end;
				}
			}
		}
	}
	if ((window.document.referrer!="")&&(window.document.referrer!="-")){
		if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
			DCS.dcsref=window.document.referrer;
		}
	}
}

function A(N,V){
	return "&"+N+"="+dcsEscape(V);
}

function dcsEscape(S){
	if (typeof(RE)!="undefined"){
		var retStr = new String(S);
		for (R in RE){
			retStr = retStr.replace(RE[R],R);
		}
		return retStr;
	}
	else{
		return escape(S);
	}
}

function dcsCreateImage(dcsSrc){
	if (document.images){
		gImages[gIndex]=new Image;
		if ((typeof(gHref)!="undefined")&&(gHref.length>0)){
			gImages[gIndex].onload=gImages[gIndex].onerror=dcsLoadHref;
		}
		gImages[gIndex].src=dcsSrc;
		gIndex++;
	}
	else{
		document.write('<IMG BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
	}
}

function dcsMeta(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		for (var i=1;i<=elems.length;i++){
			var meta=elems.item(i-1);
			if (meta.name){
				if (meta.name.indexOf('WT.')==0){
					WT[meta.name.substring(3)]=meta.content;
				}
				else if (meta.name.indexOf('DCSext.')==0){
					DCSext[meta.name.substring(7)]=meta.content;
				}
				else if (meta.name.indexOf('DCS.')==0){
					DCS[meta.name.substring(4)]=meta.content;
				}
			}
		}
	}
}

function dcsTag(){
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+(gDcsId==""?'':'/'+gDcsId)+"/dcs.gif?";
	for (N in DCS){
		if (DCS[N]) {
			P+=A(N,DCS[N]);
		}
	}
	for (N in WT){
		if (WT[N]) {
			P+=A("WT."+N,WT[N]);
		}
	}
	for (N in DCSext){
		if (DCSext[N]) {
			P+=A(N,DCSext[N]);
		}
	}
	if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0){
		P=P.substring(0,2040)+"&WT.tu=1";
	}
	dcsCreateImage(P);
}

function dcsFunc(func){
	if (typeof(window[func])=="function"){
		window[func]();
	}
}

// Added by JJA - 11/14/07
// Check if field was previously tracked.
function wasFieldTracked(name)
{
    for (var i=0; i<fieldsTracked.length; i++)
    {
        if (fieldsTracked[i]==name) {
            return true;
        }
    }
    
    return false;
}

/*	
The following five lines of code must be included in the file for licensing reasons.  There is a forwarded email To: Uma from the author explaining this.
JavaScript Function Monitor	
Copyright 2000 - 2006. All Rights Reserved.	
Author: Stephen W. Cote	
Email: sw.cote@gmail.com	
Project: http://www.imnmotion.com/projects/funmon/
*/
/*
    <example>
    <name>Monitor a Function With Window Reference</name>
    <description>Register a function to be monitored using a window reference.  This is used for referencing functions in other frames, or when monitoring functions where the <i>this</i> reference is needed. Note that the <i>Object.prototype</i> syntax must be present to monitor a prototyped function.  While the windowRef parameter can be used to register a function on a specific script object defined within a hash, that function registration cannot later be removed.</description>
    <syntax>FunctionMonitor.register(sName, vWindow, sClass);</syntax>
    <code>function ObjectClass(){</code>
    <code>   this.name = "test object";</code>
    <code>}</code>
    <code>ObjectClass.prototype.doAction = function(){</code>
    <code>   alert(this.name);</code>
    <code>   // do something</code>
    <code>}</code>
    <code>var oObj = new ObjectClass();</code>
    <code>FunctionMonitor.register("doAction",window,"ObjectClass");</code>
    <code>oObj.doAction();</code>
    </example>

    <example>
    <name>Stop monitoring a Function With Window Reference</name>
    <description>Unregister a function from being monitored using a window reference.</description>
    <syntax>FunctionMonitor.register(sName, vWindow, sClass);</syntax>
    <code>function ObjectClass(){</code>
    <code>   this.name = "test object";</code>
    <code>}</code>
    <code>ObjectClass.prototype.doAction = function(){</code>
    <code>   alert(this.name);</code>
    <code>   // do something</code>
    <code>}</code>
    <code>// where FunctionMonitor.register was previously used</code>
    <code>FunctionMonitor.unregister("doAction",window,"ObjectClass");</code>

    </example>

    <example implementation="1">
    <name>Implement FunctionMonitor</name>
    <description>Implement this package on a Web page.</description>
    <code><![CDATA[<script type = "text/javascript" src = "FunMon2.js"></script>]]></code>
    </example>

    <example>
    <name>Monitor a Function</name>
    <description>Register a function to be monitored.</description>
    <syntax>FunctionMonitor.register(sName);</syntax>
    <code>function MonitorThis(){</code>
    <code>   // Some code</code>
    <code>}</code>
    <code>FunctionMonitor.register("MonitorThis");</code>
    </example>

    <example>
    <name>Stop Monitoring a Function</name>
    <description>Unregister a function from being monitored.</description>
    <syntax>FunctionMonitor.unregister(sName);</syntax>
    <code>function MonitorThis(){</code>
    <code>   // Some code</code>
    <code>}</code>
    <code>// where FunctionMonitor.register was previously used</code>
    <code>FunctionMonitor.unregister("MonitorThis");</code>
    </example> 

    <object private="1" internal = "1">
    <name>Metric</name>
    <description>Object representing a function metric.</description>
    <property name = "start" type = "int">Start time of the metric in milliseconds.</property>
    <property name = "stop" type = "int">Stop time of the metric in milliseconds.</property>
    <property name = "valOffset" type = "int">Difference between function execution time and internal execution time in milliseconds.</property>
    <property name = "route" type = "String">String representing the function trace.</property>
    <property name = "monStatus" type = "int">Integer identifying the stat the variant object identifier.</property>
    <property name = "duration" type = "int">Not used.</property>
    <property name = "caller" type = "function">Pointer to the caller of the this monitored instance.</property>
    <property name = "parentName" type = "String">Not used.</property>
    </object>

    <object private="1" internal = "1">
    <name>FunctionStore</name>
    <description>Object representing a stored function reference.</description>
    <property name = "name" type = "String">Name of the function</property>
    <property name = "classRef" type = "String">Name of the parent or prototype class.</property>
    <property name = "refName" type = "String">Name of the window reference.</property>
    <property name = "ref" type = "object">Pointer to the window reference.</property>
    <property name = "fp" type = "function">Pointer to the original function.</property>
    <property name = "index" type = "int">Index into the reverse function map.</property>
    <property name = "metrics" type = "array">Array of collected Metric objects.</property>
    <property name = "stackCount" type = "int">Current marker into the metric stack.</property>
    </object>
*/

NRT.WebTrends.FunctionMonitor = function()
{

	return {

		/// <property type = "String" get = "1">
		/// <name>version</name>
		/// <description>The version of the class.</description>
		/// </property>
		///	
		version:"2.0",

		/// <property type = "array" get = "1" private = "1">
		/// <name>functions</name>
		/// <description>Array of monitored functions.</description>
		/// </property>
		///
		functions:[],

		/// <property type = "array" get = "1" private = "1">
		/// <name>function_index</name>
		/// <description>Reverse lookup array of monitored functions.</description>
		/// </property>
		///
		function_index:[],

		/// <property type = "int" get = "1" set = "1" default = "20">
		/// <name>stack_len</name>
		/// <description>Maximum number of records to store before overwriting previous values.</description>
		/// </property>
		///
		stack_len:20,

		/// <property type = "boolean" get = "1" set = "1" default = "true">
		/// <name>hold_max</name>
		/// <description>Bit indicating whether stored values should not be overwritten if new values are less than the stored values.</description>
		/// </property>
		///
		hold_max:1,

		/// <method>
		/// <name>unregister</name>
		/// <param name="sName" type="String">name of the monitored function</param>
		/// <param name="oWindow" type="object" optional = "1">object reference to a browser window.</param>
		/// <param name = "sClass" type = "String" optional = "1">name of the class prototype to which the function belongs.</param>
		/// <description>Unregisters a monitored function.</description>
		/// </method>
		///
		unregister : function(sFunctionName,windowRef,sClassRef)
		{
			var oFrame=window, sFrameName="window", sRefer = "", sFuncStore, vFP, iIndex,vPFP;
			if(windowRef && windowRef!==window) 
			{
			    oFrame=windowRef;
			}
				
			if(sFrameName!=="window")
			{
			    sRefer=sFrameName + "-";
			}
			if(sClassRef)
			{
			    sRefer+=sClassRef + "--";
			}
			sFuncStore="dispatch-" + sRefer + sFunctionName;


			vFP=this.functions[sFuncStore];
	
			if(!vFP)
			{
				alert(sFuncStore + " is not a monitored function");
				return;
			}
	
	
			iIndex=vFP.index;
			NRT.WebTrends.FunctionMonitor.function_index[iIndex]=null;	

			if(!sClassRef)
			{
				if(oFrame[sFunctionName])
				{
					oFrame[sFunctionName]=vFP.fp;
				}
				else
				{
					alert(sFunctionName + " does not exist");
				}
			}
			else
			{
				if(oFrame[sClassRef].prototype[sFunctionName])
				{
					oFrame[sClassRef].prototype[sFunctionName]=vFP.fp;
				}
				else
				{
					alert(sClassRef + "." + sFunctionName + " does not exist.");
				}
			}

			if(!NRT.WebTrends.FunctionMonitor[sFuncStore])
			{
				alert(sFuncStore + " does not have a monitor definition.");
				return;
			}

			vPFP=this[sFuncStore];
			if(oFrame.onload===vPFP)
			{ 
			    oFrame.onload=vFP.fp;
			}
			NRT.WebTrends.FunctionMonitor[sFuncStore]=null;
			NRT.WebTrends.FunctionMonitor._pack();
		},

		/// <method private = "1" internal = "1">
		/// <name>_pack</name>
		/// <description>Collapses the functions and function_index arrays.</description>
		/// </method>
		///
		_pack:function()
		{
			var aTemp1=NRT.WebTrends.FunctionMonitor.functions, aTemp2=NRT.WebTrends.FunctionMonitor.function_index, iL, i=0, iIndex, vD;
			NRT.WebTrends.FunctionMonitor.functions=[];
			NRT.WebTrends.FunctionMonitor.function_index=[];
			iL=aTemp2.length;
			for(;i<iL;i+=1)
			{
				if(aTemp2[i]!==null)
				{
					iIndex=NRT.WebTrends.FunctionMonitor.function_index.length;
					NRT.WebTrends.FunctionMonitor.function_index[iIndex]=aTemp2[i];
					vD=aTemp1[aTemp2[i]];
					vD.index=iIndex;
					NRT.WebTrends.FunctionMonitor.functions[aTemp2[i]]=vD;
				}
			}
		},

		/// <method>
		/// <name>register</name>
		/// <param name="sName" type="String">name of the monitored function</param>
		/// <param name="oWindow" type="object" optional = "1">object reference to a browser window.</param>
		/// <param name = "sClass" type = "String" optional = "1">name of the class prototype to which the function belongs.</param>
		/// <description>Registers a function to be monitored.</description>
		/// </method>
		///
		register:function(sFunctionName,windowRef,sClassRef)
		{
			var oFrame=window,sFrameName="window", vFP, sRefer="", sFuncStore, iIndex=-1;
			if(windowRef)
			{
				if(windowRef!==window)
				{
					oFrame=windowRef;
					if(oFrame.name)
					{
						sFrameName=oFrame.name;
					}
					else
					{
						sFrameName="frame";
					}
				}
			}
	
			if(!sClassRef)
			{
				vFP=oFrame[sFunctionName];
			}
			else
			{
				vFP=oFrame[sClassRef];
				if(vFP)
				{
					if(vFP.prototype) 
					{
					    vFP=vFP.prototype[sFunctionName];
					}
					else
					{
					    vFP = vFP[sFunctionName];
					}
				}
			}
	
			if(typeof(vFP)==="function")
			{
				if(sFrameName!=="window")
				{ 
				    sRefer=sFrameName + "-";
				}
				if(sClassRef)
				{ 
				    sRefer+=sClassRef + "--";
				}
				sFuncStore="dispatch-" + sRefer + sFunctionName;
				if(!NRT.WebTrends.FunctionMonitor.functions[sFuncStore])
				{
					iIndex=NRT.WebTrends.FunctionMonitor.function_index.length;
					NRT.WebTrends.FunctionMonitor.function_index[iIndex]=sFuncStore;
				}
				else
				{
					iIndex=NRT.WebTrends.FunctionMonitor.functions[sFuncStore].index;
				}
				NRT.WebTrends.FunctionMonitor.functions[sFuncStore] = 
					{name:sFunctionName,classRef:sClassRef,refName:sFrameName,ref:oFrame,fp:vFP,index:iIndex,metrics:[],stackCount:0};
				eval('NRT.WebTrends.FunctionMonitor["' + sFuncStore + '"]=function(){return NRT.WebTrends.FunctionMonitor.dispatch("' + sFuncStore + '",this,arguments);}');

				if(!sClassRef)
				{
					oFrame[sFunctionName]=NRT.WebTrends.FunctionMonitor[sFuncStore];
				}
				else
				{
					if(oFrame[sClassRef].prototype)
					{
					     oFrame[sClassRef].prototype[sFunctionName]=NRT.WebTrends.FunctionMonitor[sFuncStore];
					}
					else 
					{
					    oFrame[sClassRef][sFunctionName]=NRT.WebTrends.FunctionMonitor[sFuncStore];
					}
				}
		
				if(oFrame.onload===vFP)
				{
				    oFrame.onload=NRT.WebTrends.FunctionMonitor[sFuncStore];
				}
			}
			else
			{
				alert(sFunctionName + " is not a function");
			}
		},
	

		
		/// <method private = "1" internal = "1">
		/// <name>dispatch</name>
		/// <param name = "sStoreName" type = "String">Internal lookup name for a monitored function.</param>
		/// <param name = "vThis" type = "variant">Pointer to the <i>this</i> object.</param>
		/// <param name = "aArgs" type = "array">Arguments passed to the function.</param>
		/// <return-value name = "v" type = "variant">Returns the value returned by the monitored function.</return-value>
		/// <description>Receives function calls, invokes the original function.</description>
		/// </method>
		///

	    dispatch : function(sFuncStore,vThis,aArgs)
	    {
		    var retVal, vFun = NRT.WebTrends.FunctionMonitor.functions[sFuncStore];

		    if(NRT.WebTrends.FunctionMonitor.dispatch.caller && NRT.WebTrends.FunctionMonitor.dispatch.caller.caller)
		    {
			    vCaller=NRT.WebTrends.FunctionMonitor.dispatch.caller.caller;
		    }

            NRT.WebTrends.Utility.HandleFunctionCall(vFun.name,aArgs);
            
		    if(!vFun.classRef)
		    {
			    retVal=vFun.fp.apply(vCaller,aArgs);
		    }
		    else
		    {
			    retVal=vFun.fp.apply(vThis,aArgs);
		    }

	        return retVal;
        }
	};
}();
/*
    </static-class>
    </package>
    </source>
 *//* ##########################################################################################################################

	Namespace : NRT.WebTrends
	Classes   : Utility
				MySite
				PropertySearch
	Summary	  : This file contains all the scripts to enable WebTrends tracking of dynamic content for
				a metro site.  Must be adjusted to work for each metro.
	Copyright : (c) 2006 NRT Inc. All rights reserved.

	RevisionHistory: 
	-------------------------------------------------------------------------------------------------------------------------
	Date		Name		Description
	-------------------------------------------------------------------------------------------------------------------------
	04/18/2007	tsutton		Initial Creation
	11/16/2007  janderson	Added two new classes (Utility/MySite) and refactored existing code.
	11/28/2007	janderson	Reworked how tracked content is reported.

###########################################################################################################################*/

[].indexOf || (Array.prototype.indexOf = function(v,n)
{
	n = (typeof(n) === "undefined" || n===null)?0:n;
	
	var m = this.length;
	
	for(var i = n; i < m; i++)
	{
		if(this[i] === v)
		{
			return i;
		}
	}
	return -1;
});


/***********************************************************************************************************
	Class		: Utility
	Summary		: Provides reusable functions shared by MySite & PropertySearch classes.
	Author		: Joshua Anderson
	Create Date	: 11/16/2007
************************************************************************************************************/
NRT.WebTrends.Utility = function()
{
	return {
		/*==================================================================================
			Method		: getTabButtons
			Summary		: Returns an object reference to the DIV tag that contains the Tab buttons.
			Author		: Joshua Anderson
			Create Date	: 11/16/2007
		====================================================================================*/	
		getTabButtons: function()
		{
			return NRT.Utility.getElementByTagNameAndID('div_Tabs','DIV');
		},
		
		/*==================================================================================
			Method		: HandleFunctionCall
			Summary		: Sends to webtrends details of Monitored functions registered 
						  by NRT.WebTrends.FunctionMonitor.register.
			              Actually called by NRT.WebTrends.FunctionMonitor.dispatch
			              This function analyzes which function was called.
			parameters  : functName - Name of the monitored function that was called
			            : args - the arguments that were passed to the monitored function
			Author		: Joshua Anderson
			Create Date	: 11/16/2007
			Modified	: 11/28/2007 - JJA, Added code to handle Registration.
		====================================================================================*/															
		HandleFunctionCall: function (functName,args)
		{
		    try
		    {
	             //Check for parameters
		        if(functName === "redirectToPropertyResultsPage" && args && args.length > 1)
		        {
					switch (args[1])
                    {
                        case 0:
							// All Matches
							NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'SavedSearch',null,'Saved Search - All Matches','4');
						break;
						case 1:
							// Today's matches
							NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'SavedSearch',null,'Saved Search - Today Matches','4');
						break;
						case 2:
							// Since Last Login
							NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'SavedSearch',null,'Saved Search - New Matches Since Last Login','4');
						break;
                    }
		        }
		        else if(functName==="redirectToMySavedSearches")
		        {
					NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'TabSelected',null,'My Saved Searches Tab','3');
				}
				else if(functName==="redirectToMySavedProperties")
		        {
					NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'TabSelected',null,'My Saved Properties Tab','3');
				}
				else if(functName==="redirectToMyAccount")
		        {
					NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'TabSelected',null,'My Saved Account Tab','3');
				}
		        else if(functName==="handleDidYouMeanCheckboxSelect")
		        {
					NRT.WebTrends.Utility.track(NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - Did You Mean',NRT.WebTrends.PropertySearch.getOwnerName(),'DidYouMean_LocationSelected',null,'Location Selected','6;2');
		        }
		        else if(functName==="setSelectedCommunitySelectionTextStyle")
		        {
		        	if (args && args.length > 0)
		        	{
		        		if (args[0].checked === true)
		        		{
		        			NRT.WebTrends.Utility.track(NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - Community',NRT.WebTrends.PropertySearch.getOwnerName(),'Community_LocationSelected',null,'Location Selected','6;2');
		        		}
		        	}
		        }
		        else if(functName==="handleSelectFromListLocationsClick")
		        {
		        	NRT.WebTrends.Utility.track(NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - No Locations Found',NRT.WebTrends.PropertySearch.getOwnerName(),'NoLocationsFound_SelectFromList',null,'Select From List Clicked','6;2');
		        }
		        else if(functName==="removeLocationFromSelectedLists")
	            {
	        	    NRT.WebTrends.Utility.track(NRT.WebTrends.PropertySearch.getScenarioName(),NRT.WebTrends.PropertySearch.getOwnerName(),'RemoveLocation',null,'Location Removed','8');
	            }
		        else if(args && args.length > 0 && typeof(args[0]) === "string")
		        {
					var _splitArgs = [];
					var _arg = [];
					var i = 0;
					var _scenario = "";
					var _name = "";
		            
					_splitArgs = args[0].split("&");
					for (i=0;i<_splitArgs.length;i++)
					{
						_arg = _splitArgs[i].split("=");
						
						// showLayeredPage function.  Figure out what kind of dialog and attach listeners to the controls.
						if (_arg[0] === "controlType")
						{
							// Add Handlers for buttons on the layered Dialog
							switch (_arg[1])
							{
								case "Registration" :
									YAHOO.util.Event.on("imgRegister", "click", NRT.WebTrends.MySite.HandleRegistrationButtons,"Register");
									YAHOO.util.Event.on("img1", "click", NRT.WebTrends.MySite.HandleRegistrationButtons,"Cancel");
									
									NRT.WebTrends.Utility.track(NRT.WebTrends.MySite.getScenarioName(),NRT.WebTrends.MySite.getOwnerName(),'Registration',null,'Sign Up Dialog','1');
		                        break;
		                        case "DidYouMean" :
									_name="Did You Mean";
									_scenario=NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - '+_name;
									
									YAHOO.util.Event.on("ct100_img_DidYouMean_Continue", "click", NRT.WebTrends.PropertySearch.HandleDidYouMeanButtons,"Continue");
									YAHOO.util.Event.on("img_DidYouMean_Cancel", "click", NRT.WebTrends.PropertySearch.HandleDidYouMeanButtons,"Cancel");
									
									NRT.WebTrends.Utility.track(_scenario,NRT.WebTrends.PropertySearch.getOwnerName(),_name.replace(/ /g,""),null,'Did You Mean Dialog','5;1');
		                        break;
		                        case "CommunitySelection" :
									_name="Community";
									_scenario=NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - '+_name;
									
									YAHOO.util.Event.on("img_CommunitySelection_Continue", "click", NRT.WebTrends.PropertySearch.HandleCommunityButtons,"Continue");
									YAHOO.util.Event.on("img_CommunitySelection_Cancel", "click", NRT.WebTrends.PropertySearch.HandleCommunityButtons,"Cancel");
									
									NRT.WebTrends.Utility.track(_scenario,NRT.WebTrends.PropertySearch.getOwnerName(),_name.replace(/ /g,""),null,'Community Dialog','5;1');
		                        break;
		                        case "NoLocationsFound" :
									_name="No Locations Found";
									_scenario=NRT.WebTrends.PropertySearch.getScenarioName()+';Property Search - '+_name;
									
									YAHOO.util.Event.on("img_NoLocationsFound_OK", "click", NRT.WebTrends.PropertySearch.HandleNoLocationButtons,"OK");
									
									NRT.WebTrends.Utility.track(_scenario,NRT.WebTrends.PropertySearch.getOwnerName(),_name.replace(/ /g,""),null,'No Locations Found Dialog','5;1');
		                        break;
							}
						}
					}
				}
		    }
		    catch (err)
		    {
		        return;
		    }
		},	
		
		/*==================================================================================
			Method		: track
			Summary		: 
			Author		: Joshua Anderson
			Create Date	: 12/03/2007
		====================================================================================*/	
		track: function(scenario, oUri, sUri, queryStr, title, step)
		{
			try
			{
				if (queryStr === null)
				{
					queryStr = '';
				}
				
				var callstr = "dcsMultiTrack('DCS.dcsuri','/WT_"+oUri+"_"+sUri+".htm"+this.encodeQueryString(queryStr)+"','WT.ti','"+title+"','WT.si_n','"+scenario+"','WT.si_x','"+step+"'";
				
				if (arguments.length > 6)
				{
					for (var i=6; i<arguments.length;i++)
					{
						callstr += ',"'+arguments[i]+'","'+arguments[i+1]+'"';
						
						i++;
					}
				}
				
				callstr += ')';
				
				eval(callstr);
			}
			catch(err)
			{
				_oErrorHandler.Error('NRT.WebTrends.Utility.track', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}
		},
		
		/*==================================================================================
			Method		: encodeQueryString
			Summary		: 
			Author		: Joshua Anderson
			Create Date	: 12/03/2007
		====================================================================================*/	
		encodeQueryString: function(queryStr)
		{
			return queryStr.replace(/\?/g,"%3F").replace(/&/g,"%26");
		}
	};		
}(); 


/***********************************************************************************************************
	Class		: MySite
	Summary		: Provides functions that handle tracking of MySite specific AJAX and dynamic content.
	Author		: Joshua Anderson
	Create Date	: 11/16/2007
************************************************************************************************************/
NRT.WebTrends.MySite = function()
{
	var _sName = "MySite";
	var _oName = "MySite";
	
	return {
		/*--------------------------------------------------------------------
		-						PUBLIC PROPERTIES
		---------------------------------------------------------------------*/
		getScenarioName: function()
		{
			return _sName;
		},
		
		getOwnerName: function()
		{
			return _oName;
		},
		
		/*--------------------------------------------------------------------
		-						PUBLIC METHODS
		---------------------------------------------------------------------*/
		
		/*==================================================================================
			Method		: clickTabControl
			Summary		: Gets which tab was selected and send off a webtrends response
			Author		: Joshua Anderson
			Create Date	: 11/16/2007
		====================================================================================*/														
		clickTabControl: function(e) 
		{
			try
			{
			    switch(_oTab.tabSelected()) 
			    {
				    case 0 : 
			            NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'My Saved Searches Tab','3');
				        break;
				    case 1 : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'My Saved Properties Tab','3');
					    break;
				    case 2 : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'My Saved Account Tab','3');
					    break;
				}
			}
			catch(err)
			{
//				_oErrorHandler.Error('NRT.WebTrends.MySite.clickTabControl', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}
		},
		
		/*==================================================================================
			Method		: HandleRegistrationButtons
			Summary		: Sends off to webtrends when the Continue or Cancel button of the "Sign Up" Dialog are clicked.
			Author		: Jim Kern
			Create Date	: 07/27/2007
			Modified	: 11/16/2007 - JJA, Removed duplicate code and replaced with shared function call.
						  11/28/2007 - JJA, Moved to MySite class.
		====================================================================================*/															
		HandleRegistrationButtons: function(e,objref) 
		{
			NRT.WebTrends.Utility.track(_sName,_oName,'RegistrationButton',null,objref+' Button','2');
		},
			
		/*==================================================================================
			Method		: initListener
			Summary		: Setup listeners for control selection
			Author		: Joshua Anderson
			Create Date	: 11/16/2007
			Modified	: 11/28/2007 - JJA, Added monitoring of showLayeredPage function.
		====================================================================================*/															
		initListener: function()
		{
		    try
		    {
		        //Setup panels/tabs.    
		        if (typeof(_oTab) !== "undefined" && _oTab !== null)
		        {
					if (_oTab.sourceName() !== "ucPropertySearch")
					{
						YAHOO.util.Event.on(NRT.WebTrends.Utility.getTabButtons(), "click", NRT.WebTrends.MySite.clickTabControl);
					}
				}
				
				//  The following registers function calls that are not immediately accessible.
			    NRT.WebTrends.FunctionMonitor.register("redirectToPropertyResultsPage",NRT.MySite,"UI");
			    NRT.WebTrends.FunctionMonitor.register("redirectToMySavedSearches",NRT.MySite,"UI");
			    NRT.WebTrends.FunctionMonitor.register("redirectToMySavedProperties",NRT.MySite,"UI");
			    NRT.WebTrends.FunctionMonitor.register("redirectToMyAccount",NRT.MySite,"UI");
	        }
		    catch (err)
	        {
	            return;
	        }
	    }
	};		
}();


/***********************************************************************************************************
	Class		: PropertySearch
	Summary		: Provides functions that handle tracking of PropertySearch specific AJAX and dynamic content.
	Author		: Joshua Anderson
	Create Date	: 11/16/2007
************************************************************************************************************/
NRT.WebTrends.PropertySearch = function()
{
	var _sName = "Property Search";
	var _oName = "PS";
	
	return {
		/*--------------------------------------------------------------------
		-						PUBLIC PROPERTIES
		---------------------------------------------------------------------*/
		getScenarioName: function()
		{
			return _sName;
		},
		
		getOwnerName: function()
		{
			return _oName;
		},
		
		/*--------------------------------------------------------------------
		-						PRIVATE PROPERTIES
		---------------------------------------------------------------------*/
		getCZStateControl: function()
		{
			return NRT.Utility.getElementByTagNameAndID('ctl00_ctl00_MenuAndPageContent_MainContent_ucPropertySearch_ucCityZip_ucCityZipTypeIn_ucStateRegion_tbl_StateRegion','TABLE').getElementsByTagName('input');
		},
		
		getNCStateControl: function()
		{
			return NRT.Utility.getElementByTagNameAndID('ctl00_ctl00_MenuAndPageContent_MainContent_ucPropertySearch_ucNearbyCities_ucStateRegion_tbl_StateRegion','TABLE').getElementsByTagName('input');
		},
		
		/*--------------------------------------------------------------------
		-						PUBLIC METHODS
		---------------------------------------------------------------------*/
		
		/*==================================================================================
			Method		: clickTabControl
			Summary		: Gets which tab was selected and send off a webtrends response
			Author		: Todd Sutt
			Create Date	: 04/18/2007
		====================================================================================*/														
		clickTabControl: function(e) 
		{
	        var _typeSelect="TypeIn";
	        var oDivCZTI;
			try
			{
	            oDivCZTI = _oUtility.getElementByTagNameAndID('div_CityZip_TypeIn','DIV');
                if (oDivCZTI!==null)
                {
                    if (oDivCZTI.className==='hideDiv')
                    {
                        _typeSelect="Location";
                    }
		        }

			    switch(_oTab.tabSelected()) 
			    {
				    case 0 : 
		                NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'City/Zip Tab','1');
		                
		                if (_typeSelect==="Location")
		                {
			                NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Select Location from List','2');
						}
			            else
						{
	                        NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Type In Location','2');
	                    }
			            break;
				    case 1 : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'Nearby Cities Tab','1');
					    break;
				    case 2 : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'Address Tab','1');
					    break;
				    case 3 : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'MLS Tab','1');
					    break;
				    default : 
					    NRT.WebTrends.Utility.track(_sName,_oName,'TabSelected',null,'City/Zip Tab','1');
		                
		                if (_typeSelect==="Location")
		                {
			                NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Select Location from List','2');
			            }
			            else
			            {
	                        NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Type In Location','2');
	                    }
				}
			}
			catch(err)
			{
//				_oErrorHandler.Error('NRT.WebTrends.PropertySearch.clickTabControl', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}
		},

		/*==================================================================================
			Method		: clickCityZipSelection
			Summary		: Sends of to webtrends which CityZip Selection Method was clicked
			Author		: Todd Sutton
			Create Date	: 04/18/2007
			Modified	: 11/16/2007 - JJA, Added code to track County select list.
		====================================================================================*/															
		clickCityZipSelection: function(e) 
		{
		    var elTarget = YAHOO.util.Event.getTarget(e);
		    	
			try
			{
				//get the resolved (non-text node) target:
				while (elTarget.id !== "div_CityZip_Selection") 
				{
					if(elTarget.id === "lblLocationList") 
					{
						YAHOO.util.Event.on("ctl01_lst_CityZipLocationList_Counties", "change", NRT.WebTrends.PropertySearch.clickCountyControl);
						
						NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Select Location from List','2');
						break;
					}
					else if( elTarget.id === "lblTypeIn") 
					{
						NRT.WebTrends.Utility.track(_sName,_oName,'SelectLocationMethod',null,'Type In Location','2');
						break;
					} 
					else 
					{
						//wasn't the container, but wasn't an li; so
						//let's step up the DOM and keep looking:
						elTarget = elTarget.parentNode;
					}
				}
			}
			catch(err)
			{
//				_oErrorHandler.Error('NRT.WebTrends.PropertySearch.clickCityZipSelection', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}
		},
	
		/*==================================================================================
			Method		: clickStateControl
			Summary		: Sends off to webtrends when the state selection radio button list was clicked
			Author		: Lee Neisen
			Create Date	: 07/02/2007
		====================================================================================*/															
		clickStateControl: function(e) 
		{
			NRT.WebTrends.Utility.track(_sName,_oName,'StateSelected',null,'State Selected','3');
		},
		
		/*==================================================================================
			Method		: clickCountyControl
			Summary		: Sends off to webtrends when the county select list was clicked
			Author		: Jim Kern
			Create Date	: 07/27/2007
		====================================================================================*/															
		clickCountyControl: function(e) 
		{
			NRT.WebTrends.Utility.track(_sName,_oName,'CountySelected',null,'County Selected','4');
		},
		
		/*==================================================================================
			Method		: HandleDidYouMeanButtons
			Summary		: Sends off to webtrends when the Continue or Cancel button of the "Did You Mean" Dialog are clicked.
			Author		: Lee Neisen
			Create Date	: 07/16/2007
			Modified	: 11/16/2007 - JJA, Removed duplicate code and replaced with shared function call.
		====================================================================================*/															
		HandleDidYouMeanButtons: function(e,objref) 
		{
			NRT.WebTrends.Utility.track(_sName+';Property Search - Did You Mean',_oName,'DidYouMeanButton',null,objref+' Button','7;3');
		},	
			
		/*==================================================================================
			Method		: HandleCommunityButtons
			Summary		: Sends off to webtrends when the Continue or Cancel button of the "Did You Mean" Dialog are clicked.
			Author		: Lee Neisen
			Create Date	: 07/16/2007
			Modified	: 11/16/2007 - JJA, Removed duplicate code and replaced with shared function call.
		====================================================================================*/															
		HandleCommunityButtons: function(e,objref) 
		{
			NRT.WebTrends.Utility.track(_sName+';Property Search - Community',_oName,'CommunityButton',null,objref+' Button','7;3');
		},
							
		/*==================================================================================
			Method		: HandleNoLocationButtons
			Summary		: Sends off to webtrends when the OK or Select from list Link of the "No Locations found box" Dialog are clicked.
			Author		: Lee Neisen
			Create Date	: 07/16/2007
			Modified	: 11/16/2007 - JJA, Removed duplicate code and replaced with shared function call.
		====================================================================================*/															
		HandleNoLocationButtons: function(e,objref) 
		{
			NRT.WebTrends.Utility.track(_sName+';Property Search - No Locations Found',_oName,'NoLocationsFoundButton',null,objref+' Button','7;3');
		},		
		
		/*==================================================================================
			Method		: sendSearchButtonWebTrends
			Summary		: Sends to webtrends which CityZip Selection Method was active when search button was clicked
			Author		: Todd Sutton
			Create Date	: 04/18/2007
			Modified    : Lee Neisen - Add location count and other relevant information.
		====================================================================================*/															
		sendSearchButtonWebTrends: function ()
		{
		    var locs;
			var count="0";
			var doc;
			var parser;
			var mlsText=[];
			
			try
			{
				if (_oSearchCriteria !== null)  
				{
					if (_oSearchCriteria.LocationXML!==null) 
					{
						 // Count the locations selected.
						// code for IE
						if (window.ActiveXObject)
						{
							doc=new ActiveXObject("Microsoft.XMLDOM");
							doc.async="false";
							doc.loadXML(_oSearchCriteria.LocationXML);
						}
						// code for Mozilla, Firefox, Opera, etc.
						else
						{
						  parser=new DOMParser();
						  doc=parser.parseFromString(_oSearchCriteria.LocationXML,"text/xml");
						}
						locs=doc.selectNodes("//location");
						count=locs.length.toString();
					}
					else if (_oSearchCriteria.MlsNumber!==null)
					{
						mlsText = _oSearchCriteria.MlsNumber.ControlValue.split(",");
						count = mlsText.length.toString();
					}
					
					if (_oTab.tabSelected() === 0 || _oTab.tabSelected() === 1)
					{
						this.SendSelectedCriteria();
					}
					
					NRT.WebTrends.Utility.track(_sName,_oName,'SearchButton',null,'Search Button','10','WT.nrt_lc',count);
		        }
		    }
		     catch(err)
			{
	//			_oErrorHandler.Error('NRT.WebTrends.PropertySearch.sendSearchButtonWebTrends', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}   
		},	
		
		/*==================================================================================
			Method		: SendSelectedCriteria
			Summary		: Sends to webtrends which search criteria was selected
			Author		: Lee Neisen
			Create Date	: 07/18/2007
		====================================================================================*/															
		SendSelectedCriteria: function ()
		{
            var arrElements;
	        var _ctlPrefix="ctl00_ctl00_MenuAndPageContent_MainContent_ucPropertySearch_ucPropertyCriteria";
		    var _ctl=null;
            var _nameArr=[];
            var _paramArr=[];
            var _queryString=[];
            var _typeArr=[];
            var _theControlName="";
            var i,j,k,index,qsIndex;
		    try
		    {
		        //check for a control with a default prefix 
		        if(NRT.Utility.getElementByTagNameAndID(_ctlPrefix + "_ddlMinPrice","select")===null)
		        {
		             _ctlPrefix="ucPropertySearch_ucPropertyCriteria";		    
		        }
		        
		        _typeArr = ["input","select"];
		        //Create a list of controls that match the order of the scenario analysis report in WebTrends
	            _nameArr=[_ctlPrefix + "_rbtnl_SearchTypes_0",
                        _ctlPrefix + "_rbtnl_SearchTypes_1",
                        _ctlPrefix + "_rbtnl_SearchTypes_2",
                        "chklstPropertyType_1",
                        "chklstPropertyType_2",
                        "chklstPropertyType_3",
                        "chklstPropertyType_4",
                        _ctlPrefix + "_ddlMinPrice",
                        _ctlPrefix + "_ddlMaxPrice",
                        _ctlPrefix + "_ddlBeds",
                        _ctlPrefix + "_ddlBaths",
                        _ctlPrefix + "_chkTNewConstruction",
                        _ctlPrefix + "_chkTRecentlyReduced",
                        _ctlPrefix + "_chkTAdultCommunity",
                        _ctlPrefix + "_chkTAtleast1Photo",
                        _ctlPrefix + "_chkTWaterFront",
                        _ctlPrefix + "_chkTMultiplePhotos",
                        _ctlPrefix + "_chkTPool",
                        _ctlPrefix + "_chkTVirtualTour",
                        _ctlPrefix + "_chkTLuxuryHomes",
                        _ctlPrefix + "_chkTExclusiveProp",
                        _ctlPrefix + "_chkTOpenHouses",
                        _ctlPrefix + "_chkTFloorPlans",
                        _ctlPrefix + "_chkDisplayPastListings",
                        _ctlPrefix + "_ddlRentalMinPrice",
                        _ctlPrefix + "_ddlRentalMaxPrice"];
                //Create a new friendly list of Query parameters to send to webtrends
	            _paramArr=["SearchType",
                        "SearchType",
                        "SearchType",
                        "SingleFamily",
                        "MultiFamily",
                        "Condo_TownHouse",
                        "Co-op",
                        "MinPrice",
                        "MaxPrice",
                        "Beds",
                        "Baths",
                        "NewConstruction",
                        "RecentlyReduced",
                        "AdultCommunity",
                        "Atleast1Photo",
                        "WaterFront",
                        "MultiplePhotos",
                        "Pool",
                        "VirtualTour",
                        "LuxuryHomes",
                        "ExclusiveProp",
                        "OpenHouses",
                        "FloorPlans",
                        "DisplayPastListings",
                        "RentalMinPrice",
                        "RentalMaxPrice"];	
                for (k = 0; k < _typeArr.length; k += 1)
                {
                    //Find all controls of either "input" or "select" type
	                arrElements = document.getElementsByTagName(_typeArr[k]);
                    
                    if (arrElements.length > 0)
                    {
                        for (i = 0; i < arrElements.length; i += 1)
                        {
                            _ctl=arrElements[i];
                            //look in the list of webtrends monitored controls for the id
                            index=_nameArr.indexOf(_ctl.id.replace("Rental","")); //Rental will be listed with general min and max price as they appear the same on the page.
                            qsIndex=_nameArr.indexOf(_ctl.id); //Leave Rental in the query string for now.

                            if(index>=0)
                            {
	                             switch(_ctl.type)
	                            {
	                                case "select-one":
	                                    _queryString[qsIndex]=_paramArr[qsIndex] + "=" + _ctl.value;
	                                    
	                	                if (_ctl.value!=="0"&&_ctl.value!=="999999999"&&_ctl.value!==null)
	                                    {
											NRT.WebTrends.Utility.track('Property Search Criteria',_oName,_paramArr[qsIndex],'?selected='+_ctl.value,_paramArr[qsIndex]+' Selected',(index+1).toString());
	                                    }
	                                    break;
	                                case "checkbox":
	                                    if (_ctl.checked===true)
	                                    {
                   	                        NRT.WebTrends.Utility.track('Property Search Criteria',_oName,_paramArr[index],null,_paramArr[index]+' Checked',(index+1).toString());
                   	                        
	                                        _queryString[index]=_paramArr[index] + "=1";
	                                    }
	                                    else
	                                    {
	                                        _queryString[index]=_paramArr[index] + "=0";
	                                    }
	                                    break;
	                                case "radio":
	                                    if (_ctl.checked===true)
	                                    {
	                                        //Parse the control's label to get a friendly name to send to webtrends
	                                        if(_ctl.nextSibling.innerText)//IE
	                                        {
	                                            _theControlName=_ctl.nextSibling.innerText.replace(/ /g,"_").replace("/","_or_");
	                                        }
	                                        else
	                                        {
	                                            _theControlName=_ctl.nextSibling.textContent.toString().replace(/ /g,"_").replace("/","_or_");
                                            }
                                            
	                   	                    NRT.WebTrends.Utility.track('Property Search Criteria',_oName,_paramArr[index],'?checked='+_theControlName,_paramArr[index]+' Selected',(index+1).toString());
	                                        
	                                        _queryString[index]=_paramArr[index] + "=" + _theControlName;
	                                    }
	                                    break;
	                            }
	                        }
	                    }
	                }
	            }
	            if (_queryString[2]!==undefined && _queryString[2]!==null) //Rental search, remove the min and max price query string.
	            {
	                _queryString[7]=null;
	                _queryString[8]=null;
	            }
	            else //remove the rental min and max price
	            {
	                _queryString[24]=null;
	                _queryString[25]=null;
	            }
	            
	            var qStr = _queryString.join("&").replace(/&&&/g,"&").replace(/&&&/g,"&").replace(/&&/g,"&");
	            
	            if (qStr.charAt(qStr.length-1)==="&")
	            {
					qStr = qStr.substring(0,qStr.length-1);
				}
	            
	            NRT.WebTrends.Utility.track(_sName,_oName,'SearchCriteria','?'+qStr,'Property Search Criteria','9');
		    }
		    catch (err)
		    {
		        return;
		    }
		},		
		
		/*==================================================================================
			Method		: initListener
			Summary		: Setup listeners for control selection
			Author		: tsutton
			Create Date	: 04/18/2007
			Modified    : 07/10/2007 - Add additional controls
						  11/16/2007 - JJA, replaced call to duplicate function.
		====================================================================================*/															
		initListener: function()
		{
		    try
		    {
		        //Setup panels/tabs.        
			    YAHOO.util.Event.on(NRT.WebTrends.Utility.getTabButtons(), "click", NRT.WebTrends.PropertySearch.clickTabControl);
			    YAHOO.util.Event.on("div_CityZip_Selection", "click", NRT.WebTrends.PropertySearch.clickCityZipSelection);
			    YAHOO.util.Event.on(this.getCZStateControl(), "click", NRT.WebTrends.PropertySearch.clickStateControl);
			    YAHOO.util.Event.on(this.getNCStateControl(), "click", NRT.WebTrends.PropertySearch.clickStateControl);
			    
			    this.clickTabControl(null);
				
				//  The following registers function calls that display dialog boxes to the user that are not accessable until they show.
			    NRT.WebTrends.FunctionMonitor.register("showLayeredPage",NRT,"Utility");
			    NRT.WebTrends.FunctionMonitor.register("removeLocationFromSelectedLists",NRT.Property.Search,"CityZip");  //Location Removed Link clicked.
			    NRT.WebTrends.FunctionMonitor.register("handleDidYouMeanCheckboxSelect",NRT.Property.Search,"DidYouMean");   //"Did you mean" Dialog.  Location Checked/Unchecked.  
			    NRT.WebTrends.FunctionMonitor.register("handleSelectFromListLocationsClick",NRT.Property.Search,"DidYouMean");  // No locations Found.  "Select from List of locations" link pressed
			    NRT.WebTrends.FunctionMonitor.register("setSelectedCommunitySelectionTextStyle",NRT.Property.Search,"CommunitySelection");  // Community dialog.  Location Checked/Unchecked
	        }
		    catch (err)
	        {
	            return;
	        }
	    }
	};		
}();        

/* ##########################################################################################################################

	Namespace : NRT.WebTrends
	Classes   : PropertySearchResults
	Summary	  : This file contains all the scripts to handle the entire client side functionality for the
			    WebTrends on PropertySearchResults. 
	Copyright : (c) 2006 NRT Inc. All rights reserved.

	RevisionHistory: 
	-------------------------------------------------------------------------------------------------------------------------
	Date		Name		Description
	-------------------------------------------------------------------------------------------------------------------------
	06/27/2007	lneisen	Initial Creation

###########################################################################################################################*/


NRT.WebTrends.PropertyResults = function()
{

return {

    	/*==================================================================================
			Method		: RecordResultsPageView
			Summary		: Sends to webtrends that a callback of the results page has been requested
			Author		: Lee Neisen
			Create Date	: 06/27/2007
		====================================================================================*/															
		RecordResultsPageView: function (SearchID, PageNumber, MaxListingsPerPage, SortColumn, SourceID, DisplayMode)
		{
	        var laSI_N = [];
	        var laSI_X = [];
		    try
		    {
    		    
		        if(SourceID === -1)
		        {
		            dcsMultiTrack('DCS.dcsuri','/WT_Co-Mingle.htm','WT.ti','Co-Mingle Results','WT.si_n','Co-Mingle','WT.si_x','1');
	            }
		        else
		        {
                    laSI_N[0] = "Page_Number";
                    laSI_N[1] = "Max_Listings";
                    laSI_N[2] = "Show_Maps";
                    laSI_N[3] = "Sort_Column";
                    
                    laSI_X[0] = PageNumber;
                   // WebTrends wt.si_x parameters must start at 1 and increments by 1, so replace the 5, 10 and 25 with 1,2 and 3 respectively.
                    switch (MaxListingsPerPage) {
                        case 5 :
                            laSI_X[1] = 1;
                            break;
                        case 10 :
                            laSI_X[1] = 2;
                            break;
                        case 25 :
                            laSI_X[1] = 3;
                            break;
                        default :
                            laSI_X[1] = 2;
                            break;
                    }   
                    laSI_X[2] = parseInt(DisplayMode) + 1; //Web Trends indexes start at 1 not zero.  So increment by one.
                    laSI_X[3] = parseInt(SortColumn) + 1; //Web Trends indexes start at 1 not zero.  So increment by one.
	                dcsMultiTrack('DCS.dcsuri','/WT_PropertyResults.htm','WT.ti','Property Results Pageview','WT.si_n',laSI_N.join(";"),'WT.si_x',laSI_X.join(";"));
        	    }
		        laSI_N = null;
		        laSI_X = null;
		    }
		    catch(err)
		    {
		        return;
		    }    
		}	
	};
}();