function getDealerId()
{
	var x = document.location.hostname;
	var sp = x.split(".");
	return sp[0];
}
//	alert(getDealerId());
//	alert('boing');

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function setBroughtToYouBy()
{
  var CoName = "";
	
	var nameEQ = "DealerName" + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		//alert (c)
		if (c.indexOf(nameEQ) == 0) 
		  CoName = c.substring(nameEQ.length,c.length);
	}
	CoName = decodeURIComponent(CoName);
	CoName = CoName.replace(/\+/g, " ");
	//CoName.replace(/T/g, "hmm");

  //alert(CoName)

  if (CoName != "") {
	  document.getElementById('BroughtToYouBy').innerHTML = "Brought to you by " + CoName;
	} else {
		document.getElementById('BroughtToYouBy').innerHTML = '&nbsp';
	}
}


function getDealerXML(dId)
{
	var req= getHTTPObject();//new XMLHttpRequest();
	req.open("GET", "/reseller/" + dId + ".html", true);
	req.onreadystatechange = 
	  function() {
	  	if (req.readyState == 4 && req.status == 200) {
	  		if (req.responseText) {
	  			setBroughtToYouBy(req.responseText);
	  		}
	  	}
	  };
	req.send("");
}


function updateBroughtToYouBy() {
  getDealerXML(getDealerId());
}

