 	function MapIt(){
		document.DataForm.SearchBy.value= "Map";
	}

	function doHomePageRealtorSearch(){
		$("#" + 'TabSimpleSearch').attr("class","iQ_FormTabInactive");
		$("#" + 'TabRealtorSearch').attr("class","iQ_FormTabActive");
		$('#' + 'RealtorSearch').css({"display":"block"});
		$('#' + 'RealtorSearch').css({"visibility":"visible"});
		$('#' + 'SimpleSearch').css({"display":"none"});
		$('#' + 'SimpleSearch').css({"visibility":"hidden"});
	}

	function doHomePageSimpleSearch(){
		$("#" + 'TabSimpleSearch').attr("class","iQ_FormTabActive");
		$("#" + 'TabRealtorSearch').attr("class","iQ_FormTabInactive");
		$('#' + 'RealtorSearch').css({"display":"none"});
		$('#' + 'RealtorSearch').css({"visibility":"hidden"});
		$('#' + 'SimpleSearch').css({"display":"block"});
		$('#' + 'SimpleSearch').css({"visibility":"visible"});
 	}

$(document).ready( function() {  

    $("#AreaList").multiSelect();  

}); 
 
 
 
 if(jQuery) (function($){
	$.extend($.fn, {
		multiSelect: function(o, callback) {
			// Default options
			if( !o ) var o = {};
			if( o.selectAll == undefined ) o.selectAll = true;
			if( o.selectAllText == undefined ) o.selectAllText = "Select All";
			if( o.noneSelected == undefined ) o.noneSelected = 'Select options';
			if( o.oneOrMoreSelected == undefined ) o.oneOrMoreSelected = '% selected';
			if( o.width == undefined ) o.width = '';
			if( o.height == undefined ) o.height = '';
			
			// Initialize each multiSelect
			$(this).each( function() {
				var options = o;
				var objSelect = $(this);
				var objSelectOptions = $('option',objSelect);
				
				//if there is not more then 1 record then just return
				//since there is no reason to do check boxes for less then 2
				if(objSelectOptions.length < 2){
					return true;	
				}

				if( options.height == '' ){
					options.height = objSelect.height();
				}

				if( options.width == '' ){
					options.width = objSelect.width();
				}
	
				if($.browser.msie){
					var innerWidth = eval(options.width - 20);
				}else{
					var innerWidth = eval(options.width - 20);
				}
				
				var arrHTML = [];

				arrHTML.push('<input type="text" readonly="readonly" name="' + objSelect.attr('name') + '_Display" class="multiSelect" value="" style="cursor: default; width:' + options.width + 'px;" />');
				arrHTML.push('<div class="multiSelectOptions" style="position: absolute; z-index: 99999; display: none; width:' + options.width + 'px;">');

				if( options.selectAll ){
					arrHTML.push('<label style="width:' + innerWidth + 'px;" class="selectAll"><input type="checkbox" style="width:20px" class="selectAll" />' + options.selectAllText + '</label>');
				}
				
				var bHasSelectedOptions = false;

				objSelectOptions.each( function(){
					var objOption = $(this);

					if( $(this).val() != '' ) {
						arrHTML.push('<div style="overflow:hidden; width:' + innerWidth + 'px; display:table;">');
						if( objOption.attr('selected') ){
							bHasSelectedOptions = true;
							arrHTML.push('<label style="height:20px;"><input type="checkbox" style="width:20px; font-weight:normal" name="' + objSelect.attr('name') + '" value="' + objOption.val() + '" checked="checked" />' + objOption.html() + '</label>');
						}else{
							arrHTML.push('<label style="height:20px;"><input type="checkbox" style="width:20px; font-weight:normal" name="' + objSelect.attr('name') + '" value="' + objOption.val() + '" />' + objOption.html() + '</label>');
						}
						arrHTML.push('</div>');
					}
				});

				arrHTML.push('</div>');

				objSelect.after(arrHTML.join(""));
				
				//now get a reference to the check boxes
				var objChecks = objSelect.next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').not('.selectAll');

				// Hide the original select box
				objSelect.hide();

				//because the user can use the back button and we remove the original select
				//we need to retrieve the values that were checked from a cookie
				var sCookie = $(this).GetCookie('MULTISELECT_' + objSelect.attr('name').toUpperCase());

				//if the select box already had options selected then dont check the cookie value
				//that way we just use the selected options
				if(!bHasSelectedOptions){
					if(sCookie != '' && sCookie != 'undefined'){
						var arrCookieVals = sCookie.split(",");

						objChecks.each( function() {
							var objCheck = $(this);
							objCheck.attr('checked',false);
							var sCheckVal = ',' + objCheck.val() + ',';

							for(var c = 0; c < arrCookieVals.length; c++){
								var sCookieVal = ',' + arrCookieVals[c] + ',';	
								if(sCheckVal.toString().toUpperCase().indexOf(sCookieVal) > -1){
									objCheck.attr('checked',true);
								}
							}
						});
					}
				}

				// Events
				var objDisplay = objSelect.next('.multiSelect');

				objDisplay.mouseover( function() {
					$(this).addClass('hover');
				})

				objDisplay.mouseout( function() {
					$(this).removeClass('hover');
				})

				objDisplay.click( function() {
					// Show/hide on click
					if( objSelect.hasClass('active') ) {
						$(this).multiSelectOptionsHide();
					} else {
						$(this).multiSelectOptionsShow();
					}
					return false;
				})

				objDisplay.focus( function() {
					// So it can be styled with CSS
					$(this).addClass('focus');
				})

				objDisplay.blur( function() {
					// So it can be styled with CSS
					$(this).removeClass('focus');
				});

				
				// Determine if Select All should be checked initially
				if( options.selectAll ) {
					var sa = true;
					objChecks.each( function() {
						if( !$(this).attr('checked')){
							sa = false;
						}
					});

					if( sa ){
						objSelect.next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').attr('checked', true).parent().addClass('checked');
					}
				}
				
				// Handle Select All
				objSelect.next('.multiSelect').next('.multiSelectOptions').find('INPUT.selectAll').click( function() {
					var objParent = $(this).parent().parent();

					if( $(this).attr('checked') == true ){
						objParent.find('INPUT:checkbox').attr('checked', true).parent().addClass('checked');
					}else{
						objParent.find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
					}

					objParent.multiSelectUpdateDisplay(options,objSelect.attr('name'));
				});
				
				// Handle checkboxes
				objSelect.next('.multiSelect').next('.multiSelectOptions').find('INPUT:checkbox').click( function() {
					var objParent = $(this).parent().parent().parent();
					
					objParent.multiSelectUpdateDisplay(options,objSelect.attr('name'));
					objParent.find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
					objParent.prev('.multiSelect').focus();

					if( !$(this).attr('checked') ){
						objParent.find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
					}

					if( callback ){
						callback($(this));
					}
				});
				
				// Initial display
				objSelect.next('.multiSelect').next('.multiSelectOptions').each( function() {
					$(this).multiSelectUpdateDisplay(options,objSelect.attr('name'));
					$(this).find('INPUT:checked').parent().addClass('checked');
				});
				
				// Handle hovers
				objSelect.next('.multiSelect').next('.multiSelectOptions').find('LABEL').mouseover( function() {
					$(this).parent().find('LABEL').removeClass('hover');
					$(this).addClass('hover');
				}).mouseout( function() {
					$(this).parent().find('LABEL').removeClass('hover');
				});
				
				// Keyboard
				objSelect.next('.multiSelect').keydown( function(e) {
					// Is dropdown visible?
					if( $(this).next('.multiSelectOptions').is(':visible') ) {
						// Dropdown is visible
						// Tab
						if( e.keyCode == 9 ) {
							$(this).addClass('focus').trigger('click'); // esc, left, right - hide
							$(this).focus().next(':input').focus();
							return true;
						}
						
						// ESC, Left, Right
						if( e.keyCode == 27 || e.keyCode == 37 || e.keyCode == 39 ) {
							// Hide dropdown
							$(this).addClass('focus').trigger('click');
						}
						// Down
						if( e.keyCode == 40 ) {
							if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
								// Default to first item
								$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
							} else {
								// Move down, cycle to top if on bottom
								$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').next('LABEL').addClass('hover');
								if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
									$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
								}
							}
							
							// Adjust the viewport if necessary
							$(this).multiSelectAdjustViewport($(this) );
							
							return false;
						}
						// Up
						if( e.keyCode == 38 ) {
							if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
								// Default to first item
								$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
							} else {
								// Move up, cycle to bottom if on top
								$(this).next('.multiSelectOptions').find('LABEL.hover').removeClass('hover').prev('LABEL').addClass('hover');
								if( !$(this).next('.multiSelectOptions').find('LABEL').hasClass('hover') ) {
									$(this).next('.multiSelectOptions').find('LABEL:last').addClass('hover');
								}
							}
							
							// Adjust the viewport if necessary
							$(this).multiSelectAdjustViewport($(this) );
							
							return false;
						}
						// Enter, Space
						if( e.keyCode == 13 || e.keyCode == 32 ) {
							// Select All
							if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').hasClass('selectAll') ) {
								if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
									// Uncheck all
									$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', false).parent().removeClass('checked');
								} else {
									// Check all
									$(this).next('.multiSelectOptions').find('INPUT:checkbox').attr('checked', true).parent().addClass('checked');
								}
								$(this).next('.multiSelectOptions').multiSelectUpdateDisplay(options,objSelect.attr('name'));
								if( callback ) callback($(this));
								return false;
							}
							// Other checkboxes
							if( $(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked') ) {
								// Uncheck
								$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', false);
								$(this).next('.multiSelectOptions').multiSelectUpdateDisplay(options,objSelect.attr('name'));
								$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
								// Select all status can't be checked at this point
								$(this).next('.multiSelectOptions').find('INPUT:checkbox.selectAll').attr('checked', false).parent().removeClass('checked');
								if( callback ) callback($(this));
							} else {
								// Check
								$(this).next('.multiSelectOptions').find('LABEL.hover INPUT:checkbox').attr('checked', true);
								$(this).next('.multiSelectOptions').multiSelectUpdateDisplay(options,objSelect.attr('name'));
								$(this).next('.multiSelectOptions').find('LABEL').removeClass('checked').find('INPUT:checked').parent().addClass('checked');
								if( callback ) callback($(this));
							}
						}
						return false;
					} else {
						// Dropdown is not visible
						if( e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.keyCode == 32 ) { // down, enter, space - show
							// Show dropdown
							$(this).removeClass('focus').trigger('click');
							$(this).next('.multiSelectOptions').find('LABEL:first').addClass('hover');
							return false;
						}
						//  Tab key
						if( e.keyCode == 9 ) {
							// Shift focus to next INPUT element on page
							$(this).focus().next(':input').focus();
							return true;
						}
					}
					// Prevent enter key from submitting form
					if( e.keyCode == 13 ) return false;
					
				});
				
				// Apply bgiframe if available on IE6
				if( $.fn.bgiframe ) objSelect.next('.multiSelect').next('.multiSelectOptions').bgiframe();
				
				// Eliminate the original form element
				objSelect.remove();
			});
			
		},
		
		// Hide the dropdown
		multiSelectOptionsHide: function() {
			$(this).removeClass('active').next('.multiSelectOptions').hide();
		},
		
		// Show the dropdown
		multiSelectOptionsShow: function() {
			// Hide any open option boxes
			$('.multiSelect').multiSelectOptionsHide();
			$(this).next('.multiSelectOptions').find('LABEL').removeClass('hover');
			$(this).addClass('active').next('.multiSelectOptions').show();
			
			// Position it
			var offset = $(this).position();
			$(this).next('.multiSelectOptions').css({ top:  offset.top + $(this).outerHeight() + 'px' });
			$(this).next('.multiSelectOptions').css({ left: offset.left + 'px' });
			
			/* IE6 does not support max-height */
			if( $.browser.msie && typeof document.body.style.maxHeight === "undefined" ) {
				var listHeight = 0;
				$(this).next('.multiSelectOptions').children().each(function() {
					listHeight += this.offsetHeight;
				});
				// @todo - made this height configurable
				if (listHeight > 200) $(this).next('.multiSelectOptions').css({ height: '200px' });
			}
			
			// Disappear on hover out
			multiSelectCurrent = $(this);
			var timer = '';
			$(this).next('.multiSelectOptions').hover( function() {
				clearTimeout(timer);
			}, function() {
				timer = setTimeout('jQuery(multiSelectCurrent).multiSelectOptionsHide(); $(multiSelectCurrent).unbind("hover");', 250);
			});
			
		},
		
		// Update the textbox with the total number of selected items
		multiSelectUpdateDisplay: function(options,sFieldName) {
			var i = 0, s = '';
			var arrVals = [];
			
			$(this).find('INPUT:checkbox:checked').not('.selectAll').each( function() {
				arrVals.push($(this).val());
				i++;
			})

			//set a cookie for what vals were selected.
			$(this).SetCookie('MULTISELECT_' + sFieldName.toUpperCase(), arrVals.join(","),10);
			
			if( i == 0 ) {
				$(this).prev('INPUT.multiSelect').val( options.noneSelected );
			} else {
				if( options.oneOrMoreSelected == '*' ) {
					var display = '';

					$(this).find('INPUT:checkbox:checked').each( function() {
						if( $(this).parent().text() != options.selectAllText ){
							display = display + $(this).parent().text() + ', ';
						}
					});

					display = display.substr(0, display.length - 2);
					$(this).prev('INPUT.multiSelect').val( display );
				} else {
					$(this).prev('INPUT.multiSelect').val( options.oneOrMoreSelected.replace('%', i) );
				}
			}
		},
		
		// Ensures that the selected item is always in the visible portion of the dropdown (for keyboard controls)
		multiSelectAdjustViewport: function(el) {
			// Calculate positions of elements
			var i = 0;
			var selectionTop = 0, selectionHeight = 0;

			$(el).next('.multiSelectOptions').find('LABEL').each( function() {
				if( $(this).hasClass('hover') ) {
					selectionTop = i;
					selectionHeight = $(this).outerHeight();
					return;
				}

				i += $(this).outerHeight();
			});

			var divScroll = $(el).next('.multiSelectOptions').scrollTop();
			var divHeight = $(el).next('.multiSelectOptions').height();

			// Adjust the dropdown scroll position
			$(el).next('.multiSelectOptions').scrollTop(selectionTop - ((divHeight / 2) - (selectionHeight / 2)));
		},

		SetCookie: function( name, value, expires){
			// set time, it's in milliseconds
			var today = new Date();
			today.setTime( today.getTime() );
		
			/*
			if the expires variable is set, make the correct 
			expires time, the current script below will set 
			it for x number of days, to make it for hours, 
			delete * 24, for minutes, delete * 60 * 24
			*/
			if ( expires ){
				expires = expires * 1000 * 60 ;
			}
		
			//We have to do this becasue of IE Sucking so BAD
			//If you dont do this then you get duplicate Cookies when you use CF
			var tDomain =  window.location.host.toLowerCase();
			//tDomain = tDomain.replace('www.','');
		
			var expires_date = new Date( today.getTime() + (expires) );
		
			document.cookie = name.toUpperCase() + "=" + escape(value) +
				( ( expires ) ? "; expires=" + expires_date.toGMTString() : "" ) + 
				( "; path=/" ) + 
				( "; domain=" + tDomain );
		},

		// this fixes an issue with the old method, ambiguous values 
		// with this test document.cookie.indexOf( name + "=" );
		GetCookie: function( name ) {
			// first we'll split this cookie up into name/value pairs
			// note: document.cookie only returns name=value, not the other components
			var a_all_cookies = document.cookie.split( ';' );
			var a_temp_cookie = '';
			var cookie_name = '';
			var cookie_value = '';
			var b_cookie_found = false; // set boolean t/f default f

			for ( i = 0; i < a_all_cookies.length; i++ ){
				// now we'll split apart each name=value pair
				a_temp_cookie = a_all_cookies[i].split( '=' );

				// and trim left/right whitespace while we're at it
				cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

				// if the extracted name matches passed check_name
				if ( cookie_name.toUpperCase() == name.toUpperCase()){
					b_cookie_found = true;
					// we need to handle case where cookie has no value but exists (no = sign, that is):
					if ( a_temp_cookie.length > 1 )
					{
						cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
					}
					// note that in cases where cookie is initialized but no value, null is returned
					return cookie_value;
					break;
				}
				a_temp_cookie = 'undefined';
				cookie_name = '';
			}
			if ( !b_cookie_found ){
				return 'undefined';
			}
		},

		// this deletes the cookie when called
		DeleteCookie: function( name, path, domain ) {
			document.cookie = name.toUpperCase() + "=" +
			( ( path ) ? ";path=" + path : ";path=/") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
		}		
		
	});
	
})(jQuery);