var img = new Image();
img.src = "images/loading.gif";
var tempcontentid;
var ajaxObjects = new Array();
function fnVoteForComment(userid,type,typeid,commentid,voteans)
{
	if(userid ==0 || userid=="")
	{
		chkLogin = 1;
	}
	else
	{
		chkLogin = 0;		
	}
	
	//fnAjaxCaller("", "setunsetsessionvars", "setsessionparams", "&settoparams=forcommentvoting&&type="+type+"&typeid="+typeid+"&commentid="+commentid+"&voteans="+voteans+"&login="+chkLogin,"","");
	//setTimeout("",1000);
	
			var ajaxIndex = ajaxObjects.length;	
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forcommentvoting&&type="+type+"&typeid="+typeid+"&commentid="+commentid+"&voteans="+voteans+"&login="+chkLogin;
			ajaxObjects[ajaxIndex].onCompletion = function(){
																if(userid ==0 || userid=="")
																{
																	//Lightbox.showBoxByID('divRegisterLogin', 550,345);
																	Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
																	return false;
																}
																else
																{
																	var url;
																	fnVoteAjaxCaller("id_votetd_"+commentid, "mediacommentvote","");
																	return true;
																}
															};	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();
	
	
}

function fnVoteAjaxCaller(contentid, action,params)
{
	  tempcontentid = contentid;
	  
	  var d = new Date();
	  var time = d.getTime();
	  
	  var url = sitename+'/index.php?action='+ action + params +'&'+time ;
	   
	  var myAjax = new Ajax.Request(url,
	  {
		method:'get',
		onLoading: fnVoteAjaxRequestInProgress,
		onSuccess: fnVoteProcessAjaxResponse,
		onFailure: fnVoteAjaxRequestError		
	  });	
 	
}

function fnVoteProcessAjaxResponse(transport)
{
	 var response = transport.responseText;
	
	 if(response == false || response == "") response = "Data not available..";

	 document.getElementById(tempcontentid).style.display = "";
	 document.getElementById(tempcontentid).innerHTML =  response;
}

function fnVoteAjaxRequestInProgress()
{
	document.getElementById(tempcontentid).style.display = "";
	document.getElementById(tempcontentid).innerHTML = "<img src='images/loading.gif' />";
	
}

function fnVoteAjaxRequestError()
{
	document.getElementById(tempcontentid).style.display = "";
	document.getElementById(tempcontentid).innerHTML = "Error !!!!! ";
}
