//-------------------------------------------------------------------------------------------------------------------------
// TOOLS REPLACEMENT - REQUESTS CF PAGE, STRIPS OUT META HEADER IF PRESENT, EVALS JS, CONTINUES TO FORMER UNCHANGED CODE
//-------------------------------------------------------------------------------------------------------------------------

var scripts = document.getElementsByTagName("script");
var scriptSrc = scripts[scripts.length - 1].src;
var phone = scriptSrc.split("phone=")[1];

var request = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
request.open("GET", "/js/phones_overview.cfm?phone=" + phone, false);
request.send(null);

var xmlSource = request.responseText;
xmlSource = request.responseText.split("<META NAME=\"ColdFusionMXEdition\" CONTENT=\"ColdFusion DevNet Edition - Not for Production Use.\">").join("");

eval(xmlSource);

//-------------------------------------------------------------------------------------------------------------------------

tData_StrContent = '';

//Verify we have a data array object
if (typeof tData_models != 'undefined') {
	
	//Check to see if we have an empty array
	if (tData_models.length > 0) {
		//We have a list so we loop through it
		for (n=0;n < tData_models.length;n++) {
			//Check to see if first element in list, if not decide if we need a comma or an AND
			if (n) tData_StrContent += (n == tData_models.length-1) ? ' and ': ', ';
			//Assign carrier name
			tData_StrContent += tData_models[n];
		}
			//Add link to Where to buy section (unless your the 1100 series)
		if (tData_seriesName != '1100') {
			tData_StrContent += '<div class="smallprint" style="margin-top:7px;"><a href="where-to-buy.htm">More Service Provider Info</a> <img src="/image/phones/showcase-arrow-red.gif" class="inline" /></div>';
		}
	} else {
	
		//We have an empyt list, no service providers. So we explain that...
		if (tData_seriesStatus == 'A') {
			//Phone is currently Active with no US service providers
			tData_StrContent = '<i>At this time, there are currently no U.S. service providers offering this phone.</i>';
		} else {
			//Phone is no longer Active (its a classic, not available for purchase)
			tData_StrContent = '<i>The Kyocera ' + tData_seriesName + ' Series is no longer available for purchase. If you own a Kyocera ' + tData_seriesName + ' Series cell phone, Kyocera will continue to provide information and support for this cell phone.</i>';
		}
		
	}

} else {

	//Data verification failed, display error message
	tData_StrContent = '<i>This information is temporarily unavailable.</i>';
}

//write final content
document.write(tData_StrContent);
