
/**
 * Uses yt.sendRequest to display a list of of YT videos.
 */
listAmazon = function(queryType){
  var params = 'Keywords=' + queryType;
  var filePath = 'SimpleStore.php';
  
  sendRequest(filePath, params, "content-in");
}

login = function(user, pass){
  var params = 'user=' + user + '&pass=' + pass;
  var filePath = 'crea_user.php';
  
  sendRequest(filePath, params, "content-in");
}

/**
 * Sends an AJAX request to the specified filePath
 * on the same host, passing the specified params, and filling the specified
 * resultDivName with the results.
 * @param {String} filePath The path to which the request should be sent
 * @param {String} params The URL encoded POST params
 * @param {String} resultDivName The name of the DIV used to hold the results
 */
sendRequest = function(filePath, params, resultDivName) {
  if (window.XMLHttpRequest) {
    var xmlhr = new XMLHttpRequest();
  } else {
    var xmlhr = new ActiveXObject('MSXML2.XMLHTTP.3.0');
  }
        
  xmlhr.open('POST', filePath, true);
  xmlhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 

  xmlhr.onreadystatechange = function() {
    var resultDiv = document.getElementById(resultDivName);
    if (xmlhr.readyState == 1) {
		//document.getElementById("loading-img").style.display = "inline";
      //document.getElementById("search-in").innerHTML = document.getElementById("search-in").innerHTML + '<b>Loading...</b>'; 
    } else if (xmlhr.readyState == 4 && xmlhr.status == 200) {
      if (xmlhr.responseText) {
	  	//document.getElementById("loading-img").style.display = "none";
        resultDiv.innerHTML = xmlhr.responseText;
      }
    } else if (xmlhr.readyState == 4) {
      alert('Invalid response received - Status: ' + xmlhr.status);
    }
  }
  xmlhr.send(params);
}

