/**************************************************************************************************************/
// Create xmlhttp object based on browsertype
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();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
/**************************************************************************************************************/
// Define global variables to be used throughout
var tableBusy = false;
var tableBusyCommon = false;
var tableBusyPopular = false;
var tableHttp = getHTTPObject();
var tableHttpCommon = getHTTPObject();
var tableHttpBusyPopular = getHTTPObject();
var step1Over = false;
var row = "";
/**************************************************************************************************************/

function getPopularTagsList()
{
	document.getElementById('tagdisplay').innerHTML="<img id='imgProgress' src='images/ajax-loader.gif' alt='Progress'>";
	if (!tableBusy)
	{
		var url = "populartags.php?mode=getTagsList&settagview=list";
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkTagsListResponse;
		tableBusy = true;
		tableHttp.send(null);
	}
}
function checkTagsListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var htmlRecord = tableHttp.responseText;
				// Draw Record status and nav buttons
				document.getElementById('tagdisplay').innerHTML = htmlRecord;
				tableBusy = false;
			} // end try 
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function
function getPopularTagsCloudList()
{
	document.getElementById('tagdisplay').innerHTML="<img id='imgProgress' src='images/ajax-loader.gif' alt='Progress'>";
	if (!tableBusy)
	{
		var url = "populartags.php?mode=getPopularTagsCloudList&settagview=cloud";
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = getPopularTagsCloudListResponse;
		tableBusy = true;
		tableHttp.send(null);
	}
}
function getPopularTagsCloudListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var htmlRecord = tableHttp.responseText;
				// Draw Record status and nav buttons
				document.getElementById('tagdisplay').innerHTML = htmlRecord;				
				tableBusy = false;
			} // end try 
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function

function getLinkTagsCloudList(display_tag_limit)
{
	document.getElementById('tagclouddisplay').innerHTML="<img id='imgProgress' src='images/ajax-loader.gif' alt='Progress'>";
	if (!tableBusy)
	{
		var url = "populartags.php?mode=getLinkTagsCloudList&display_tag_limit="+display_tag_limit;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = getLinkTagsCloudListResponse;
		tableBusy = true;
		tableHttp.send(null);
	}
}
function getLinkTagsCloudListResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var htmlRecord = tableHttp.responseText;
				// Draw Record status and nav buttons
				document.getElementById('tagclouddisplay').innerHTML = htmlRecord;				
				tableBusy = false;
			} // end try 
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function