

//--------------------------all javascript functions---------------------

function go_back()
 {
  window.history.go(-1); 
 }

function print_win()
 {
  window.print();
 }
 
function makePopUp(whereTo, winWidth, winHeight) 
 {
  remote = window.open("","remotewin","width="+winWidth+",height="+winHeight+",menubar=0,toolbar=no,scrollbars=yes,resizable=1");
  remote.location.href = whereTo; 
  remote.focus();
 }
 
function submit_form(form_name, form_action)
 {
  window.document.forms[form_name].action = form_action; 
  window.document.forms[form_name].submit(); 
 }
 
function close_win()
 {
  window.close(); 
 }
 
//-------------------------random images-------------------------


var maxHeaders = 4; 

//Global, set total number of Header Images supplied inimages/headers/ folder -1

function random_img() 
 {
	var randomInt = Math.floor(Math.random() * maxHeaders);
	document.getElementById("top_pic").src="/images/hm_" + randomInt + ".gif";
	return;
 }


//-----------------------pop up window at mapquest---------------------------

  /* Side panel generator  */
  /* Source: www.chicago.tribune.com/homes/ */
function make_Win (targurl, width, height, winopts) {
if (window.sidebars == null) {
sidebars = new Object;
sidebars.length = 1;
}
allopts = "width=" + width + ",height=" + height + "," + winopts;
var tempref = window.open(targurl, "sidebar" + sidebars.length, allopts);
sidebars[sidebars.length] = tempref;
sidebars.length++;
}
function killwins() {
if (navigator.appName != "Microsoft Internet Explorer") {
if (window.sidebars != null) {     
for (i = 1; i < sidebars.length; i++) {sidebars[i].close();}
}}}



//--------------------------search functions--------------------------------

//-------------------clicks on Chicago neighborhood map--------------------


 function click_area( strName )
 
  {
   
    document.frmSearch.elements[strName].checked = !document.frmSearch.elements[strName].checked;

  } 
  
//-----------------------expand/contract Chicago maps--------------------------

  function expandIt(obj)
    {
      pict = event.srcElement;
    
     if (obj.style.display == "none") 
      {
        obj.style.display = "";
        pict.src = "http://www.nufrontiers.com/images/btn_close_map.gif";
      }
      else
      {
        obj.style.display = "none";
        pict.src = "http://www.nufrontiers.com/images/btn_expand_map.gif";
      }
    }

//-------------------------------search start page-------------------------------

function SubmitSearchForm() {  // Called from search page
  
     //--------------sububs---------------
     
    ARs = document.frmSearch.areas;
	temp = "";
	for (i=0;i<ARs.length;i++) {  // save area selected
	  if(ARs.options[i].value != '') {   //if area not [all areas]
		temp += ARs.options[i].value + ",";
		}
	}
	document.frmSearch.AR.value = temp.substr(0,temp.length-1); //get rid of last comma
	
	
	//---------------downtown, for suburban clients-------------
	
	//ARs_chi = document.frmSearch.areas_chi;
	//temp_chi = "";
	//for (i=0;i<ARs_chi.length;i++) {  // save area selected
	  //if(ARs_chi.options[i].value != '') {   //if area not [all areas]
		//temp_chi += ARs_chi.options[i].value + ",";
		//}
	//}
	//document.frmSearch.AR_chi.value = temp_chi.substr(0,temp_chi.length-1); //get rid of last comma
	
	//document.frmSearch.submit();
	//return false;
	
 }

function AddList() {
	SL = document.frmSearch.AreaList;
	ARs = document.frmSearch.areas;	
	if (SL.selectedIndex==-1) {
		alert('Please make a selection first');
		return false;
	}
	for (i=0;i<ARs.length;i++) {
	 if (ARs.options[i].value == SL.options[SL.selectedIndex].value) 
		return false;
	}	

	switch (ARs.length) {
	case 1:
	    if (ARs.options[0].text == "[All Areas]")
			ARs.options[0] = null;
		break;
	case 10:
		alert('Only five areas are allowed for this search');
		return false;
		break;
	}
	
	if (SL.selectedIndex ==0) {
		
		for(i=0;i<ARs.length;) {
			ARs.options[0] = null;  // eliminate all entries if "All Areas" is selected
		}
	}
	
	ARs.options[ARs.length] = new Option(SL.options[SL.selectedIndex].text,SL.options[SL.selectedIndex].value);
	return true;
}


function AddList_chi() {
	SL_chi = document.frmSearch.AreaList_chi;
	ARs_chi = document.frmSearch.areas_chi;	
	if (SL_chi.selectedIndex==-1) {
		alert('Please make a selection first');
		return false;
	}
	for (i=0;i<ARs_chi.length;i++) {
	 if (ARs_chi.options[i].value == SL_chi.options[SL_chi.selectedIndex].value) 
		return false;
	}	

	switch (ARs_chi.length) {
	case 1:
	    if (ARs_chi.options[0].text == "[All Areas]")
			ARs_chi.options[0] = null;
		break;
	case 10:
		alert('Only five areas are allowed for this search');
		return false;
		break;
	}
	
	if (SL_chi.selectedIndex ==0) {
		
		for(i=0;i<ARs_chi.length;) {
			ARs_chi.options[0] = null;  // eliminate all entries if "All Areas" is selected
		}
	}
	
	ARs_chi.options[ARs_chi.length] = new Option(SL_chi.options[SL_chi.selectedIndex].text,SL_chi.options[SL_chi.selectedIndex].value);
	return true;
}



function RemList() {
  ARs = document.frmSearch.areas;

if (ARs.length > 0 && ARs.selectedIndex != -1) // -1 indicates no selection
	ARs.options[ARs.selectedIndex] = null;
return true;
}

function RemList_chi() {
  ARs_chi = document.frmSearch.areas_chi;

if (ARs_chi.length > 0 && ARs_chi.selectedIndex != -1) // -1 indicates no selection
	ARs_chi.options[ARs_chi.selectedIndex] = null;
return true;
}


//-----------------------------end search start page------------------------------- 

   
//------------------------------mortgage calculator--------------------------------


function mortgage()
{
form = document.test
dnpmt=form.DownPayment.value
Price= form.Price.value
perc = (dnpmt/100) * Price
prin= Price-perc
tax=Math.floor(form.Taxes.value / 12)
assess=Math.floor(form.Assessment.value)
extra= tax+assess
intRate = (form.InterestRate.value/100) / 12
Term= form.Term.value * 12
MonthPayment=Math.floor((prin*intRate)/(1-Math.pow((1+intRate),(-1*Term)))*100)/100
form.Principle.value=MonthPayment
form.MonthlyTax.value=tax
form.MonthlyAssessment.value=assess
form.MonthlyPayment.value=MonthPayment + extra
}
function Calculate()
{
form = document.test
dnpmt=form.DownPayment.value
Price= form.Price.value
perc = (dnpmt/100) * Price
prin= Price-perc
tax=Math.floor(form.Taxes.value / 12)
assess=Math.floor(form.Assessment.value)
extra= tax+assess
intRate = (form.InterestRate.value/100) / 12
Term= form.Term.value * 12
MonthPayment=Math.floor((prin*intRate)/(1-Math.pow((1+intRate),(-1*Term)))*100)/100
form.Principle.value=MonthPayment
form.MonthlyTax.value=tax
form.MonthlyAssessment.value=assess
form.MonthlyPayment.value=MonthPayment + extra
}



//----------------------------morgage process page----------------------------

	function preload() 
	{    
		this.length = preload.arguments.length;
	    for (var i = 0; i < this.length; i++) 
	     {
	         this[i+1] = new Image();
	         this[i+1].src = preload.arguments[i];    
	     }
  }
  
  if (document.images)
    {
	 var imgs = new preload(
		 "http://avantgarde.myersinternet.com/images/process/process6-0text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-1on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-1off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-1text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-2on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-2off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-2text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-3on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-3off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-3text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-4on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-4off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-4text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-5on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-5off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-5text.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-6on.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-6off.gif",
		 "http://avantgarde.myersinternet.com/images/process/process6-6text.gif")
  }
  
  function swap(img,num)
    {
	if (document.images) 
	 {
	  var test = document.images[img].src;
 	  if (test.indexOf("off")!=-1)
 	    {
		  document.images[img].src = "http://avantgarde.myersinternet.com//images/process/process6-"+num+"on.gif";
		  document.images["text"].src = "http://avantgarde.myersinternet.com//images/process/process6-"+num+"text.gif";
	    }
	 else 
	    {
		document.images[img].src = "http://avantgarde.myersinternet.com//images/process/process6-"+num+"off.gif";
		document.images["text"].src = "http://avantgarde.myersinternet.com//images/process/process6-0text.gif";
	    }
	}
  }


//-----------------------swamp images on LN details pages-------------------------

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.01
  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 && d.getElementById) x=d.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];}
}



//===========================================================
//Script:   JavaScript Cross-Browser SlideShow Script
//          With Cross-Fade Effect between Images
//          Adjustable Timing and Unlimited Images
//Function: Displays images continuously in a slideshow
//          presentation format, with a fade effect on
//          image transitions.
//Browsers: All common browsers: NS3-6, IE 4-6
//          Fade effect only in IE; others degrade gracefully
//Author:   etLux
//===========================================================

// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below


Pic[0] = '/images/hm_1.gif';
Pic[1] = '/images/hm_2.gif';
Pic[2] = '/images/hm_3.gif';
Pic[3] = '/images/hm_4.gif';

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()

for (i = 0; i < p; i++)
{
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow()

{
  
  if (document.all)
  
   {
      
      document.getElementById("hm_img").style.filter="blendTrans(duration=2)"  
      document.getElementById("hm_img").style.filter="blendTrans(duration=crossFadeDuration)"
      document.getElementById("hm_img").filters.blendTrans.Apply()
   
   }
      
   document.getElementById("hm_img").style.height="175px";
   document.getElementById("hm_img").style.width="518px";
   document.getElementById("hm_img").style.backgroundRepeat='repeat-x';
   document.getElementById("hm_img").style.backgroundImage="url(" + preLoad[j].src + ")";
  
  if (document.all)
   {
     
       document.getElementById("hm_img").filters.blendTrans.Play()

   }
   
   j = j + 1
   
   if (j > (p-1)) j=0
   
   t = setTimeout('runSlideShow()', slideShowSpeed)
   
}



// --> 



