﻿var scrollPosX,scrollPosY;
var BrokerIDX={};
String.prototype.toNumber=function(){
	/* 
		Purpose:	To convert a string to Numeric representation of the String
					Strips all white space and non-digit characters, with the exception of the decimal.
					e.g. "300.3" to 300.3, "$425.00" to 425.00, "100%" to 1.00 (or it's decimal equivalent);
					Intentionally Limited & Narrow in Scope
		Returns:	Number (Integer|Decimal)
	*/
	var n=Number(this.replace(/[^\d.]/g,''));
	if(this.match('%')!==null){
		n=(n/100);
	}
	return n;
};

BrokerIDX.IsArray=function(item){
	/*
		Purpose:		To determine if the item is an Object of Type Array
		Expects:		@param item = Any DOM or JavaScript Object OR Array of DOM or JavaScript Objects
		Dependencies:	BrokerIDX Object
		Returns:		(Boolean) true:false
	*/
	var s=typeof(item),rv=false;
	rv = (s==='object'&&item!==null)?(typeof(item.length)==='number'&&typeof(item.splice)==='function'&&(item.propertyIsEnumerable &&!(item.propertyIsEnumerable('length'))))?true:false:false;     
	return rv
}
BrokerIDX.IsDefined=function(item){
	/*
		Purpose:		To determine if the item (or in the case of an Array, collection of items) exists before performing operations on the item
		Expects:		@param item = Any DOM or JavaScript Object OR Array of DOM or JavaScript Objects
						e.g. String,Object,Null,Function,Array,HTMLDomElement,Window,['String','String',Object,HTMLDomElement,Function]
		Dependencies:	BrokerIDX Object
		Returns:		(Boolean) true:false
	*/
	var s=typeof(item),rv=false;
	if(s!=='undefined'&&item!=='null'&&item!==null){
		rv=true;
		if(BrokerIDX.IsArray(item)){
			for(var oI in item){
				if(typeof(item[oI])==='undefined'||item[oI]==='null'||item[oI]===null){
					rv=false;
					break;
				}
			}
		}
	}
	return rv;
}


BrokerIDX.Page={
	CenterObj:function(obj){
		if(typeof(obj)!=='undefined'){
			if(obj.style.display==='block'||obj.style.display===''){
				var posX=((BrokerIDX_getWHofViewport()[0]-obj.offsetWidth)/2)+BrokerIDX_getXYofViewportScroll()[0]+'px';
				var posY=((BrokerIDX_getWHofViewport()[1]-obj.offsetHeight)/2)+BrokerIDX_getXYofViewportScroll()[1]+'px';
				obj.style.left=posX;
				obj.style.top=posY;
				return;
			}
		}else{
			return;
		}
	},
	AlignObj:function(obj,target){
		if(typeof(obj)!=='undefined'){
			var posX=BrokerIDX_getXYofElement(target)[0]+'px';
			var posY=BrokerIDX_getXYofElement(target)[1]+'px';
			obj.style.left=posX;
			obj.style.top=posY;
		}else{
			return;
		}
	},
	MapLoaded:false
};
BrokerIDX.Page.Fx={
	getOpacity:function(id){
		var o=getObj(id);
		if(typeof(o)!=='undefined'){
			if(typeof(o.style.opacity)!=='undefined'){
				if(o.style.opacity.toString().length>0){
					return (o.style.opacity*100);
				}else{
					return '';
				}
			}else if(typeof(o.style.MozOpacity)!=='undefined'){
				if(o.style.MozOpacity.toString().length>0){
					return (o.style.MozOpacity*100);
				}else{
					return '';
				}
			}else if(typeof(o.style.KhtmlOpacity)!=='undefined'){
				if(o.style.KhtmlOpacity.toString().length>0){
					return (o.style.KhtmlOpacity*100);
				}else{
					return '';
				}
			}else if(typeof(o.style.filter)!=='undefined'){
				if(o.style.filter.toString().length>0){
					return parseInt(o.style.filter.toString());
				}else{
					return '';
				}
			}
		}
	},
	setOpacity:function(id,v){
		var o=getObj(id),x=(v/100);
		if(typeof(o)!=='undefined'){
			o.style.opacity=(x);
			o.style.MozOpacity=(x);
			o.style.KhtmlOpacity=(x);
			o.style.filter="alpha(opacity="+v+")";
		}
	},
	fade:function(id,which,ms,display){
		var timer=0,i,speed,v,o;
		if(typeof(ms)==='undefined'){ms=500;}
		if(typeof(display)==='undefined'){display='block';}
		speed=Math.round(ms/100);
		if(typeof(id)!=='undefined'&&typeof(which)!=='undefined'){
			o=getObj(id);
			switch(which){
				case 'out':
					v=BrokerIDX.Page.Fx.getOpacity(id);
					if(v.toString().length===0||v.toString().length>1){
						for(i=100;i>=0;i--){
							setTimeout("BrokerIDX.Page.Fx.setOpacity('"+id+"',"+i+");",(timer*speed));
							timer++;
						}
						setTimeout(function(){
							o.style.display='none';
						},ms);
					}
					break;
				case 'in':
					v=BrokerIDX.Page.Fx.getOpacity(id);
					if(v.toString().length>0&&v.toString().length<3){
						getObj(id).style.display=display;
						for(i=0;i<=100;i++){
							setTimeout("BrokerIDX.Page.Fx.setOpacity('"+id+"',"+i+");",(timer*speed));
							timer++;
						}
					}
					break;
				default:
					break;
			}
		}
	}
}
BrokerIDX.Iframe={
	Current:'',
	FrameLoaded:false,
	FrameUnLoaded:false,
	CurrentFrame:function(){
		var c=this.Current,ri;
		if(typeof(c)!=='undefined'){
			ri = parent.frames[c];
			if(typeof(ri)==='undefined'){
				ri = frames[c];
			}
		}
		return ri;
	},
	LoadFrame:function(url,override){
		if(!(BrokerIDX.IsDefined(override))){
			override=false;
		}
		if(!(override)){
			var iframe=this.CurrentFrame();
			if(typeof(iframe)!=='undefined'&&iframe.location.href.indexOf(url)===-1){
				iframe.location.replace(url);
			}
		}else{
			var iframe=this.CurrentFrame();
			if(BrokerIDX.IsDefined(iframe)){
				iframe.location.replace(url);
			}
		}
	},
	Bounds:function(){
		var me=this;
		function find(item,v){
			switch(item.toLowerCase()){
				case 'ow':
					if(BrokerIDX.IsDefined(v)){
						me.oW=v;
					}else{
						return me.oW;
					}
					break;
				case 'oh':
					if(BrokerIDX.IsDefined(v)){
						me.oH=v;
					}else{
						return me.oH;
					}
					break;
				case 'ew':
					if(BrokerIDX.IsDefined(v)){
						me.eW=v;
					}else{
						return me.eW;
					}
					break;
				case 'eh':
					if(BrokerIDX.IsDefined(v)){
						me.eH=v;
					}else{
						return me.eH;
					}
					break;
				default:
					break;
			}
		}
		this.Element=null;
		this.oW=null;
		this.oH=null;
		this.eW=null;
		this.eH=null;
		
		this.set_value=function(item,v){
			if(typeof(v)==='number'){
				find(item,v);
			}
		};
		this.get_value=function(item){
			return find(item);;
		};
	}
};
BrokerIDX.Iframe.Bounds.prototype.loadWidth=function(args){
	if(BrokerIDX.IsDefined(args)){
		this.set_value('oW',args);
	}else{
		return this.get_value('oW');
	}
};
BrokerIDX.Iframe.Bounds.prototype.loadHeight=function(args){
	if(BrokerIDX.IsDefined(args)){
		this.set_value('oH',args);
	}else{
		return this.get_value('oH');
	}
};
BrokerIDX.Iframe.Bounds.prototype.expandWidth=function(args){
	if(BrokerIDX.IsDefined(args)){
		this.set_value('eW',args);
	}else{
		return this.get_value('eW');
	}
};
BrokerIDX.Iframe.Bounds.prototype.expandHeight=function(args){
	if(BrokerIDX.IsDefined(args)){
		this.set_value('eH',args);
	}else{
		return this.get_value('eH');
	}
};


BrokerIDX.Search={
	Results:0,
	MaxResults:500,
	MaxMessage:function(cID,mID,MaxCount){
		var m_maxcount=MaxCount.toString().toNumber(),m_recordcount=BrokerIDX.Search.Results.toString().toNumber();
		var m_count=(typeof(cID)==='string')?$get(cID):(typeof(cID)==='object'&&cID!==null)?cID:null;
		var m_msg=(typeof(mID)==='string')?$get(mID):(typeof(mID)==='object'&&mID!==null)?mID:null;
		var m_html='<div class="limit-text">\r\n';
			m_html+='<h5>Search Limit Exceeded</h5>\r\n';
			m_html+='<p>Please use the form to narrow your search results to <strong><em>{0}</em> or less.</strong></p>';
			m_html = m_html.replace('{0}',MaxCount);
		function m_GetBounds(oE){
			var oB = oE?Sys.UI.DomElement.getBounds(oE):null;
			return oB;
		}
		function m_SetLocation(b){
			var insertMessage = b ? b:true;
			var oC,oM,x,y,ri=true;
			if(m_count!==null&&m_msg!==null){
				if(insertMessage){m_msg.innerHTML=m_html;}
				oC=m_GetBounds(m_count);
				oM=m_GetBounds(m_msg);
				x=((oC.x+(oC.width/2))-(oM.width/2));
				y=oC.y+oC.height;
				m_msg.style.left=x+'px';
				m_msg.style.top=y+'px';
			}else{
				ri=false;
			}
			return ri;
		}
		function m_Load(){
			m_ToggleMessage('auto');
		}
		function m_ToggleMessage(b){
			var mode=(typeof(b)==='boolean')?b.toString().toLowerCase():'auto';
			var oDE = Sys.UI.DomElement,ri=false;
			if(m_count!==null&&m_msg!==null){
				if(typeof(oDE)!=='undefined'&&oDE!==null){
					switch(mode){
						case 'true':
							oDE.removeCssClass(m_msg,'hide-max-message');
							m_SetLocation();
							break;
						case 'false':
							oDE.addCssClass(m_msg,'hide-max-message');
							break;
						default:
							if(m_recordcount > m_maxcount){
								oDE.removeCssClass(m_msg,'hide-max-message');
								m_SetLocation();
							}else if(m_recordcount <= m_maxcount){
								oDE.addCssClass(m_msg,'hide-max-message');
							}
							break;
					}
					ri = true;
				}
			}
			return ri;
		}
		this.Show=function(){
			m_ToggleMessage(true);
		};
		this.Hide=function(){
			m_ToggleMessage(false);
		};
		this.Snap=function(){
			if(m_recordcount > m_maxcount){
				return m_SetLocation(false);
			}
		};
		this.Toggle=function(){
			return m_ToggleMessage('auto');
		}	
		setTimeout(function(){m_Load();},600);
	},
	CurrentElement:null
}
BrokerIDX.Search.Map={
	loaded:false
}
BrokerIDX.Tabs={
	CurrentTab:null,
	SelectEventFired:false,
	MultiPage:{
		ClearHeight:function(args){
			/*
			Purpose:		To Remove Inline CSS height declarations from MultiPage PageViews
			Expects:		@param args = An array literal containing ClientIDs of MultiPage PageView Objects in a TabStrip/MultiPage Setup
							e.g. args=['idA','idB']
			Dependencies:	Requires ASP.NET Ajax ScriptManager on Page
							BrokerIDX Object
			Returns:		No Return Value
			*/
			var oP; 
			if(BrokerIDX.IsDefined(args)){
				if(args.length>0){
					for(var i=0;i<args.length;i+=1){
						oP=$get(args[i]);
						if(BrokerIDX.IsDefined(oP)){
							oP.style.height='auto';
							if(oP.offsetParent){
								oP.offsetParent.style.height='100px';
								oP.offsetParent.style.height='auto';
							}
						}
					}
				}
			}
		},
		PageView:{
			Select:function(sender,multipage){
				/*
				Purpose:		To raise a custom PageView Select event when associated TabStripTab is selected
				Expects:		@param sender = A reference to the selected ComponentArt TabStrip Tab Object
								@param multipage = A reference to the associated ComponentArt MultiPage Object
								e.g. (TabStripTabObject,MultiPageObject)
				Dependencies:	Requires ASP.NET Ajax ScriptManager on Page
								ComponentArt TabStrip/MultiPage Controls
								BrokerIDX Object
				Returns:		No Return Value
				*/
				if(BrokerIDX.IsDefined([sender,multipage])){
					var id = sender.get_pageViewId();
					var oPV = multipage.findPageById(id).get_element();
					BrokerIDX.Tabs.MultiPage.IFrame.AdjustAll(oPV,true,false);
				}
			}
		},
		IFrame:{
			AdjustAll:function(pageview,cH,cW){
				/*
				Purpose:		Address width / height issues of dynamically sized iframes in MultiPage control when different PageView is selected before current PageView iframes have finished loading
				Expects:		@param pageview = A reference to the selected ComponentArt PageViewPage Object's DomElement
								@param cH = (Boolean|Integer) Whether to size the iframe to match the height of it's contents or to the value of the number provided // defaults to true
								@param cW = (Boolean|Integer) Whether to size the iframe to match the width of it's contents or to the value of the number provided // defaults to false
								e.g. (PageViewHTMLDomObject,ChangeHeight,ChangeWidth)
								
								@optional override param maxheight-{value} where {value} is an number of type (Integer|Decimal|Percentage) and is added to the Iframe's CssClass collection
								@optional override param maxwidth-{value} where {value} is an number of type (Integer|Decimal|Percentage) and is added to the Iframe's CssClass collection
								e.g. <iframe class="maxheight-350 maxwidth-90%" />
								
				Dependencies:	Requires ASP.NET Ajax ScriptManager on Page
								ComponentArt TabStrip/MultiPage Controls
								BrokerIDX Object
				Returns:		No Return Value
				*/
				var H=cH?cH:true,W=cW?cW:false,oF,F,N;
				if(BrokerIDX.IsDefined(pageview)){
					var aIF = pageview.getElementsByTagName("iframe");
					for(var iframe in aIF){
						oF=aIF[iframe];
						F=parent.frames[oF.name];
						if(BrokerIDX.IsDefined(F)){
							if(oF.src.indexOf(F.location.pathname)===-1){
								var mH=this.UseMaxHeight(oF);
								var mW=this.UseMaxWidth(oF);
								if(mH[0]>0){
									this.SetHeight(oF,F,mH[0],mH[1]);	
								}else{
									this.SetHeight(oF,F,H);
								}
								if(mW[0]>0){
									this.SetWidth(oF,F,mW[0],mW[1]);
								}else{
									this.SetWidth(oF,F,W);
								}
							}
						}
					}
				}
			},
			Adjust:function(f,id,cH,cW){
				/*
				Purpose:		Override width / height issues of a single instance of an iframe
				Expects:		@param f = (String|Object) Can be either the name of an iframe or a reference to the instance of the iframe via the parent.frames[frameName] method
								@param id = (String|Object) Can be either the id of an iframe or a reference to the instance of the iframe via the $get(id) method
								@param cH = (Boolean|Integer) Whether to size the iframe to match the height of it's contents or to the value of the number provided // defaults to true
								@param cW = (Boolean|Integer) Whether to size the iframe to match the width of it's contents or to the value of the number provided // defaults to false
								e.g. (FrameName,$get(FrameID),ChangeHeight,ChangeWidth)
								
								@optional override param maxheight-{value} where {value} is an number of type (Integer|Decimal|Percentage) and is added to the Iframe's CssClass collection
								@optional override param maxwidth-{value} where {value} is an number of type (Integer|Decimal|Percentage) and is added to the Iframe's CssClass collection
								e.g. <iframe class="maxheight-350 maxwidth-90%" />
								
				Dependencies:	Requires ASP.NET Ajax ScriptManager on Page
								BrokerIDX Object
				Returns:		No Return Value
				*/
				
				var H=cH?cH:true,W=cW?cW:false,F,oF;
				F=(typeof(f)==='string')?parent.frames[f]:(typeof(f)==='object')?f:null;
				oF=(typeof(id)==='string')?$get(id):(typeof(id)==='object')?id:null;
				if(BrokerIDX.IsDefined([F,oF])){
					var mH=this.UseMaxHeight(oF);
					var mW=this.UseMaxWidth(oF);
					if(mH[0]>0){
						this.SetHeight(oF,F,mH[0],mH[1]);	
					}else{
						this.SetHeight(oF,F,H);
					}
					if(mW[0]>0){
						this.SetWidth(oF,F,mW[0],mW[1]);
					}else{
						this.SetWidth(oF,F,W);
					}
				}
			},
			SetHeight:function(oF,F,H,P){
				/*
					Purpose:	Supporting function used by BrokerIDX.Tabs.MultiPage.Iframe Object methods (AdjustAll | Adjust).
								// DO NOT MODIFY
				*/
				var p=P?P:false,h=(Sys.UI.DomElement.getBounds(F.window.document.body).height)+10;
				switch(typeof(H)){
					case 'boolean':
						if(H){
							oF.style.height=(h)+'px';
						}
						break;
					case 'number':
						if(p){
							(h<(h*H))?oF.style.height=(h)+'px':oF.style.height=(h*H)+'px';
						}else{
							(h<H)?oF.style.height=(h)+'px':oF.style.height=(H)+'px';
						}
						break;
					default:
						oF.style.height=(oF.style.height)+'px';
						break;
				}
			},
			SetWidth:function(oF,F,W,P){
				/*
					Purpose:	Supporting function used by BrokerIDX.Tabs.MultiPage.Iframe Object methods (AdjustAll | Adjust).
								// DO NOT MODIFY
				*/
				var p=P?P:false,w=(Sys.UI.DomElement.getBounds(F.window.document.body).width)+10;
				switch(typeof(W)){
					case 'boolean':
						if(W){
							oF.style.width=(w)+'px';
						}
						break;
					case 'number':
						if(p){
							(w<(w*W))?oF.style.width=(w)+'px':oF.style.width=(w*W)+'px';
						}else{
							(w<W)?oF.style.width=(w)+'px':oF.style.width=(W)+'px';
						}
						break;
					default:
						oF.style.width=(oF.style.width)+'px';
						break;
				}
			},
			UseMaxHeight:function(oF){
				/*
					Purpose:	Supporting function used by BrokerIDX.Tabs.MultiPage.Iframe Object methods (AdjustAll | Adjust).
								// DO NOT MODIFY
				*/
				var rv=0,aCss,P=false;
				if(oF.className.length > 0 && oF.className.indexOf("maxheight")>-1){
					aCss = oF.className.split(" ");
					for(var c in aCss){
						if(aCss[c].indexOf("maxheight")>-1){
							rv=aCss[c].split("-")[1];
							break;
						}
					}
					if(typeof(rv)==='string'){
						if(rv.match("%")){
							P=true;	
						}
						rv=rv.toNumber();
					}
				}
				return [rv,P];
			},
			UseMaxWidth:function(oF){
				/*
					Purpose:	Supporting function used by BrokerIDX.Tabs.MultiPage.Iframe Object methods (AdjustAll | Adjust).
								// DO NOT MODIFY
				*/
				var rv=0,aCss,P=false;
				if(oF.className.length > 0 && oF.className.indexOf("maxwidth")>-1){
					aCss = oF.className.split(" ");
					for(var c in aCss){
						if(aCss[c].indexOf("maxwidth")>-1){
							rv=aCss[c].split("-")[1];
							break;
						}
					}
					if(typeof(rv)==='string'){
						if(rv.match("%")){
							P=true;	
						}
						rv=rv.toNumber();
					}
				}
				return [rv,P];
			}
		}
	}
}
function CFWI_ComboBoxHeightControl(iframe){
	var m_h1=0,m_h2=0,m_loadHeight=0,m_height=0,m_adjustedHeight=0,m_isInitialized=false,m_oF=null;
	var me=this;
	this.init=function(){
		m_oF=parent.getObj(iframe);
		m_isInitialized=true;
		m_height=me.get_height(true);
		m_loadHeight=m_height;
	};
	this.get_height=function(b){
		var ri,adj;
		m_h1=0;
		m_h2=0;
		if(m_isInitialized===true){
			m_h1=document.documentElement.scrollHeight;
			m_h2=document.documentElement.offsetHeight;
			if(m_height===0){
				var n=document.all?0:10;
				if(m_h1>m_h2){
					ri=(m_h1+n);
				}else{
					ri=(m_h2+n);
				}
			}else{
				adj=(m_h1>m_h2)?m_h1:m_h2;
				ri=adj;
			}
			if(b){
				return ri;
			}
		}
	};
	this.set_height=function(v){
		m_oF.style.height=v+'px';
	};
	this.adjust_height=function(){
		var h = me.get_height(true);
		m_adjustedHeight=h;
		me.set_height(h);
	};
	this.restore_height=function(){
		m_oF.style.height=m_loadHeight+'px';
		var h = me.get_height(true);
		me.set_height(h);
	};
}
// Added on 8/6/08 - New Default Buttons Code...replaces older defaultButtons code.
	BrokerIDX.DefaultButtons={
		registerButton:function(cId,bId,bA,bLS,oE){
			var oC=document.getElementById(cId);
			var oB=document.getElementById(bId);
			var isAjax=bA?bA:false; /* Optional parameter specifies whether form is ajax'd */
			var LimitScope=bLS?bLS:true; /* Optional parameter specifies whether form validation should be limited to the specified container object */
			var ScopeElement=oE?oE:oC; /* Optional parameter specifies scope element to use as base for form validation */
			if(BrokerIDX.IsDefined(oC)&&BrokerIDX.IsDefined(oB)){
				attachEventListener(oC,'keypress',function(e){
					BrokerIDX.DefaultButtons.Click(e,oB,isAjax,LimitScope,ScopeElement);
				},false);
				attachEventListener(oC,'mousedown',function(e){
					BrokerIDX.DefaultButtons.Click(e,oB,isAjax,LimitScope,ScopeElement);
				},false);
			}
		},
		Click:function(e,lbtn,bA,bLS,oE){
			var isAjax=bA?bA:false,LimitScope=bLS?bLS:true,ScopeElement=null;
			if(typeof(e)!=='undefined'&&e!==null){
				var k=(e.which||e.keyCode);
				var t=(e.target||e.srcElement);
				
				if(LimitScope&&(typeof(window.FormValidator)!=='undefined'&&window.FormValidator!==null)){
					ScopeElement=oE?oE:t;
					FormValidator.LimitScope=true;
					FormValidator.SetScopeElement(ScopeElement);
				}
				
				try{
					if(k===13){
						if(t.type==='text'){if(e.preventDefault){e.preventDefault();}e.returnValue=false;}
						if(t.type!=='textarea'){
							if(lbtn.getAttribute('onclick')){
								if(!(document.all)){
									s=lbtn.getAttribute('onclick').toString();
								}else{
									s=lbtn.attributes["onclick"].value;
								}
								if(s.indexOf('return ')>-1){
									s=s.replace('return ','');
								}
								if(eval(s)){
									if(isAjax){
										return true;
									}else{
										eval(lbtn.href);
									}
								}else{
									if(e.preventDefault){e.preventDefault();}
									e.returnValue = false;
									return false;
								}
							}else{
								if(isAjax){
									return true;
								}else{
									eval(lbtn.href);
								}
								return false;
							}
						}
					}else{
						return true;
					}
				}
				catch(err){
					//alert(err.message);
					if(e.preventDefault){e.preventDefault();}
					e.returnValue = false;
					return false;
				}
			}else{
				if(!e.which&&!e.keyCode){
					return false;
				}
			}
		}
	};
// Example: BrokerIDX.DefaultButtons.registerButton('containerID','buttonID');


//create custom defaultButtons object
	var defaultButtons={registerButton:function(cId,bId){var oC=document.getElementById(cId);var oB=document.getElementById(bId);if(BrokerIDX.IsDefined(oC)&&BrokerIDX.IsDefined(oB)){if(typeof(oC.addEventListener)!=='undefined'){oC.addEventListener('keypress',function(e){defaultButtons.fireDefaultButton(e,oB);},false);}else if(typeof(oC.attachEvent)!=='undefined'){oC.attachEvent('onkeypress',function(e){defaultButtons.fireDefaultButton(e,oB);});}}},fireDefaultButton:function(e,lbtn){if(!e.which&&!e.keyCode){return;}else{var k=(e.which||e.keyCode);var t=(e.target||e.srcElement);try{if(k===13){if(t.type!=='textarea'){lbtn.focus();eval(lbtn.href);return true;}}}catch(err){return false;}}}};
	// Example: defaultButtons.registerButton('containerID','buttonID');
	
// Adds Load Listener to the window.onload event handler.
	function addLoadListener(fn){if(typeof window.addEventListener!='undefined'){window.addEventListener('load',fn,false);}else if (typeof document.addEventListener != 'undefined'){document.addEventListener('load',fn,false);}else if(typeof window.attachEvent!='undefined'){window.attachEvent('onload',fn);}else{return false;}return true;}

// Attaches an Event Listener to a valid document event type
	function attachEventListener(target, eventType, functionRef, capture){if(typeof target.addEventListener!="undefined"){target.addEventListener(eventType,functionRef,capture);}else if(typeof target.attachEvent!="undefined"){target.attachEvent("on"+eventType,functionRef);window.attachEvent("onunload",function(e){removeListeners(target,eventType,functionRef,capture);});}else{return false;}return true;}
	function removeListeners(target, eventType, functionRef, capture){if(typeof target.removeEventListener!="undefined"){target.removeEventListener(eventType,functionRef,capture);}else if(typeof target.detachEvent!="undefined"){target.detachEvent("on"+eventType,functionRef);}else{return false;}return true;}

// Determines what triggered an event
	function getEventTarget(e){var o;if(!e){var e=window.event;}if(e.target){o=e.target;}else if(e.srcElement){o=e.srcElement;}if(o.nodeType==3){o=o.parentNode;}return o;}

// Generic GetHTML Object Functions
	function getObj(oId){var d=document,i,el;el=d.getElementById?d.getElementById(oId):d.all?d.all[oId]?d[oId]:d[oId]:null;if(!el){if(d.forms.length>0){for(i=0; !el && i<d.forms.length; i++){el=d.forms[i][oId];}}}return el;}
	function get_HtmlObjWH(obj){if(obj.offsetWidth&&obj.offsetHeight){return [obj.offsetWidth,obj.offsetHeight];}else{return [0,0];}}
	function BrokerIDX_getXYofElement(obj){
		var x=y=0;
		if(obj.offsetParent){
			x=obj.offsetLeft;
			y=obj.offsetTop;
			while(obj=obj.offsetParent){
				x+=obj.offsetLeft;
				y+=obj.offsetTop;
			}
		}
		return [x,y];
	}

// Get Viewport Dimensions & Scroll Distances
	function BrokerIDX_getWHofViewport(){
		var W=window;
		if(window.top.DNN_BrokerIDX){
			if(window.top.DNN_BrokerIDX.Window.UseGlobalWindow()){
				W=window.top;
			}
		}
		var w=W.innerWidth?W.innerWidth-21:(W.document.documentElement&&W.document.documentElement.clientWidth)?W.document.documentElement.clientWidth:W.document.body.clientWidth?W.document.body.clientWidth:null;
		var h=W.innerHeight?W.innerHeight-21:(W.document.documentElement&&W.document.documentElement.clientHeight)?W.document.documentElement.clientHeight:W.document.body.clientHeight?W.document.body.clientHeight:null;
		if(w&&h){return [w,h];}
	}
	function BrokerIDX_getXYofViewportOffset(){
		var xA=0,yA=0;
		if(window.top.DNN_BrokerIDX){
			if(window.top.DNN_BrokerIDX.Window.UseGlobalWindow()){
				W=window.top;
				xA=window.top.DNN_BrokerIDX.Window.GetPosXY()[0];
				yA=window.top.DNN_BrokerIDX.Window.GetPosXY()[1];
			}
		}
		return [xA,yA];
	}
	function BrokerIDX_getXYofViewportScroll(){
		var W=window,x,y,xA,yA;
		if(window.top.DNN_BrokerIDX){
			if(window.top.DNN_BrokerIDX.Window.UseGlobalWindow()){
				W=window.top;
				xA=BrokerIDX_getXYofViewportOffset()[0];
				yA=BrokerIDX_getXYofViewportOffset()[1];
			}
		}
		x=W.innerWidth?W.pageXOffset:(W.document.documentElement&&W.document.documentElement.scrollLeft)?W.document.documentElement.scrollLeft:W.document.body.scrollLeft?W.document.body.scrollLeft:null;
		y=W.innerHeight?W.pageYOffset:(W.document.documentElement&&W.document.documentElement.scrollTop)?W.document.documentElement.scrollTop:W.document.body.scrollTop?W.document.body.scrollTop:null;
		if(xA > 0){ x=(x-xA); }
		if(yA > 0){ y=(y-yA); }
		return [x,y];
		
	}
	function BrokerIDX_setInitialXYofViewportScroll(){scrollPosX=BrokerIDX_getXYofViewportScroll()[0],scrollPosY=BrokerIDX_getXYofViewportScroll()[1];}
	attachEventListener(window,'load',BrokerIDX_setInitialXYofViewportScroll,false);




// Generic Set Title function
	function BrokerIDX_setElementTitle(obj,txt){
		if(typeof(obj)!=='undefined'&&obj!==null){
			if(typeof(txt)!=='undefined'&&txt!==null){
				if(txt.length===0){txt='';}
				obj.title=txt;
			}
		}
	}
// Generic Append / Replace Css ClassName functions
	function BrokerIDX_appendCssClass(obj,n){if(typeof(obj)!=='undefined'&&obj!==null){obj.className+=n;}}
	function BrokerIDX_restoreCssClass(obj,n){if(typeof(obj)!=='undefined'&&obj!==null){obj.className=obj.className.replace(n,'');}}

	function _ieFocus(obj,which){if(document.all){return true;}}
	
// Generic Append to URL function
	// usage: 
	// srcId = Name of Cookie or Textbox that contains the value to be appended / replaced in the url
	// targetName = Name assigned to URL to be updated via the name attribute (e.g. <a name="mylink" href="">some text</a>
	// paramName = Name of Variable to find / append (e.g. find "key" in savedListing.aspx?format=print&key=guid&otherparams=something)
	function _appendToUrl(srcId,targetName,paramName){try{var strToAppend='',strToReplace='',newStr='',iStart,iStop,arr=document.getElementsByName(targetName),url='',val=getCookie(srcId);if(val==null||val=='null'){val=getObj(srcId);if(val&&val.type=='text'){val=val.value;}else{val='';}}if(arr&&arr.length>0){for(var i=0;i<arr.length;i++){url=arr[i].href;if(url.indexOf(paramName)==-1){strToAppend="?"+paramName+"="+val;if(url.indexOf("?")>-1){url=url.replace("?",(strToAppend+"&"));if(url.lastIndexOf("&")==url.length-1){url=url.substring(0,url.length-1);}}else{url=url+strToAppend;}}else if(url.indexOf(paramName)>-1){startindex=url.indexOf(paramName);stopindex=url.indexOf("&",startindex);newStr=paramName+"="+val;if(stopindex==-1){stopindex=url.length;}strToReplace=url.substring(startindex,stopindex);url=url.replace(strToReplace,newStr);}arr[i].href=url;}}}catch(err){}}

// Uses location.replace() method to set the href of the targeted iframe to prevent iframe url's from being added to history object.
	function BrokerIDX_loadUrl(sender){
		try{
			if(sender.target){
				var oI=parent.frames[sender.target]?parent.frames[sender.target]:frames[sender.target]?frames[sender.target]:null;
				if(typeof(oI)!=='undefined'&&oI!==null){
					oI.location.replace(sender.href);
				}else{
					location.replace(sender.href);
				}
			}else{
				if(sender.href){
					location.replace(sender.href);
				}
			}
		}
		catch(ex){
		
		}
	}

// Generic Toggle Display Functions
	function BrokerIDX_toggleDisplay(id,which){var obj=getObj(id);if(typeof obj=='undefined'){return}else{obj.style.display=which;return;};}

// Create Instance of a Flash Object inside an HTML container object via script. Bypasses "Click to Activate Control" message in IE
// Usage: <script type="text/javascript">var oFlash=new insertFlashObject(['oContainerId','id','url','w','h','wmode']);</script>
// Notes: 'wmode' is an optional override and is not required when creating a new insertFlashObject call...simply end the array after 'h'...example: var oFlash=new insertFlashObject(['oContainerId','id','url','w','h']);
	function insertFlashObject(args){var oContainerId=args[0],id=args[1],url=args[2],w=args[3],h=args[4],wmode=args[5]?args[5]:'transparent';if(oContainerId.length>0)var oFlashContainer=getObj(oContainerId);if(oFlashContainer&&url){var oStartTag  = '<object type="application/x-shockwave-flash" id="'+id+'" data="'+url+'" width="'+w+'" height="'+h+'">';var strParams  = '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+url+'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="autoStart" value="true" /><param name="WMode" value="'+wmode+'" />';var oEndTag = '</object>';oFlashContainer.innerHTML=oStartTag+strParams+oEndTag;}}

// Used to set the iframe width/height within the BrokerIDX UI Popup Window
	function BrokerIDX_UIPopupWindow_ContentFrameSize(){this.initialize=function(){var w,h,mW=420,mH=300,frameWidth,frameHeight,title;if(typeof this.Title!='undefined'){title=this.Title;}if(typeof this.Width!='undefined'){w=this.Width;}if(typeof this.Height!='undefined'){h=this.Height;}if(typeof this.OnClose_ReloadParent!='undefined'){reload_parent=this.OnClose_ReloadParent;}else{reload_parent=false;}if(typeof this.OnClose_PostParent!='undefined'){post_parent=this.OnClose_PostParent;}else{post_parent=false;}if(typeof this.OnClose_ChangeParent!='undefined'){change_parent=this.OnClose_ChangeParent;}else{change_parent='';}function adjust(){var oParentFrame=parent.document.getElementById('BrokerIDX_UIWindow_iframe');var oParentTitle=parent.getObj('BrokerIDX_UIWindow_Title');if(typeof oParentFrame=='undefined'){return;}else{try{var c=get_HtmlObjWH(getObj("iframe-page-content"));if(typeof c!='undefined'){if(typeof w=='undefined'){if(c[0]>mW){frameWidth=mW;}else{frameWidth=c[0];}}else{frameWidth=parseInt(w);}if(typeof h=='undefined'){if(c[1]>mH){frameHeight=(mH+20);frameWidth+=19;}else{frameHeight=c[1]+20;}}else{frameHeight=parseInt(h)+20;}if(typeof title=='undefined'){title='';}if(oParentFrame){oParentFrame.style.width=frameWidth+'px';}if(oParentFrame){oParentFrame.style.height=frameHeight+'px';}if(oParentTitle){oParentTitle.innerHTML=title;}}}catch(err){}}}this._modify=function(){adjust()};attachEventListener(window,'load',adjust,false);}}

// Close the Dialog Window
	function BrokerIDX_UIPopupWindow_Close(){
		if(typeof(parent.dialog)!=='undefined'){
			parent.dialog.Close();
		}
		if(typeof(parent.Dialog)!=='undefined'){
			parent.Dialog.Close();
		}
		if(typeof(dialog)!=='undefined'){
			dialog.Close();
		}
		if(typeof(Dialog)!=='undefined'){
			Dialog.Close();
		}
	}

// Determine how to handle, then process the parent window.  Used via Dialog Content iFrame.
	// Refresh, Change, Post Parent Window Functions
	function BrokerIDX_UIPopupWindow_ReloadParent(){parent.document.location.replace(parent.document.location.href);}
	function BrokerIDX_UIPopupWindow_ChangeParent(url){parent.document.location.replace(url);}
	function BrokerIDX_UIPopupWindow_PostParent(){parent.document.forms[0].submit();}
	// Prep, then Handle / Process Parent Window
	function BrokerIDX_PrepParentWindow(action,url){if(typeof action=='undefined'){return false;}else if(typeof url=='undefined'){return false;}else{try{var v=action+'|'+url;writeCookie("HandleParentWindow",v);return true;}catch(err){}}}
	function BrokerIDX_HandleParentWindow(){if(getCookie("HandleParentWindow")&&getCookie("HandleParentWindow").length>0){var action=getCookie("HandleParentWindow").split("|")[0];var url=''+getCookie("HandleParentWindow").split("|")[1];writeCookie("HandleParentWindow",'');BrokerIDX_ProcessParentWindow(action,url);}}
	function BrokerIDX_ProcessParentWindow(action,url){if(typeof action=='undefined'){return false;}else{try{window.setTimeout('BrokerIDX_UIPopupWindow_Close()',250);switch(action.toLowerCase()){case "changeparent":BrokerIDX_UIPopupWindow_ChangeParent(url);break;case "reloadparent":BrokerIDX_UIPopupWindow_ReloadParent();break;case "postparent":BrokerIDX_UIPopupWindow_PostParent();break;case "none":break;default:break;}}catch(err){}}}


	
// ### Last Selected Tab Code ### //

    // Control Tabstrip Tab Select event on individual tabs to use location.replace() method to prevent tab selections from being
    // remembered in history.  This function works both separately and in conjuction with the tabstrip-wide BrokerIDX_onTabSelect functions.
    function BrokerIDX_TabstripTabSelect(sender){
		var iframe=parent.frames[sender.Target];
		if(!iframe){iframe=frames[sender.Target];}
		if(BrokerIDX.IsDefined(iframe)){
			try{
				if(iframe.location.href.toLowerCase().indexOf(sender.NavigateUrl.toLowerCase())===-1){
					iframe.location.replace(sender.NavigateUrl);
				}else{
					return false;
				}
			}
			catch(err){}
		}
	}
	
	//BrokerIDX_onSideBarLoad
	function BrokerIDX_onSideBarLoad(sender, eventArgs){
		if(getCookie("SelectedTabs")){
		    var selectedTabsList=getCookie("SelectedTabs");
		    var arr=selectedTabsList.split("|");
		    var found=false;
		    for(var i=0;i<arr.length;i++){
			    if(arr[i].indexOf(sender.get_id())>-1){
				    found=true;
				    break;
			    }
		    }
		    if(!found){
			    BrokerIDX_setSelectedTab(sender.get_id(),0);
			    sender.get_tabs().getTab(0).select();
			    return;
		    }else{
				return;
		    }
	    }else{
			BrokerIDX_setSelectedTab(sender.get_id(),0);
			sender.get_tabs().getTab(0).select();
		    return;
	    }
	}
    
    // Function to select the default tab index for the sidebar tabstrip control
	function BrokerIDX_SelectDefault(){
		if(typeof tsSidebar!=='undefined'){
			var isVisible = tsSidebar.getSelectedTab().get_visible();
			if(isVisible!==true||isVisible!=='true'||isVisible!==1||isVisible!=='1'){
				BrokerIDX_SelectedTab('tsSidebar',0);
			}
		}
	}
	
	// TabStrip-wide event handler that Selects, then stores the last selected TabStrip Tab
    function BrokerIDX_onTabSelect(sender, eventArgs){
	    var oTabStripId=sender.get_id();
	    var oSelectedTabId=eventArgs.get_tab().get_id();
	    var selectedTabsList='';
	    var strFn=oTabStripId+'.findTabById(\''+oSelectedTabId+'\')';
	    var found=false;
	    
    	
	    if(getCookie("SelectedTabs")){
		    selectedTabsList=getCookie("SelectedTabs");
		    var arr=selectedTabsList.split("|");
		    for(var i=0;i<arr.length;i++){
			    if(arr[i].indexOf(oTabStripId)>-1){
				    selectedTabsList=selectedTabsList.replace(arr[i],strFn);
				    found=true;
				    break;
			    }
		    }
		    if(!found){
			    if(selectedTabsList.length>0){
				    selectedTabsList+='|'+strFn;
			    }else{
				    selectedTabsList=strFn;
			    }
		    }
	    }else{
		    selectedTabsList=strFn;
	    }
	    writeCookie("SelectedTabs",selectedTabsList);
    	if(eval(strFn+'.isSelected()')){
    		return false;
    	}
    }

    function BrokerIDX_setLastSelectedTab(){
	    if(getCookie("SelectedTabs")){
		    var arr=getCookie("SelectedTabs").split("|"),updateTabsList=getCookie("SelectedTabs"),fn='',isVisible='',tn='';
		    for(var i=0;i<arr.length;i++){
			    try {
					tn=eval(arr[i]+'.get_id()');
					isVisible=arr[i]+'.get_visible()';
					fn=arr[i]+'.select()';
					if(eval(isVisible)===true||eval(isVisible)==='true'||eval(isVisible)===1||eval(isVisible==='1')){
						eval(fn);
						BrokerIDX.Tabs.SelectEventFired=true;
					}else{
						throw("Tab " + tn + " Not Found");
					}					
			    } 
			    catch(err){
					//The tab doesn't exist on this page...so we clear this path from the cookie.
				    if(updateTabsList.length>0){
					    if(updateTabsList.indexOf('|'+arr[i])>-1){
						    updateTabsList=updateTabsList.replace('|'+arr[i],'');
					    }else if(updateTabsList.indexOf(arr[i]+'|')>-1){
						    updateTabsList=updateTabsList.replace(arr[i]+'|','');
					    }else{
						    updateTabsList=updateTabsList.replace(arr[i],'');
					    }
				    }
				    //If the Tab Strip in question is the Sidebar, and the previously selected tab is no longer visible,
				    //then we default its view to the first tab (index 0);
				    BrokerIDX_SelectDefault();
			    }
		    }
		    writeCookie("SelectedTabs",updateTabsList);
	    }
    }

    // Usage: BrokerIDX_setSelectedTab('<%=TabStrip.ClientID %>',index);
    // Index value of -1 exits the function before it runs
    function BrokerIDX_setSelectedTab(tabStripId, index){
	    try {
		    if(index>-1){
			    var updateTabsList='',itemToReplace='';
			    var strFn=tabStripId+'.get_tabs().getTab('+index+')';
			    if(getCookie("SelectedTabs")){
				    var arr=getCookie("SelectedTabs").split("|"),updateTabsList=getCookie("SelectedTabs");
				    for(var i=0;i<arr.length;i++){
					    if(arr[i].indexOf(tabStripId)>-1){
						    itemToReplace=arr[i];
						    break;
					    }
				    }
				    if(itemToReplace.length>0 && updateTabsList.length>0){
					    updateTabsList=updateTabsList.replace(itemToReplace,strFn);
				    }else{
					    if(updateTabsList.length>0){
						    updateTabsList+='|'+strFn;
					    }else{
						    updateTabsList=strFn;
					    }
				    }
			    }else{
				    updateTabsList=strFn;
			    }
			    writeCookie("SelectedTabs",updateTabsList);
		    }
		    return;
	    }
	    catch(err){
			return;
	    }
    }

    function BrokerIDX_SelectedTab(tabStripId,index){
	    var strFn=tabStripId+'.get_tabs().getTab('+index+').select()';
	    eval(strFn);
    }


// Checkbox Lists used on the Search Results Features and Search Additional Features lists.
function CbxList(prefix,textboxID,listContainerID,overridelimit,overridemsg){
	var m_limit=overridelimit?overridelimit:2048
	var m_msg=overridemsg?overridemsg:'You have exceeded the number of options that may be selected.\nYou must deselect other options in order to select this option.';
	var m_initialized=false
	var m_id=textboxID;
	var m_lcID=listContainerID
	var m_prefix=prefix;
	
	this.ListContainer = get_container();
	this.TextBox = get_textbox();
	this.List = this.TextBox.value;
	this.UsePrefix = get_prefix();
	this.Limit = get_limit();
	this.DoPostback = true;
	
	function get_textbox(){ return $get(m_id); }
	function get_container(){ return $get(m_lcID); }
	function get_prefix(){ if(BrokerIDX.IsDefined(m_prefix)&&m_prefix.length>0){ return m_prefix }else{ return null; }}
	function get_limit(){ return m_limit; }
	
	this.Click = {
		Fire:function(e,Ctrl,UPId){
			var me = Ctrl;
			var UpdatePanelId = UPId;
			var item=e.target||e.srcElement;
			var list=me.List;
			var prefix='';
			if(BrokerIDX.IsDefined(item)&&item.type==='checkbox'){
				if(me.UsePrefix!==null){
					if(item.id.toLowerCase().indexOf(me.UsePrefix.toLowerCase())>-1){
						prefix = me.UsePrefix;
					}else{
						return false;
					}
				}else{
					prefix = null;
				}
				if(item.checked&&(list.length+item.value.length)<me.Limit&&(prefix.length>0||prefix===null)){
					if(list.length===0){
						list=item.value;
					}else{
						list+='|'+item.value;
					}
				}else if(item.checked&&(list.length+item.value.length)>me.Limit){
					item.checked=false;
					alert(msg);
					return false;
				}else{
					if(list.indexOf('|'+item.value)>-1){
						list=list.replace('|'+item.value,'');
					}else if(list.indexOf(item.value+'|')>-1){
						list=list.replace(item.value+'|','');
					}else if(list.indexOf(item.value)>-1){
						list=list.replace(item.value,'');
					}
				}
				
				me.TextBox.value=list;
				if(me.DoPostback){
					__doPostBack(UpdatePanelId,'');
				}
			}
		}
	}
}


// ### Generic Checkbox List Function with Master Checkbox(es)
// Usage: var o<%=this.ClientID %> = new generic_CbxList('cbxSS','<%= txtSelectedItems.ClientID %>');
function generic_CbxList(prefix,targetId,append,overrideParam){
	var target=getObj(targetId),arrCbxs=new Array(),arrMasterCbxs=new Array(),checkedCount=0,isInitialized=false;
	var param=overrideParam?overrideParam:'key';
	if(append){
		var srcId=append[0];
		if(append.length>1){
			var btnName=append[1];
		}
	}
	
	function get_CheckedCount(){var checked=0;for(var i=0;i<arrCbxs.length;i++){if(arrCbxs[i].checked==true){checked++;}}return checked;}
	
	function process_MakeSelectedList(el,action){var thelist=target?target.value:'',rv=true;switch(action){case "add":if(thelist.length==0){thelist=el.value;}else{if(thelist.indexOf(el.value)==-1){thelist+='|'+el.value;}}break;case "remove":if(thelist.length>0){if(thelist.indexOf("|"+el.value)>-1){thelist=thelist.replace("|"+el.value,'');}else if(thelist.indexOf(el.value+"|")>-1){thelist=thelist.replace(el.value+"|",'');}else if(thelist.indexOf(el.value)>-1){thelist=thelist.replace(el.value,'');}}break;default:break;}return [rv,thelist];}
	function process_MasterCbx(el){if(el.checked){process_AllCbxs("on");}else if(!el.checked){process_AllCbxs("off");}if(arrMasterCbxs.length>0){if(get_CheckedCount()==arrCbxs.length){for(var i=0;i<arrMasterCbxs.length;i++){arrMasterCbxs[i].checked=true;}}else{for(var i=0;i<arrMasterCbxs.length;i++){arrMasterCbxs[i].checked=false;}}}}
	function process_Cbx(el){var arr;if(el.checked){arr=process_MakeSelectedList(el,"add");}else{arr=process_MakeSelectedList(el,"remove");}if(get_CheckedCount()==arrCbxs.length){for(var i=0;i<arrMasterCbxs.length;i++){arrMasterCbxs[i].checked=true;}}else{for(var i=0;i<arrMasterCbxs.length;i++){arrMasterCbxs[i].checked=false;}}set_TargetValue(arr[1]);}
	function process_AllCbxs(action){var arr;switch(action){case "on":for(var i=0;i<arrCbxs.length;i++){arrCbxs[i].checked=true;arr=process_MakeSelectedList(arrCbxs[i],"add");set_TargetValue(arr[1]);}break;case "off":for(var i=0;i<arrCbxs.length;i++){arrCbxs[i].checked=false;arr=process_MakeSelectedList(arrCbxs[i],"remove");set_TargetValue(arr[1]);}break;default:break;}}
	
	function set_TargetValue(olist){if(target){target.value=olist;try{_appendToUrl(srcId,btnName,param)}catch(err){alert(err.message);}}}
	
	function init(){var f=document.forms[0],c=0,mc=0;for(var i=0;i<f.length;i++){if(f.elements[i].id.indexOf(prefix)>-1&&f.elements[i].type=='checkbox'){if(f.elements[i].id.toLowerCase().indexOf("master")>-1){arrMasterCbxs[mc]=f.elements[i];arrMasterCbxs[mc].onclick=function(){process_MasterCbx(this)};mc++;}else{arrCbxs[c]=f.elements[i];arrCbxs[c].onclick=function(){process_Cbx(this)};if(target.value.indexOf(arrCbxs[c].value)>-1){arrCbxs[c].checked=true;}c++;}}}checkedCount=get_CheckedCount();if(checkedCount==arrCbxs.length){for(var i=0;i<arrMasterCbxs.length;i++){arrMasterCbxs[i].checked=true;}}}
	if(!isInitialized){
		init();
		isInitialized=true;
	}
}




function loadCompareScreen(listSrc){
	var list=getCookie(listSrc),compareWin=null;
	if(list==null||list=='null'){
		list=getObj(listSrc);
		if(list&&list.type=='text'){list=list.value;}
	}
	if(list&&list.length>0){
		compareWin = window.open('/idx/search/compare.aspx?key='+list, 'CompareWindow', 'width=800,height=600,left=0,top=0,menubar=yes,resizable=yes,scrollbars=yes,status=yes');
		compareWin.window.focus();
	}else{
		alert("At least 1 item must be selected to view the compare screen.");
		return false;
	}
	return true;
}


// ### Form Validation Functions
	function _restrictTo(e,what){
		var key=e.keyCode||e.which;
		var keyChar,regexp;
		
		if(!(BrokerIDX.IsDefined(key))){key=e.charCode}
		keyChar=String.fromCharCode(key);
		
		switch(what){
			case 'alpha':
				regexp=/[a-zA-Z\-\']|\0|[\b]|\t/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
						return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
				break;
			/* Task 1194 - Added 'Name' validator to allow for spaces */
			case 'name':
				regexp=/[a-zA-Z\-\']|\0|[\b]|\t|\s/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
						return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
				
				break;	
			case 'alphanumeric':
				regexp=/[\w\-\']|\s|\0|[\b]|\t/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
						return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
				break;
			case 'integer':
				regexp=/\d|\0|[\b]|\t/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
							return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
				break;
			case 'decimal':
				regexp=/\d|\.|\0|[\b]|\t/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
							return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
				break;
			case 'email':
				regexp=/\S|\t/;
				if(!regexp.test(keyChar)){
					if(key===36||key===46){
							return key; 
					}else{
						if(e.preventDefault){e.preventDefault();}
						e.returnValue = false;
						return false;
					}
				}
			default:
				break;
		}
	}
	var oTTgt;
	function _integer_moveToNextField(e,args){
		var key=e.keyCode||e.which;
		var el=e.target||e.srcElement;
		var oT,oF=document.forms[0].elements;
		if(!(BrokerIDX.IsDefined(key))){
			key=e.charCode;
			el=e.target;
		}
		keyChar=String.fromCharCode(key);
		
		var regex=/(48)|(49)|(50)|(51)|(52)|(53)|(54)|(55)|(56)|(57)|(96)|(97)|(98)|(99)|(100)|(101)|(102)|(103)|(104)|(105)/;
		var limit=args[0],id=args[1],tabTarget;
		try{
			if(regex.test){
				if(el.value.length==limit){
					oT=document.getElementById(id);
					if(!(oT)){
						for(var item in oF){
							alert(oF[item].getAttribute('id'));
							if(oF[item]&&oF[item].getAttribute('id')){
								if(oF[item].id.toLowerCase().indexOf(id.toLowerCase())>-1){
									oT=oF[item];
									break;
								}
							}
						}
					}
					oTTgt = oT;
					oTTgt.focus();
					if((oTTgt.type==='text'||oTTgt.type==='textarea')&&oTTgt.value.length > 0){
						oTTgt.select();
					}
				}
			}
		}
		catch(ex){
			//alert(ex.message);
		}
	}
	
	function _compareValues(src1Id,src2Id,msgPhldrId,passCssClass,passMsgText,failCssClass,failMsgText){
		var oMsgPhldr=getObj(msgPhldrId);
		var oSrc1=getObj(src1Id);
		var oSrc2=getObj(src2Id);
		if(typeof(oSrc1)!=='undefined'&&typeof(oSrc2)!=='undefined'&&typeof(oMsgPhldr)!=='undefined'){
			if(oSrc1.value.length>0||oSrc2.value.length>0){
				if(oSrc1.value===oSrc2.value){
					oMsgPhldr.className=passCssClass;
					oMsgPhldr.innerHTML=passMsgText;
					oMsgPhldr.style.display='block';
				}else{
					oMsgPhldr.className=failCssClass;
					oMsgPhldr.innerHTML=failMsgText;
					oMsgPhldr.style.display='block';
				}
			}else if(oSrc1.value.length===0&&oSrc2.value.length===0){
				oMsgPhldr.className='';
				oMsgPhldr.innerHTML='';
				oMsgPhldr.style.display='none';
			}
		}
	}

	var validate_isEmail,validate_targetObject;
	function validateEmail(el) {
		/*
		var regexp = "^([a-zA-Z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$";
		var oRegEx = new RegExp(regexp);
		*/
		var oRegEx = /((^[^\.])([\w\W-]+)([^\.])@([^\.])(?:[\w\W]+)([a-zA-Z]{2,4}))/g;
		if(el.value.length!=0){
			if(!oRegEx.test(el.value)){
				alert("The email address you entered appears to be invalid.\nPlease double-check your entry and make sure it is properly formatted.\nex: name@address.com");
				validate_isEmail=false;
				validate_targetObject=el;
				window.setTimeout('_resetFocus()',1);
			}
		}
	}

	function _formatPhone(el){
		var t=el.value,nv='';
		if (el.value.length < 7) {
			return false;
		} else {
			if(t.length==7){
				nv = t.substr(0,3);
				nv += "-" + t.substr(3,4);
			}else if(t.length==10){
				nv += "(" + t.substr(0,3) + ")"; // area code
				nv += " " + t.substr(3,3); // prefix
				nv += "-" + t.substr(6,4); // suffix
			}else{
				nv=t;
			}
			el.value = nv;
			return true;
		}
	}
	
	//Determines if v (value) is an Integer.  Returns true/false
		function isInteger(v){var oRegExp=/(^-?\d\d*$)/;return oRegExp.test(v);}
	
	//Validates and Formats Currency / returns value to source input field
		function validatePrice(el){var a='0123456789',n='',i,j,t;if(el.value.length>0){t=el.value.split(".");for(i=0;i<t[0].length;i++){for(j=0;j<a.length;j++){if(t[0].charAt(i)==a.charAt(j)){n+=a.charAt(j);break;}}}if(n.length==0){el.value='';}else if(n==0||n=='0'){el.value='';}else{el.value=FormatCurrency(n);}}}
		function FormatCurrency(num){num=num.toString().replace(/\$|\,/g,'');if(isNaN(num))num="0";var sign=(num==(num=Math.abs(num)));num=Math.floor(num*100+0.50000000001);cents=num%100;num=Math.floor(num/100).toString();if(cents<10)cents="0"+cents;for(var i=0;i<Math.floor((num.length-(1+i))/3); i++)num=num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));return(((sign)?'':'-')+'$'+num);}
	
	//Parses / Validates v (value) as Positive Integer / returns integer value to source input field unless value is 0, then returns zero-length string
		function validatePosInt(el){var t;if(el.value.length>0){t=parseInt(el.value);if(!isInteger(t)||t<0||t==0||t=='0')t='';el.value=t;return true;}}

	//Two List Boxes Control stuff
		function twoListBoxes_focusOnAvailable(id){var obj=getObj(id);for(var i=0;i<obj.options.length;i++){if(obj.options[i].selected==true){obj.options[i].selected=false;}}}
		function twoListBoxes_focusOnSelected(id){var obj=getObj(id);if(obj){for(var i=0;i<obj.options.length; i++){if(obj.options[i].selected==true){obj.options[i].selected=false;}}}}

/* ### Cookies 
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
*/
function setCookie(name, value, expires, path, domain, secure){
	var arrKeys=value.split("|"),c=arrKeys.length,newValue=value,tempValue='';
	var msg= 'A maximum of 50 listings may be selected for comparison at one tithis.\n';
		msg+='You have selected '+ c +' listings for comparison.\n';
		if((c-50)==1){
			msg+='The last listing will be de-selected automatically from your list.';
		} else {
			msg+='The last '+ (c-50) +' listings will be de-selected automatically from your list.';
		}
	if(arrKeys.length>50){
		for(var i=0;i<50;i++){
			if(tempValue==''){
				tempValue=arrKeys[i];
			} else {
				tempValue+='|'+arrKeys[i];
			}
		}
		newValue=tempValue;
		alert(msg);
	}
	writeCookie(name, newValue, expires, path, domain, secure);
} 

function writeCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ("; path=/") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/*
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
*/
function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1){
        begin = dc.indexOf(prefix);
        if (begin == -1) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ("; path=/") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


//Time related functions
	function timeFixMinutes(minutes){var results=minutes; if (minutes<=9){results='0'+minutes;}; return results;}
	function timeFixHours(hours){var results=hours; if (hours>=13){results=hours-12;}; if (results=='0'){results=12}; return results;}
	function timeGetAMPM(hours){var results = 'AM'; if (hours<=12){results='AM';} else {results='PM';}; return results;}
	function dateGetMonthName(month){}

	function formatDateTime(item){
		var d=item;
		var results='';
		var intMonth=d.getMonth();
		var intDay=d.getDate();
		var intYear=d.getFullYear();
		var intHours=timeFixHours(d.getHours());
		var int24Hours=d.getHours();
		var intMinutes=timeFixMinutes(d.getMinutes());
		var strAMPM=timeGetAMPM(d.getHours());
	    
		var strMilitaryTime=int24Hours + ':' + intMinutes;
		var strAMPMTime=intHours + ':' + intMinutes + ' ' + strAMPM;
	    
		var strMMDDYYYY=intMonth + '/' + intDay + '/' + intYear;
		var strDDMMYYYY=intDay + '/' + intMonth + '/' + intYear;
	    
		results = strMMDDYYYY + ' ' + strAMPMTime;
		return results
	}
