

/* Example message arrays for the two demo scrollers */

var pausecontent=new Array()
pausecontent[0]='<a href="http://feeds.feedburner.com/RealtororgPressRoomHeadlines">Press room headlines from REALTOR.COM</a>'
pausecontent[1]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'

var pausecontent2=new Array()
pausecontent2[0]='<a class="white_link" href="/content.php?page=http://www.mlsfinder.com/fl_mfrmls/reikirealty/index.cfm?action=userlogin">Sign up to get new property updates in your email!</a>'
pausecontent2[1]='<a class="white_link" href="/map_search.php">Map search - the most innovative search tool on the web.</a>'



/* **********************************************
* Pausing up-down scroller- &copy; Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
********************************************** */

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}


	function setDefaultClick(p_src, p_default) {
		if (p_src.value == p_default) {
			p_src.value = "";
		}
	}
	function setDefaultBlur(p_src, p_default) {
		if (p_src.value == "") {
			p_src.value = p_default;
		}
	}
	function updatePropertyType(p_obj) {
		var frm = p_obj.form;
		for (var i = 0; i < p_obj.options.length; i++ ) {
			var field = p_obj.options[i].value;
			if (field != "") frm[field].value = (i == p_obj.selectedIndex) ? "Y" : "";
		}
	}
	function quickSearch(frm) {
		if (frm.temp_address && frm.temp_address.value != "Address") frm.address.value = frm.temp_address.value;
		if (frm.temp_zip_code && frm.temp_zip_code.value != "Zip") frm.zip_code.value = frm.temp_zip_code.value;
		if (frm.temp_property_id && frm.temp_property_id.value != "MLS Number") frm.property_id.value = frm.temp_property_id.value;
		frm.submit();
	}
	function quickSearch2() {
		var frm = document.forms.searchForm;
		if (frm.address.value == "Address") frm.address.value = "";
		frm.submit();
	}

	// this is set to yes after all the variables have been loaded
	city_county_loaded = "no";
	city_page_load_first_run = "Y";
	county_page_load_first_run = "Y";
	useall = true;
	allfactor = 1;
	
	// when all the variables have been loaded via the external js file the city_county_loaded variable will be set to yes.
	// then we can move on
	function checkDataLoad(){
		if (city_county_loaded == "no"){
			setTimeout ("checkDataLoad();", 250);
		}else{
			stateToggle();
			updateCounties();
			updateCities();
		}
	}
	
	// Checks to see if state_list has more than one state - if not, disable the state dropdown
	function stateToggle() {
		if(document.searchForm.state.length == 1) {
			document.searchForm.state.disabled = true;
			document.searchForm.state.style.display = "none";
		}
	}
	
	// checks the current state (if one is defined) and populates the list of counties in the select box
	function updateCounties(){
		f = document.searchForm;
		// blank the select box
		RemoveAll(f.county);
		//RemoveAll(f.chosencities);
		//f.city.value = '';
		// if we need to, add the 'all' option
		if (useall){
			AddToSelect(f.county,"- County -","");
		}
		// loop over the array of states, adding them to the dropdown
		if(counties.length > 0) {
			for (x=0; x < counties.length; x++){
				// a little test to make sure only the right counties show up if a state is chosen
				use_this_county = 1;
				
					chosen_state = f.state.options[f.state.selectedIndex].value;
					if(states[x] != chosen_state){
						use_this_county = 0;
					}
				
				// if the state matches, or if there is no state, add it to the select
				if(use_this_county == 1){		
					AddToSelect(f.county,counties[x],counties[x]);
					//Set the Default County to selected if one is present
					 if (f.DefaultCounty.value.toLowerCase() == counties[x].toLowerCase())
					  {
						SelectOption(f.county, counties[x], true);
					  }
				}
			}
			// select the first one
			if(f.DefaultCounty.value == "")
			 {
			  f.county.selectedIndex=0;
			 }
		} else {
				// There are no counties, so disable the selection box 
				f.county.disabled = true;
				f.county.style.display = "none";
		}
		if (county_page_load_first_run == "Y"){
			county_page_load_first_run = "N";
			
			if ("" != ''){
				SelectOption(f.county, "", "");
			}else if ("" != ''){
				SelectOption(f.county, "", "");
			}
			
		}else{
			// populate the city list
			//RemoveAll(f.chosencities);
			updateCities();
		}
	}
	// this function accepts a county name and returns the index of that county
	// from within the js array that contains the city data
	function getCountyIndex(countyname){
		chosen_state = f.state.options[f.state.selectedIndex].value;
		for (x=0; x<counties.length; x++){
			if(counties[x] == countyname && states[x] == chosen_state){
				return(x);
			}
		}
	}
	// update the city dropdown according to chosen county or 'all' for a given state
	function updateCities(){
		// blank the dropdown
		RemoveAll(f.citylist);
		f.city.value = "";
		AddToSelect(f.citylist, "- City -", "");
		// get the county array index
		countySelectIndex = f.county.selectedIndex - allfactor;
		// less than zero if they chose 'all'
		if (countySelectIndex < 0){
			// now we choose which index points to the chosen state
			chosen_state = f.state.options[f.state.selectedIndex].value;
			chosen_state_index = listfind(state_list, chosen_state, ",");
			// loop over the state/city array and build the list
			if(chosen_state_index > 0){
				for (x=0; x<all_array[chosen_state_index].length; x++){
					AddToSelect(f.citylist, all_array[chosen_state_index][x], all_array[chosen_state_index][x]);

				}
			}else{
				// this will only happen if the admin puts a state in the list for a given market and there happen
				// to be no cities in the db that match.  this will be VERY rare, if ever.
				alert("No Cities in this state")
			}
		}else{
			// pull back the index for the chosen county
			countyIndex = getCountyIndex(f.county.options[f.county.selectedIndex].value)
			
			// loop over the county/city array and add to city select
			for (x=0; x<cities[countyIndex].length; x++){
				AddToSelect(f.citylist, cities[countyIndex][x], cities[countyIndex][x]);
			}
		}
	}
	var f;

	function listfind(thelist, thevalue, delim){
		if (! delim){
			delim = ",";
		}
		l = listlen(thelist, delim);
		listpos = -1;
		
		for (var x = 1; x < l; x++){
			listelement = listgetat(thelist,x,delim);
			if (listelement == thevalue){
				listpos = x;
				break;
			}
		}
		return listpos;
	}
	
	window.onload=checkDataLoad;



function MoveDropDown(tsource, tdest){
	var thelength = 0;
	var returnvalue;
	for (var i = tsource.length - 1; i >= 0; i--) {
		if (tsource.options[i].selected) {
			returnvalue = tsource.options[i].value;

			tdest.length ++;
			thelength = tdest.length;
			
			tdest.options[thelength - 1].text = tsource.options[i].text;
			tdest.options[thelength - 1].value = tsource.options[i].value;
			
		
			var oldlength = tsource.length;
			for (var j = i; tsource.length > j + 1; j++) {
				tsource.options[j].value = tsource.options[j + 1].value;
				tsource.options[j].text = tsource.options[j + 1].text;
			}
			
			tsource.options[j].value = "";
			tsource.options[j].text = "";
			tsource.length = tsource.length - 1;
		}
	}
	return (returnvalue);
}
function MoveDropDown2(tsource, tdest){
	for (var i = 0; i < tsource.length; i++) {
		if (tsource.options[i].selected) {
			AddIf(tdest,tsource.options[i].text,tsource.options[i].value)
		}
	}
	RemoveSelected(tsource);
}

function SelectOption(tsource, thevalue, nocase){
	tsource.selectedIndex = -1;
	var hit = 0;
	for (var i = 0; i < tsource.length; i++) {
		if (listfind(thevalue.toLowerCase(),tsource.options[i].value.toLowerCase())>0 || tsource.options[i].value.toLowerCase() == thevalue.toLowerCase()) {
			tsource.options[i].selected = true;
			if (hit == 0 ){
//				alert(i + ' ' + tsource[i].text);
				tsource.selectedIndex = i;
				hit = 1;
			}
		}
	}
}
function RemoveSelected(tsource){

	for (var x = tsource.length-1; x>= 0; x--){
		if (tsource.options[x].selected){
			for (var j = x; tsource.length > j + 1; j++) {
				tsource.options[j].value = tsource.options[j + 1].value;
				tsource.options[j].text = tsource.options[j + 1].text;
			}
			
			tsource.options[j].value = "";
			tsource.options[j].text = "";
			tsource.length = tsource.length - 1;
		}
	}
	tsource.selectedIndex = -1;
}

function ChangeSelected(tsource, thetext, thevalue){

	for (var x = tsource.length-1; x>= 0; x--){
		if (tsource.options[x].selected){
			tsource.options[x].value = thevalue;
			tsource.options[x].text = thetext;
		}
	}
}

function AddToSelect(destdrop, thetext, thevalue){
	destdrop.length ++;
	thelength = destdrop.length;
	destdrop.options[thelength - 1].text = thetext;
	destdrop.options[thelength - 1].value = thevalue;
	return (1);
}


function SelectAll(tsource){
	for (var x = 0; x < tsource.length; x++){
		tsource.options[x].selected = true;
	}
}

function RemoveAll(formelement){
	var thelength = formelement.length
	for (var i = 0; thelength > i; i++) {
		RemoveLast(formelement);
	}
}


function RemoveLast(formelement){
	var thelength = formelement.length;
	
	if (thelength >= 1){
		formelement.options[thelength - 1].value = "";
		formelement.options[thelength - 1].text = "";
		formelement.length = thelength - 1;	
	}
}

function MoveUpDown(source, whichway){
	s = source.selectedIndex;
	if (s == 0 && whichway == 'up'){
		return;
	}
	if (s == (source.length-1) && whichway == 'down'){
		return;
	}
	if(whichway == 'up'){
		offset = -1;
	}else{
		offset = 1;
	}
	v = source.options[s + offset].value;
	t = source.options[s+ offset].text;
	source.options[s + offset].value = source.options[s].value;
	source.options[s + offset].text = source.options[s].text;
	source.options[s].value = v;
	source.options[s].text = t;
	source.options[s + offset].selected = true;
	source.options[s].selected = false;
}


function listappend(thelist, newval, delim){
	if (newval == ""){
		newval = " ";
	}
	if (! delim){
		delim = ",";
	}

	if (thelist == ""){
		newstring = newval;
	}else{
		newstring = thelist + delim + newval;
	}
	return newstring;
}

function listgetat(thelist, theindex, delim){
	if (! delim){
		delim = ",";
	}

	currpos = 1;
	start = 0;
	end = -1;
	if (theindex == 1){
		setendflag = 1;
	}else{
		setendflag = 0;
	}
	for (var x=1; x <= thelist.length; x++){
		if (thelist.substring(x,x+1) == delim){
			currpos ++;
			if(setendflag == 1){
				setendflag = 0;
				end = x;
			}
			if(currpos == theindex){
				start = x + 1;
				end = thelist.length;
				setendflag = 1;
			}
		}
	}
	if (start == 0 && end == -1){
		returnstring = "";
	}else{
		returnstring = thelist.substring(start,end);
	}

	return returnstring;
}

function listdeleteat(thelist, listpos, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);

	newlist = '';
	for (var x = 1; x <= l; x++){
		if (x != listpos){
			listelement = listgetat(thelist,x,delim);
			newlist = listappend(newlist,listelement,delim);
		}
	}
	return newlist;
}

function listlen(thelist, delim){
	if (! delim){
		delim = ",";
	}
	listcount = 1;
	for (var x=1; x <= thelist.length; x++){
		if (thelist.substring(x,x+1) == delim){
			listcount ++;
		}
	}
	return listcount;
}

function listcontains(thelist, thevalue, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);
	listpos = -1;
	
	for (var x = 1; x < l; x++){
		listelement = listgetat(thelist,x,delim);
		if (listelement.indexOf(thevalue) >= 0){
			listpos = x;
			break;
		}
	}
	return listpos;
}

function listcontainsnocase(thelist, thevalue, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);
	listpos = -1;
	uc = thevalue.toUpperCase();
	
	for (var x = 1; x < l; x++){
		listelement = listgetat(thelist,x,delim);
		listelement = listelement.toUpperCase();
		if (listelement.indexOf(uc) >= 0){
			listpos = x;
			break;
		}
	}
	return listpos;
}

function listfind(thelist, thevalue, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);
	listpos = -1;
	
	for (var x = 1; x < l; x++){
		listelement = listgetat(thelist,x,delim);
		if (listelement == thevalue){
			listpos = x;
			break;
		}
	}
	return listpos;
}

function listfindnocase(thelist, thevalue, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);
	listpos = -1;
	
	for (var x = 1; x < l; x++){
		listelement = listgetat(thelist,x,delim);
		if (listelement.toUpperCase() == thevalue.toUpperCase()){
			listpos = x;
			break;
		}
	}
	return listpos;
}

function listfirst(thelist, delim){
	return listgetat(thelist,1,delim);
}

function listlast(thelist, delim){
	return listgetat(thelist,listlen(thelist,delim),delim);
}

function listprepend(thelist, thevalue, delim){
	return listappend(thevalue, thelist, delim)
}

function listsetat(thelist, listpos, thevalue, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);

	newlist = '';
	for (var x = 1; x <= l; x++){
		if (x != listpos){
			listelement = listgetat(thelist,x,delim);
			newlist = listappend(newlist,listelement,delim);
		}else{
			newlist = listappend(newlist,thevalue,delim);
		}
	}
	return newlist;
}

function listsort(thelist, delim){
	if (! delim){
		delim = ",";
	}
	l = listlen(thelist, delim);
	a = new Array(1);

	for (var z = 1; z <= l; z++){
		newl = a.length;
		a[newl] = listgetat(thelist, z, delim);
	}
	
	var v = '';
	var t = '';
	
	for (var x = 1; x < a.length; x++){
		for (var y = x; y < a.length; y++){
			string1 = a[x];
			string1 = string1.toUpperCase();
			string2 = a[y];
			string2 = string2.toUpperCase();
			if (string2 < string1){
				v = a[x];
				a[x] = a[y];
				a[y] = v;
			}
		}
	}
	
	
	newlist = "";
	for (var x = 1; x <= l; x++){
		newlist = listappend(newlist,a[x],delim);
	}
	return( newlist);
}

			var curDateTime = new Date();
			var tzoffset = "-" + (curDateTime.getTimezoneOffset()/60);
			var expiredate = new Date();
			expiredate.setTime(expiredate.getTime()+(120*24*60*60*1000)); // set expire date to 120 from now 
			if (-4 != tzoffset) {
				document.cookie = "mlsfinder_tz="+tzoffset+";expires="+expiredate.toGMTString();
			}
		

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

