function calculateDownPayment(ttl_price){
	// note ttl_price = $1,000,000,000 value
	//alert (ttl_price + ' of type: ' + typeof(ttl_price));
	
	// init the old string
	oldstring = ttl_price;
	
	// strip the string of $
	newstring = oldstring.replace("$","");
	
	// strip the string of ,
	newstring = newstring.replace(/,/g,"");
	
	// strip the string of any .
	newstring = newstring.replace(".","");
	
	// show the output
	//alert ("cleaned up: " + newstring + ' of type: ' + typeof(newstring));
	
	// parse it as an integer
	price_int = parseInt(newstring);
	
	// show the output
	//alert ("number? " + typeof(price_int));
	
	// calculate the downpayment
	downpayment = price_int - (price_int * .80);
	
	// show the output
	//alert ("total down: " + downpayment + " from the purchase price of: " + ttl_price);
	
	// update the input field
	document['jsmortcalc'].DownPayment.value = downpayment;
}


// modification for the vrein random listing code.
// IXF1.11 :: Image cross-fade 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
//******************************************************
//global object
var vrein_ixf = { 'clock' : null, 'count' : 1 }
/*******************************************************



/*****************************************************************************
 List the images that need to be cached
*****************************************************************************/

vrein_ixf.imgs = [
	'buttons/udm4-whitebutton88x31.gif',
	'buttons/udm4-greenbutton88x31.gif',
	'buttons/udm4-purplebutton88x31.gif'
	];

/*****************************************************************************
*****************************************************************************/



//cache the images
vrein_ixf.imgsLen = vrein_ixf.imgs.length;
vrein_ixf.cache = [];
for(var i=0; i<vrein_ixf.imgsLen; i++)
{
	vrein_ixf.cache[i] = new Image;
	vrein_ixf.cache[i].src = vrein_ixf.imgs[i];
}


//crossfade setup function
function crossfade_vrein()
{
	//if the timer is not already going
	if(vrein_ixf.clock == null)
	{
		//copy the image object 
		vrein_ixf.obj = arguments[0];
		
		//copy the image src argument 
		vrein_ixf.src = arguments[1];
		
		//store the supported form of opacity
		if(typeof vrein_ixf.obj.style.opacity != 'undefined')
		{
			vrein_ixf.type = 'w3c';
		}
		else if(typeof vrein_ixf.obj.style.MozOpacity != 'undefined')
		{
			vrein_ixf.type = 'moz';
		}
		else if(typeof vrein_ixf.obj.style.KhtmlOpacity != 'undefined')
		{
			vrein_ixf.type = 'khtml';
		}
		else if(typeof vrein_ixf.obj.filters == 'object')
		{
			//weed out win/ie5.0 by testing the length of the filters collection (where filters is an object with no data)
			//then weed out mac/ie5 by testing first the existence of the alpha object (to prevent errors in win/ie5.0)
			//then the returned value type, which should be a number, but in mac/ie5 is an empty string
			vrein_ixf.type = (vrein_ixf.obj.filters.length > 0 && typeof vrein_ixf.obj.filters.alpha == 'object' && typeof vrein_ixf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			vrein_ixf.type = 'none';
		}
		
		//change the image alt text if defined
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			vrein_ixf.obj.alt = arguments[3];
		}
		
		//if any kind of opacity is supported
		if(vrein_ixf.type != 'none')
		{
			//create a new image object and append it to body
			//detecting support for namespaced element creation, in case we're in the XML DOM
			vrein_ixf.newimg = document.getElementsByTagName('body')[0].appendChild((typeof document.createElementNS != 'undefined') ? document.createElementNS('http://www.w3.org/1999/xhtml', 'img') : document.createElement('img'));

			//set positioning classname
			vrein_ixf.newimg.className = 'idupe';
			
			//set src to new image src
			vrein_ixf.newimg.src = vrein_ixf.src

			//move it to superimpose original image
			vrein_ixf.newimg.style.left = vrein_ixf.getRealPosition(vrein_ixf.obj, 'x') + 'px';
			vrein_ixf.newimg.style.top = vrein_ixf.getRealPosition(vrein_ixf.obj, 'y') + 'px';
			
			//copy and convert fade duration argument 
			vrein_ixf.length = parseInt(arguments[2], 10) * 1000;
			
			//create fade resolution argument as 20 steps per transition
			vrein_ixf.resolution = parseInt(arguments[2], 10) * 20;
			
			//start the timer
			vrein_ixf.clock = setInterval('vrein_ixf.crossfade_vrein()', vrein_ixf.length/vrein_ixf.resolution);
		}
		
		//otherwise if opacity is not supported
		else
		{
			//just do the image swap
			vrein_ixf.obj.src = vrein_ixf.src;
		}
		
	}
};


//crossfade timer function
vrein_ixf.crossfade = function()
{
	//decrease the counter on a linear scale
	vrein_ixf.count -= (1 / vrein_ixf.resolution);
	
	//if the counter has reached the bottom
	if(vrein_ixf.count < (1 / vrein_ixf.resolution))
	{
		//clear the timer
		clearInterval(vrein_ixf.clock);
		vrein_ixf.clock = null;
		
		//reset the counter
		vrein_ixf.count = 1;
		
		//set the original image to the src of the new image
		vrein_ixf.obj.src = vrein_ixf.src;
	}
	
	//set new opacity value on both elements
	//using whatever method is supported
	switch(vrein_ixf.type)
	{
		case 'ie' :
			vrein_ixf.obj.filters.alpha.opacity = vrein_ixf.count * 100;
			vrein_ixf.newimg.filters.alpha.opacity = (1 - vrein_ixf.count) * 100;
			break;
			
		case 'khtml' :
			vrein_ixf.obj.style.KhtmlOpacity = vrein_ixf.count;
			vrein_ixf.newimg.style.KhtmlOpacity = (1 - vrein_ixf.count);
			break;
			
		case 'moz' : 
			//restrict max opacity to prevent a visual popping effect in firefox
			vrein_ixf.obj.style.MozOpacity = (vrein_ixf.count == 1 ? 0.9999999 : vrein_ixf.count);
			vrein_ixf.newimg.style.MozOpacity = (1 - vrein_ixf.count);
			break;
			
		default : 
			//restrict max opacity to prevent a visual popping effect in firefox
			vrein_ixf.obj.style.opacity = (vrein_ixf.count == 1 ? 0.9999999 : vrein_ixf.count);
			vrein_ixf.newimg.style.opacity = (1 - vrein_ixf.count);
	}
	
	//now that we've gone through one fade iteration 
	//we can show the image that's fading in
	vrein_ixf.newimg.style.visibility = 'visible';
	
	//keep new image in position with original image
	//in case text size changes mid transition or something
	vrein_ixf.newimg.style.left = vrein_ixf.getRealPosition(vrein_ixf.obj, 'x') + 'px';
	vrein_ixf.newimg.style.top = vrein_ixf.getRealPosition(vrein_ixf.obj, 'y') + 'px';
	
	//if the counter is at the top, which is just after the timer has finished
	if(vrein_ixf.count == 1)
	{
		//remove the duplicate image
		vrein_ixf.newimg.parentNode.removeChild(vrein_ixf.newimg);
	}
};



//get real position method
vrein_ixf.getRealPosition = function()
{
	this.pos = (arguments[1] == 'x') ? arguments[0].offsetLeft : arguments[0].offsetTop;
	this.tmp = arguments[0].offsetParent;
	while(this.tmp != null)
	{
		this.pos += (arguments[1] == 'x') ? this.tmp.offsetLeft : this.tmp.offsetTop;
		this.tmp = this.tmp.offsetParent;
	}
	
	return this.pos;
};
