// JavaScript Document
$(document).ready(function() {
	
	
	
	
	$('#overlayAJAX').jqm({trigger: 'a.overlayAJAX'});  
	$('.overlayAJAX').click(function() {
		doAJAXoverlay($(this).attr("id"));
		return false;
	  });
  
});




var http = getHTTPObject(); // We create the HTTP Object

function getHTTPObject() {
  var xmlhttp;
  if (typeof XMLHttpRequest == 'undefined') {
  	XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
  }
  
  
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
	  xmlhttp = new XMLHttpRequest();
	} catch (e) {
	  xmlhttp = false;
	}
  }
  return xmlhttp;
}

function doAJAXoverlay(Content) {
  clearAJAXoverlay();
  http.open("GET", "gammacart-ajax.php?Content=" + escape(Content) + "&cache=" + Math.random(), true);
  http.onreadystatechange = handleAJAXResponse;
  http.send(null);
}

function handleAJAXResponse() {
  if (http.readyState == 4) {
	document.getElementById('AJAXcart').src = http.responseText;
	//document.getElementById('overlayAJAXTxt').innerHTML = http.responseText;
  }
}

function clearAJAXoverlay() {
	//document.getElementById('overlayAJAXTxt').innerHTML = '<div style="padding:20px; background:#FFFFFF;text-align:center;font-size:18px;font-weight:bold;"><img src="http://www.gammacart.com/images/ajax-loader.gif" align="middle" /> &nbsp;&nbsp; LOADING...</div></div></div>';
	//document.getElementById('AJAXcart').src = 'loading.html';
}
