var xmlHttp
var xmlHttp2
var which
function getlatest(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
which = 1;  
/*var url="getlatestnews.asp";
url=url+"?type="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function() {

 		if (xmlHttp.readyState==4) {
			document.getElementById("qw").innerHTML=xmlHttp.responseText;
			var stripoutput = xmlHttp.responseText.replace("($","");
			if (stripoutput != "Enter a valid code. -"){
				document.checkoutform.promocodecost.value= stripoutput.replace(")","");
			}	
		}

 	};
xmlHttp.open("GET",url,true);
xmlHttp.send(null);*/

xmlHttp2=GetXmlHttpObject();
xmlHttp2.onreadystatechange=function() {

 		if (xmlHttp2.readyState==4) {

			var xmldata= xmlHttp2.responseXML;
			//alert("hello");
			if(xmldata==null || xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
				document.getElementById("blog-block").innerHTML="<b>Error</b> fetching remote RSS feed!<br />";
				return;
			}

			feeditems=xmldata.getElementsByTagName("item");
			var innerhtm = ""; 

			//Cycle through RSS XML object and store each peice of the item element as an attribute of the element
			//feeditems.length
			
			var hash = {
				"Jan":"January",
				"Feb":"February",
				"Mar":"March",
				"Apr":"April",
				"May":"May",
				"Jun":"June",
				"Jul":"July",
				"Aug":"August",
				"Sep":"September",
				"Oct":"October",
				"Nov":"November",
				"Dec":"December"
			}
			
			for (var i=0; i<1; i++){
				var nice_time = feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue.split(" ");
				nice_time = hash[nice_time[2]] + " " + nice_time[1] + ", " + nice_time[3];
				innerhtm += "<p class='tilesbold'><strong>"+feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue+"</strong></p>";
				innerhtm += "<p class='author-line'>" +  nice_time + "</p>";
				//try {
//					innerhtm += "<p class='author-line'>by " + feeditems[i].getElementsByTagName("dc:creator")[0].firstChild.nodeValue + ",&nbsp;" + nice_time + "</p>";
//				} catch (e) {
//					innerhtm += "<p class='author-line'>by " + feeditems[i].getElementsByTagName("creator")[0].firstChild.nodeValue + ",&nbsp;" + nice_time + "</p>";
//				}
				content = feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue;
				innerhtm += "<p class='post-content'>" + content.substr(0,201)+ " ...</p>";
				
				innerhtm += '<p>(<a href="'+feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue+'">Click here to read the full post</a>)';
				innerhtm += "<a class='rss-link' style='float: right;' href=\"http://revenuecycleinc.com/blog/?feed=rss2&amp;p=3\">RSS Feed</a></p><br />";
			}
			document.getElementById("blog-block").innerHTML = innerhtm;
		}

 	};

var url2="/blog/?feed=rss2";
which=2;
xmlHttp2.open("GET",url2,true);
xmlHttp2.send(null);
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}