
function getInternalHtml(uri, divId,activeTab, postLoad){

	if (uri.indexOf("?") >= 0){
		uri = uri + "&cacheBuster="+ Math.random();
	}else{
		uri = uri + "?cacheBuster="+ Math.random();
	}

	new Ajax.Request('/DealerPortal3/'+uri,
		{
    	method:'get',
    	onSuccess: function(transport){
      		var response = transport.responseText || "";
      		loadHtml(response, divId,activeTab, postLoad);
    	},
    	onFailure: function(response, divId){ htmlError(response, divId, postLoad); }
  	});
}

function loadHtml(response, divId, activeTab,postLoad){
	var news_items = document.getElementById(divId); 
	news_items.innerHTML = response;
	var anchors=document.getElementById(divId).getElementsByTagName('a');
	for (var i=0;i < anchors.length; i++)
	 {
	      var hrefVal=anchors[i].getAttribute('href');
	      anchors[i].setAttribute('href',hrefVal+'?activeTab='+activeTab);
	 }
	//run any post functions that have been supplied
	eval(postLoad);
}

function htmlError(response, divId, postLoad){
	//if we can not get the service messages try again after 30 seconds
	setTimeout(function(response, divId, postLoad){
		getInternalHtml(response, divId, postLoad);}, "30000");
}

function getIndustryNews(uri, divId,activeTab, postLoad){
	if (uri.indexOf("?") >= 0){
		uri = uri + "&cacheBuster="+ Math.random();
	}else{
		uri = uri + "?cacheBuster="+ Math.random();
	}

	new Ajax.Request('/DealerPortal3/'+uri,
		{
    	method:'get',
    	onSuccess: function(transport){
      		var response = transport.responseText || "";
      		loadIndustryHtml(response, divId,activeTab, postLoad);
    	},
    	onFailure: function(response, divId){ htmlError(response, divId, postLoad); }
  	});
}

function loadIndustryHtml(response, divId, activeTab,postLoad){
	var news_items = document.getElementById(divId); 
	news_items.innerHTML = response;
}