var XHR_STATE_UNSENT = 0;
var XHR_STATE_OPEN = 1;
var XHR_STATE_SENT = 2;
var XHR_STATE_LOADING = 3;
var XHR_STATE_DONE = 4;
  
function testResponse(xhr) {
  
  if (xhr != null) {
  	if (xhr.readyState != XHR_STATE_DONE) {
  		handleResponseError('');
  	} else if (xhr.status >= 400 
  		|| xhr.responseText == '' || xhr.status == 302) {
  		handleResponseError(xhr.getAllResponseHeaders());
  	}			
  }
}

// this function is called whenever an unrecognized response is returned from an XmlHttpRequest call
// currently all it does is break out of the productDesigner application and display an error page

// This should only be used as a last resort (deal with 500 Error, etc)

function handleResponseError(headers) {
	if (headers != '') 
		parent.document.location = '/sn/designer_error.jsp?headers=' + escape(headers);
	else
		parent.document.location = '/sn/designer_error.jsp';
}
