function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}


function ajaxActions() {
  var xmlhttp;
  
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
  xmlhttp.onreadystatechange = function()
  {
    var xmlTag, actionName, actionData;
    if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("ACTION");
	if ( x.length ) {
		xmlTag = x[0].getElementsByTagName("NAME");
		try
		{
		  actionName = xmlTag[0].firstChild.nodeValue;
		} catch (er) {
		}
		
		xmlTag = x[0].getElementsByTagName("DATA");
		try
		{
		  actionData = xmlTag[0].firstChild.nodeValue;
		} catch (er) {
		}
		if ( actionName == "HELLOWORLD" ) {
		  alert(actionData);
		} else if ( actionName == "REDIRECT" ) {
		  window.location = actionData;
		} else if ( actionName == "REFRESH" ) {
		  location.reload(true);
		}
	}
    }
  }
  
  if ( typeof shopcartid != 'undefined' ) {
    xmlhttp.open("GET", "/ajaxactions.php?cartid="+escape(shopcartid), true);
  } else {
    xmlhttp.open("GET", "/ajaxactions.php", true);
  }
  xmlhttp.send();
  
  ajaxActionsTimer();

}

function ajaxActionsTimer() {
  setTimeout("ajaxActions()", 3000);
}

addEvent(window, 'load', ajaxActionsTimer);
