/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 Likes Architecture
 Sunday, October 11, 2009 12:27:29 PM
 HAPedit 3.1.11.111
 Written by Perry Mason
 - - - - - - - - - - - - - - - - - - - - - - - */

var xmlhttp
var submitted_type
var submitted_item_id

function like(type, item_id)
{
xmlhttp=GetXmlHttpObject();
submitted_type = type;
submitted_item_id = item_id;
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="index2.php?option=com_comprofiler&task=like";
//var url="components/com_comprofiler/like.php";
url=url+"&type="+type+"&item_id="+item_id+"&sid="+Math.random();
//url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function displayUpdatedLikeCount(type, item_id)
{
xmlhttp=GetXmlHttpObject();
submitted_type = type;
submitted_item_id = item_id;
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="index2.php?option=com_comprofiler&task=dislpayLikeCountLive";
//var url="components/com_comprofiler/like.php";
url=url+"&type="+type+"&item_id="+item_id+"&sid="+Math.random();
//url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChangedLikeCount;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChangedLikeCount()
{

if (xmlhttp.readyState==4)
  {
  //document.getElementById("link"+type+"_"+item_id).innerHTML=xmlhttp.responseText;
  //document.getElementById("link1_245").innerHTML=xmlhttp.responseText;
  document.getElementById("likeCount"+submitted_type+"_"+submitted_item_id).innerHTML=xmlhttp.responseText;
  }
}


function stateChanged()
{

if (xmlhttp.readyState==4)
  {
  //document.getElementById("link"+type+"_"+item_id).innerHTML=xmlhttp.responseText;
  //document.getElementById("link1_245").innerHTML=xmlhttp.responseText;
  document.getElementById("like"+submitted_type+"_"+submitted_item_id).innerHTML=xmlhttp.responseText;
  displayUpdatedLikeCount(submitted_type,submitted_item_id);
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

