// JavaScript Document
var testString;
var url;

function handleHttpResponse1() {
  if (http.readyState == 4) {
    // Split the comma delimited response into an array
    //results = http.responseText.split("`");
	//alert(results[0]);\
	testString=http.responseText;
 	if (testString.length > 10) {
		insertProductTable();
		document.getElementById('loading').style.display="none";
	} else {
		document.getElementById('loading').style.display="none";
		document.getElementById('notFound').style.display="block";
	}
  }
}

function getProducts() {
	//var url = "http://trackcred.com/classyMommy/indexTest4.php?style=crunchy&color=multi";
	writeBreadcrumb();
	document.getElementById('title').value="";
	document.getElementById('loading').style.display="block";
	document.getElementById('notFound').style.display="none";
	constructURL();
	http.open("POST", url , true);
	http.onreadystatechange = handleHttpResponse1;	
	http.send(null);
	url=null;
}

function findProducts() {
	document.getElementById('priceRangeSelector').options[0].selected = true;
	document.getElementById('productTypeSelector').options[0].selected = true;
	document.getElementById('forPersonSelector').options[0].selected = true;
	document.getElementById('colorSelector').options[0].selected = true;
	document.getElementById('styleSelector').options[0].selected = true;
	document.getElementById('loading').style.display="block";
	document.getElementById('notFound').style.display="none";
	constructSearchURL();
	fakeURLSearchTerm=document.getElementById('title').value;
	pageTracker._trackEvent('UI_Elements', 'Search', fakeURLSearchTerm);
	http.open("POST", url , true);
	http.onreadystatechange = handleHttpResponse1;	
	http.send(null);
	url=null;
}

function updateCityState() {
  var zipValue = document.getElementById("zip").value;
  http.open("GET", url + escape(zipValue), true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
 }


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;

}

var http = getHTTPObject(); // We create the HTTP Object