//-- Ajax Updater --//
function ajaxReq(url, divName, pars, errMessage, callback, doctype, processingCount) {
  //html doctype declarations

  var array_doctype = ["HTML", "XHTML"];
  if(typeof processingCount=="undefined") processingCount = 0;
  /*
  //set to default XHTML
  if(array_doctype.indexOf(doctype) == -1 ){
  	doctype = "XHTML";
  }
  */
  $.ajax( {
				url :url,
				method :"POST",
				datatype :'html',
				data :pars,
				processData :false,
				cache :false,
				beforeSend : function(XMLHttpRequest) {
			        $("#frontbox").css('position','fixed');
			        $("#basebox").css('position','fixed');
			        if(processingCount == 0){
			        	$('#basebox').css('display', "block");
						$('#frontbox').css('display', "block");
						$('#innerbox').css('display', "block");
			        }
				},
				success : function(data) {
					data = data.replace(/th>\s+<th/g,'th><th');
					data = data.replace(/td>\s+<td/g,'td><td');

					$('#' + divName).html(data);

					$('#basebox').css('display', "none");
					$('#frontbox').css('display', "none");
					$('#innerbox').css('display', "none");
					if (callback) {
						callback();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$('#' + divName).html("A network error has occurred. We apologize for the inconvenience. Please<br/>return to the Renesas home page and try your search again(Ajax Error).");

					$('#basebox').css('display', "none");
					$('#frontbox').css('display', "none");
					$('#innerbox').css('display', "none");
				}
			});
}

$(document).ready(function() {
	data = null

	if ($("table.searchResultsTable").html() != null) {
		target = $("table.searchResultsTable");
		data = target.html();
	} else if ($("table.resultTable").html() != null) {
		target = $("table.resultTable");
		data = target.html();
	} else if ($("#equivDetails").html() != null) {
		target = $("#equivDetails");
		data = target.html();
	} else if ($("#ajax_document_result_content").html() != null) {
		target = $("#ajax_document_result_content");
		data = target.html();
	} else if ($("#toolResult").html() != null) {
		target = $("#toolResult");
		data = target.html();
	} else if ($("#ajax_main_content").html() != null) {
		target = $("#ajax_main_content");
		data = target.html();
	}

	if (data != null) {
		data = data.replace(/th>\s+<th/g,'th><th');
		data = data.replace(/td>\s+<td/g,'td><td');
		target.html(data);
	}
});
