// JavaScript Document
/* ----- AJAX RELATED FUNCTIONS ----- */
function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http = createRequestObject();

function getNews() {
	http.open('get','includes/ajax_getNews.php?feed=' + document.newsForm.newsFeeds.value);
	http.onreadystatechange = handleNews;
	http.send(null);
}

function handleNews() {
	if(http.readyState != 4) {
		document.getElementById('newsCage').innerHTML = '<img src="images_global/activity.gif" align="absmiddle" />Loading News...';
	}
	else if(http.readyState == 4) {
		response = http.responseText;
		document.getElementById('newsCage').innerHTML = response;
	}
}

function getMortgageRates() {
	document.write('<table cellspacing="0" cellpadding="1" width="100%" border="0"><tr class="header-brm"><td colspan="3" valign="bottom"><b>Mortgage Rates</b></td><td align="center" valign="bottom">Today</td><td align="center" valign="bottom">+/-</td><td align="center" valign="bottom">Last Week</td></tr><tr><td valign="top" align="middle"><img src="http://www.bankrate.com/brm/images/brm_nd/bullet.gif" width="4" height="4" hspace="1" vspace="4"></td><td class="body-brm"><a href="http://www.bankrate.com/aff/subhome/mtg_m1.asp" target="_blank" class="body-brm-link">30 yr fixed mtg</a></td><td class="body-brm" align="left"><a href="http://www.bankrate.com/aff/graphs/graph_trend.asp?product=1&amp;prodtype=M&amp;ad=mtg" target="_blank"><img src="http://www.bankrate.com/brm/images/brm_nd/graph.gif" border="0" width="29" height="11" alt="Graph the three month trend"></a></td><td class="body-brm" align="center">5.81%</td><td class="body-brm" align="center"><img src="http://www.bankrate.com/brm/images/artwork/arrow_up_brm.gif" width="11" height="6" vspace="4"></td><td class="body-brm" align="center">5.76%</td></tr><tr class="body-brm"><td class="body-brm" valign="top" align="middle"><img src="http://www.bankrate.com/brm/images/brm_nd/bullet.gif" width="4" height="4" hspace="1" vspace="4"></td><td class="body-brm"><a href="http://www.bankrate.com/aff/subhome/mtg_m2.asp" target="_blank" class="body-brm-link">15 yr fixed mtg</a></td><td class="body-brm" align="left"><a href="http://www.bankrate.com/aff/graphs/graph_trend.asp?product=2&amp;prodtype=M&amp;ad=mtg" target="_blank"><img src="http://www.bankrate.com/brm/images/brm_nd/graph.gif" border="0" width="29" height="11" alt="Graph the three month trend"></a></td><td class="body-brm" align="center">5.42%</td><td class="body-brm" align="center"><img src="http://www.bankrate.com/brm/images/artwork/arrow_up_brm.gif" width="11" height="6" vspace="4"></td><td class="body-brm" align="center">5.35%</td></tr><tr><td valign="top" align="middle"><img src="http://www.bankrate.com/brm/images/brm_nd/bullet.gif" width="4" height="4" hspace="1" vspace="4"></td><td class="body-brm"><a href="http://www.bankrate.com/aff/subhome/mtg_m4.asp" target="_blank" class="body-brm-link">30 yr fixed jumbo mtg</a></td><td class="body-brm" align="left"><a href="http://www.bankrate.com/aff/graphs/graph_trend.asp?product=4&amp;prodtype=M&amp;ad=mtg" target="_blank"><img src="http://www.bankrate.com/brm/images/brm_nd/graph.gif" border="0" width="29" height="11" alt="Graph the three month trend"></a></td><td class="body-brm" align="center">6.07%</td><td class="body-brm" align="center"><img src="http://www.bankrate.com/brm/images/artwork/arrow_up_brm.gif" width="11" height="6" vspace="4"></td><td class="body-brm" align="center">6.00%</td></tr><tr><td class="body-brm" valign="top" align="middle"><img src="http://www.bankrate.com/brm/images/brm_nd/bullet.gif" width="4" height="4" hspace="1" vspace="4"></td><td class="body-brm"><a href="http://www.bankrate.com/aff/subhome/mtg_m6.asp" target="_blank" class="body-brm-link">5/1 ARM</a></td><td class="body-brm" align="left"><a href="http://www.bankrate.com/aff/graphs/graph_trend.asp?product=6&amp;prodtype=M&amp;ad=mtg" target="_blank"><img src="http://www.bankrate.com/brm/images/brm_nd/graph.gif" border="0" width="29" height="11" alt="Graph the three month trend"></a></td><td class="body-brm" align="center">5.37%</td><td align="center"><img src="http://www.bankrate.com/brm/images/artwork/arrow_up_brm.gif" width="11" height="6" vspace="4"></td><td class="body-brm" align="center">5.29%</td></tr></table>');
}

function getHomeEquityRates() {
	document.write('<table border="0" cellspacing="0" cellpadding="1" width="100%"><tr class="header-brm"><td colspan="3" valign="bottom"> Home Equity Rates</td><td align="center" valign="bottom">Today</td><td align="center" valign="bottom">+/-</td></tr><tr class="body-brm"><td valign="top" align="middle" width="4"><img src="http://www.bankrate.com/brm/images/brm_nd/bullet.gif" width="4" height="4" hspace="1" vspace="4"></td><td><a href="http://www.bankrate.com/aff/subhome/loan_L49.asp" target="_blank" class="body-brm-link">$30K home equity loan</a></td><td align="left"><a href="http://www.bankrate.com/aff/graphs/graph_trend.asp?product=49&amp;prodtype=L&amp;ad=loan" target="_blank"><img src="http://www.bankrate.com/brm/images/brm_nd/graph.gif" border="0" width="29" height="11" alt="Graph the three month trend"></a></td><td align="center">7.54%</td><td align="center"><img src="http://www.bankrate.com/brm/images/artwork/arrow_up_brm.gif" width="11" height="6" vspace="4"></td></tr></table>');
}

function getMortgageRateChart() {
	document.write('<table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td align="center"><a href="http://www.bankrate.com/aff/subhome/mtg_m1.asp" target="_blank"><IMG SRC="http://www.bankrate.com/brm/graphs/new_graph_draw_full.asp?web=brm&product=1&prodtype=M&mkt=ZZ&g2file=N&w_x=380&ad=mtg" border="0"></a></td></tr><tr class="header-brm"><td align="right"><a href="http://www.bankrate.com/aff/rate/mtg_home.asp" class="body-brm">More Info</a></td></tr></table>')
}