function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popup(newURL)
{
newWindow = window.open(newURL, "refer", "statusbar,resizable,scrollbars,menubar=0,height=400,width=500")
newWindow.focus();
}	
function popuplogin()
{
	popup('login.asp')
}	
function send_to_flash_DoFSCommand(command, args) {
  var send_to_flashObj = InternetExplorer ? send_to_flash : document.send_to_flash;
  var theVarFromFlash = args;
  window.document.get_var.SetVariable("displayVar", theVarFromFlash);
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split('&');
  for (var i=0;i<vars.length;i++) {
	var pair = vars[i].split('=');
	if (pair[0] == variable) {
	  return pair[1];
	}
  } 
}

	//MM_swapImage('chkbox1','','site_images/checkbox_checked.gif',1)
function updateloc(locid)
{
	//alert(locid + "-" + document.MainSearch.metroid.value)
	if (!isNaN(parseInt(locid)))
	
	//if ((locid != 1) || (parseInt(document.MainSearch.metroid.value) != 1))
	{
		updateloc2(locid)
	}
}
function obs_updateloc2(locid)
{
	tot = document.MainSearch.Area.options.length;	
	vArray = new Array;
	tArray = new Array;	
	//if ((locid == 1 || locid == 0) && parseInt(document.MainSearch.metroid.value) != "1")
	
	window.open("/citycookie.asp?metroid="+locid,"cityCookie","width=10,height=10");
	
	//{
	if (locid == 1)	
	{
		for (i=tot;i>=0;i--)
		{
			document.MainSearch.Area.options[i] = null;
		}
		vArray[0] = "Map";
		vArray[1] = "Map";
		vArray[2] = "*Web1";
		vArray[3] = "*Web7";
		vArray[4] = "*Web6";
		vArray[5] = "*Web3";
		vArray[6] = "*Web2";
		vArray[7] = "*Web8";
		vArray[8] = "*Web5";
		vArray[9] = "*Web4";
		vArray[10] = "All"
		
		tArray[0] = "";
		tArray[1] = "Select By City (Next Page)";
		tArray[2] = "Minneapolis, City of";
		tArray[3] = "North Region";
		tArray[4] = "Northeast Region";
		tArray[5] = "Northwest Region";
		tArray[6] = "Saint Paul, City of";
		tArray[7] = "South Region";
		tArray[8] = "Southeast Region";
		tArray[9] = "Southwest Region";
		tArray[10] = "Entire Metro Area";
		
		for (q=0;q<=10;q++)
		{
			
			document.MainSearch.Area.options[q] = new Option();
			document.MainSearch.Area.options[q].value = vArray[q];
			document.MainSearch.Area.options[q].text = tArray[q];
			document.MainSearch.Area.options[0].selected = true;
		}			
	}
	if (locid == 2)
	{
		for (i=tot;i>=0;i--)
		{
			document.MainSearch.Area.options[i] = null;
		}
		vArray[0] = "Map"
		vArray[1] = "*Web9"
		tArray[0] = ""
		tArray[1] = "St. Cloud Area"
		for (q=0;q<=1;q++)
		{
			document.MainSearch.Area.options[q] = new Option();
			document.MainSearch.Area.options[q].value = vArray[q];
			document.MainSearch.Area.options[q].text = tArray[q];
			document.MainSearch.Area.options[0].selected = true;
		}
	}
	if (locid == 3)
	{
		for (i=tot;i>=0;i--)
		{
			document.MainSearch.Area.options[i] = null;
		}
		vArray[0] = "Map"
		vArray[1] = "*Web10"
		tArray[0] = ""
		tArray[1] = "Rochester Area"
		for (q=0;q<=1;q++)
		{
			document.MainSearch.Area.options[q] = new Option();
			document.MainSearch.Area.options[q].value = vArray[q];
			document.MainSearch.Area.options[q].text = tArray[q];
			document.MainSearch.Area.options[0].selected = true;
		}
	}
	
	document.MainSearch.metroid.value = locid;
}

function checkvalues()
{
	
	if (document.MainSearch.MinRent.value != "")
	{
		if (isNaN(parseInt(document.MainSearch.MinRent.value)))
		{
			alert("Please enter a numeric Minimum Rent value.");
			document.MainSearch.MinRent.focus();
			return false;
		}
		else
		{
			document.MainSearch.MinRent.value = parseInt(document.MainSearch.MinRent.value)
		}
	}
	
	if (document.MainSearch.MaxRent.value != "")
	{
		if (isNaN(parseInt(document.MainSearch.MaxRent.value)))
		{
			alert("Please enter a numeric Maximum Rent value.")
			document.MainSearch.MaxRent.focus();
			return false;
		}
		else
		{
			document.MainSearch.MaxRent.value = parseInt(document.MainSearch.MaxRent.value)
		}
	}
	
	if (parseInt(document.MainSearch.MinRent.value) > parseInt(document.MainSearch.MaxRent.value))
	{
		alert("Your lower rent range is higher than your upper rent range.");
		document.MainSearch.MinRent.focus();
		return false;
	
	}
	if (document.MainSearch.AreaNew.options[document.MainSearch.AreaNew.selectedIndex].value == "!")
	{
		alert("Please choose a metro area.");
		document.MainSearch.AreaNew.focus();
		return false;
	}
	
	/* document.MainSearch.submit(); */
	return true;

}
function openNewWindow(URLtoOpen, windowName, windowFeatures)
{ 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
function popuprefine(newURL)
{
	newWindow = window.open(newURL, "nospam", "statusbar,resizable,scrollbars,menubar=0,height=565,width=525")
	newWindow.focus();
}
function displayrefine()
{	
	if (document.MainSearch.refine.options[document.MainSearch.refine.selectedIndex].value == "1")
	{
		var mystr = "mainpage=1&"
		for (i=0;i<document.RefineSearch.elements.length;i++)
		{
			iname = document.RefineSearch.elements[i].name;
			ival = document.RefineSearch.elements[i].value;
			if (ival == "  ")
			{
				ival = ""
			}
			mystr = mystr + iname + "=" + ival + "&";
		
		}

		mystr = mystr + "metroid=" + document.MainSearch.metroid.value + "&";
		
		if(typeof (document.MainSearch.fname) != 'undefined'){
			mystr = mystr + "fname=" + document.MainSearch.fname.value + "&";
		}
		if(typeof (document.MainSearch.lname) != 'undefined'){
			mystr = mystr + "lname=" + document.MainSearch.lname.value + "&";
		}
		if(typeof (document.MainSearch.mname) != 'undefined'){
			mystr = mystr + "mname=" + document.MainSearch.mname.value + "&";
		}
		if(typeof (document.MainSearch.email) != 'undefined'){
			mystr = mystr + "email=" + document.MainSearch.email.value + "&";
		}
		if(typeof (document.MainSearch.password) != 'undefined'){
			mystr = mystr + "password=" + document.MainSearch.password.value + "&";
		}
		
		popuprefine('refinesearch.asp?refpage=searchform&' + mystr)
	}
}

function freerent()
{	
	myheight = screen.height - 100;
	mywidth = 670;
	mystr = "statusbar,scrollbars,menubar,height=" + myheight + ",width=" + mywidth + ",top=20,left=20";
	newWindow = window.open("renterperks.asp", "freerent", mystr)
	newWindow.focus();
}
function locto2()
{
	updateloc('2')
}
function nospam(newURL)
{
	newWindow = window.open(newURL, "nospam", "statusbar,resizable,scrollbars,menubar=0,height=565,width=525")
	newWindow.focus();
}
function getpopup(newURL)
{
	newWindow = window.open(newURL, "get100", "statusbar,resizable,scrollbars,menubar=0,height=230,width=375")
	newWindow.focus();
}
//if ("<% request("mid") %>" == '2')
//{
	//window.setTimeout(locto2,7000)	
//}
