function hidemsgdiv() {
	// hides the messaging div
	document.getElementById('msgdiv').innerHTML="";
	document.getElementById('msgdiv').style.display="none";
	document.getElementById('msgdiv').style.visibility="hidden";
}

function setAJAX(theID,theTask,theTR) {
	
		var xmlHttp;
		var url;
		
		switch (theTask) {
			case 'nav':
				// update cart nav
				url = "cart_nav_update_ajax.php";
				break;
			case 'delete':
				// delete not ajax
				break;
			case 'add':
				// add
				url = "cart_add_ajax.php";
				break;
		}
	
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  xmlHttp.overrideMimeType('text/html');
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
			  alert("Your browser does not support AJAX!");
			  return false;
			  }
			}
		  }
			
		  xmlHttp.onreadystatechange=function()
			{
			if(xmlHttp.readyState==4)
			{
			  if (xmlHttp.status == 200) 
			  {
			  	
			  	switch (theTask) {
					case 'nav':
						document.getElementById('cartspan').style.display="inline";
						document.getElementById('cartspan').style.visibility="visible";
						document.getElementById('cartspan').innerHTML="<a href='checkout.php'>cart</a>&nbsp;&nbsp;";
						colorFade('msgdiv','background','EEFF66','000000',25,50);
						break;
					case 'delete':
						// not ajax
						break;
					case 'add':
						document.getElementById('msgdiv').style.display="block";
						document.getElementById('msgdiv').style.visibility="visible";
						document.getElementById('msgdiv').innerHTML=xmlHttp.responseText;
						colorFade('msgdiv','background','EEFF66','000000',25,50);
						setAJAX('','nav','');
						window.setTimeout('hidemsgdiv();',6000);
						break;
				}
				
			  }
			  else
			  {
			   alert('There was a problem with the request.');
			   alert(xmlHttp.responseText);
			 
			  }
			}
			}
				
		  // set postparams according to task
		  switch (theTask) {
				case 'nav':
					var postparams = "nav=nav";
					break;
				case 'delete':
					// not ajax
					break;
				case 'add':
					// loop the form and set post params
					var postparams = "edid=" + theTR + "";
					var theform = document.getElementById('ticketform');
					var thecount = 0;
					for(x=0;x<theform.elements.length;x++)
					{
						if (theform.elements[x].name != "btn") {
							postparams += "&" + theform.elements[x].name + "=" + theform.elements[x].value + "";
							thecount ++;
						}
					}
					break;
			}
		  		 	
		  xmlHttp.open('POST', url, true);
			
		  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		  xmlHttp.setRequestHeader("Content-length", postparams.length);
		  xmlHttp.setRequestHeader("Connection", "close");
		  xmlHttp.send(postparams);
	
	} 

