var ns = (document.layers) ? 1:0

var ns6 = (window.innerHeight && !document.layers) ? 1:0
var ie = (document.getElementById && !window.innerHeight) ? 1:0;
var mz = (document.getElementById && window.innerHeight) ? 1:0;
var op = (mz && !document.getElementsByTagNameNS) ? 1:0;


var mac = (navigator.platform.indexOf('Mac') > -1) ? 1:0
var ispc = (!mac) ? 1:0


// flag ajax support
var ajax = ((ie && !mac) || mz || op) ? 1:0;

// begin generic ajax communication module
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} 
		catch (e) {
			xmlhttp = false;
		}
	}
  return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object
// end ajax module





// customize for each use
function handleHttpResponse() {
  if (http.readyState == 4) {  // meaning the request is complete
    var response = http.responseText;
   
    if (response.indexOf('invalid') == -1) {
		if (response.indexOf("?xml") != -1) {
			
			if (http.responseXML) {	// did we get a valid xml document?	
				var xmlDocument = http.responseXML; 
			
				if (xmlDocument) {	
				//do nothing
				//formatResults(xmlDocument);			
				}
			}
		}	
		else {
			// Split the comma delimited response into an array
			results = http.responseText.split(",");		
		}
	}
	
	// no matter what the outcome, we stop working
	loading = false;   
  }
}




// customize for each use
function acknowledgeHttpResponse() {
  if (http.readyState == 4) {  // meaning the request is complete
    var response = http.responseText;
	if (response!=null)
		// this is the confirmation text
		updateBanner(response);
	
	// no matter what the outcome, we stop working
	sending = false;   
  }
}

// customize for each use
function acknowledgeTagResponse() {
  if (http.readyState == 4) {  // meaning the request is complete
    var response = http.responseText;
	if (response!=null)
		// this is the confirmation text
		updateTagList(response);
	
	// no matter what the outcome, we stop working
	sending = false;   
  }
}

// customize for each use
function acknowledgeRatingResponse() {
  if (http.readyState == 4) {  // meaning the request is complete
    var response = http.responseText;
	if (response!=null)
		// this is the confirmation text
		closeRating();
	
	// no matter what the outcome, we stop working
	sending = false;   
  }
}


// customize for each use
function acknowledgeThemeResponse() {
  if (http.readyState == 4) {  // meaning the request is complete
    var response = http.responseText;
	if (response!=null)
		// this is the confirmation text
		processTheme(response);
	
	// no matter what the outcome, we stop working
	sending = false;   
  }
}



sending = false;
function updateSwatch(isbn,swatch) {
	
	sendurl = "http://www.servicedesignbooks.org/includes/updateswatch.php?";
	
	if (!sending && http) {
		if (ajax) {
			now = new Date();
			min = now.getMinutes();
			sec = now.getSeconds();
			cache = ""+min+sec;
		
			http.open("GET", sendurl + "isbn="+isbn+"&swatch=" + swatch + "&cache=" + escape(cache), true);
			
			http.onreadystatechange = acknowledgeHttpResponse;
			sending = true;
			http.send(null);
		}
	}
	
	// keep trying until the channel is open
	else if (http) {
		setTimeout("updateSwatch('"+isbn+"', '"+swatch+"')",3000);
	}

}





sending = false;
function updateTag(isbn,tags,id) {
	
	sendurl = "http://www.servicedesignbooks.org/includes/updatetag.php?";
	
	if (!sending && http) {
		if (ajax) {
			now = new Date();
			min = now.getMinutes();
			sec = now.getSeconds();
			cache = ""+min+sec;
		
			http.open("GET", sendurl + "isbn="+isbn+"&tags=" + tags + "&id=" + id + "&cache=" + escape(cache), true);
			
			http.onreadystatechange = acknowledgeTagResponse;
			sending = true;
			http.send(null);
		}
	}
	
	// keep trying until the channel is open
	else if (http) {
		setTimeout("updateTag('"+isbn+"', '"+tags+"', '"+id+"')",3000);
	}

}


sending = false;
function updateRating(isbn,rating,id) {
	
	sendurl = "http://www.servicedesignbooks.org/includes/updaterating.php?";
	
	if (!sending && http) {
		if (ajax) {
			now = new Date();
			min = now.getMinutes();
			sec = now.getSeconds();
			cache = ""+min+sec;
		
			http.open("GET", sendurl + "isbn="+isbn+"&rating=" + rating +"&id=" + id + "&cache=" + escape(cache), true);
			
			http.onreadystatechange = acknowledgeRatingResponse;
			sending = true;
			http.send(null);
		}
	}
	
	// keep trying until the channel is open
	else if (http) {
		setTimeout("updateRating('"+isbn+"', '"+rating+"', '"+id+"')",3000);
	}

}




sending = false;
function updateTheme(isbn,theme,id) {
	sendurl = "http://www.servicedesignbooks.org/includes/updatetheme.php?";
	
	if (!sending && http) {
		if (ajax) {
			now = new Date();
			min = now.getMinutes();
			sec = now.getSeconds();
			cache = ""+min+sec;
		
			http.open("GET", sendurl + "isbn="+isbn+"&theme=" + theme +"&id=" + id + "&cache=" + escape(cache), true);
			
			http.onreadystatechange = acknowledgeThemeResponse;
			sending = true;
			http.send(null);
		}
	}
	
	// keep trying until the channel is open
	else if (http) {
		setTimeout("updateTheme('"+isbn+"', '"+theme+"', '"+id+"')",3000);
	}

}







