var xmlHTTP;
var strAjaxFile = "getAjaxData.inc.php?";
var strThrobberImg = '<img src="images/workingBlue.gif" />';
var strThrobberAdminImg = '<img src="../images/workingBlue.gif" />';

function fnCheckUsernameAvai(strUserNameObj,strTRId,resDivId,throbberDivId)
{
	var strUserName = strUserNameObj.value;
	
	if ((strUserName != "") && (strUserName.length >= 6) && fnIsStringDigitNoSpe(strUserName))
	{
		strArgs = "usn="+strUserName+"&act=chkUsrName&sesid="+Math.random();
		xmlHTTP = createXMLHttpObject();
		xmlHTTP.open("GET",strAjaxFile+strArgs,true);
		xmlHTTP.onreadystatechange=function() 
		{
			if (xmlHTTP.readyState==4)
			{
				if (xmlHTTP.status == 200)
				{
					var strString = xmlHTTP.responseText;
					if (strString != "0")
					{
						document.getElementById(strTRId).style.display = '';
						document.getElementById(resDivId).innerHTML = xmlHTTP.responseText;
					}						
				}
				else
				{
					alert('Error:AJAX request status = ' + xmlHTTP.status);
				}
		    }
		    else
		    {
		    	document.getElementById(throbberDivId).innerHTML = strThrobberImg;
		    }
		}
		xmlHTTP.send("");
	}
	else
	{
		document.getElementById(strTRId).style.display = 'none';
		alert ('Username should be 6-15 letters or numbers, no spaces or special characters');
		strUserNameObj.focus();
		return false;
	}	
}

function fnViewEvents(strSearchDate,strTRId,resDivId,throbberDivId)
{
	if ((strSearchDate != "") && (strSearchDate.length == 10))
	{
		strArgs = "sd="+strSearchDate+"&act=chkViewEvents&sesid="+Math.random();
		xmlHTTP = createXMLHttpObject();
		xmlHTTP.open("GET",strAjaxFile+strArgs,true);
		xmlHTTP.onreadystatechange=function() 
		{
			if (xmlHTTP.readyState==4)
			{
				if (xmlHTTP.status == 200)
				{
					var strString = xmlHTTP.responseText;
					if (strString != "0")
					{
						document.getElementById(strTRId).style.display = '';
						document.getElementById(resDivId).innerHTML = xmlHTTP.responseText;
					}						
				}
				else
				{
					alert('Error:AJAX request status = ' + xmlHTTP.status);
				}
		    }
		    else
		    {
		    	document.getElementById(throbberDivId).innerHTML = strThrobberImg;
		    }
		}
		xmlHTTP.send("");
	}
	else
	{
		document.getElementById(strTRId).style.display = 'none';
		alert ('Invalid date, no events found for the this date');
		return false;
	}	
}

function fnSetBlogComActInAct(intMemBlogId,resDivId,throbberDivId)
{
	if ((intMemBlogId > 0))
	{
		strArgs = "mbid="+intMemBlogId+"&act=setBlgComAIA&sesid="+Math.random();
		xmlHTTP = createXMLHttpObject();
		xmlHTTP.open("GET",strAjaxFile+strArgs,true);
		xmlHTTP.onreadystatechange=function() 
		{
			if (xmlHTTP.readyState==4)
			{
				if (xmlHTTP.status == 200)
				{
					var strString = xmlHTTP.responseText;
					if (strString != "0")
					{
						alert(xmlHTTP.responseText);
					}						
				}
				else
				{
					alert('Error:AJAX request status = ' + xmlHTTP.status);
				}
		    }
		    else
		    {
		    	//document.getElementById(throbberDivId).innerHTML = strThrobberImg;
		    }
		}
		xmlHTTP.send("");
	}
	else
	{
		document.getElementById(strTRId).style.display = 'none';
		alert ('Invalid date, no events found for the this date');
		return false;
	}	
}

function fnSetVideoView(intVideoId)
{
	if ((intVideoId > 0))
	{ 
		strArgs = "vid="+intVideoId+"&act=setVidView&sesid="+Math.random();
		xmlHTTP = createXMLHttpObject();
		xmlHTTP.open("GET",strAjaxFile+strArgs,true);
		xmlHTTP.onreadystatechange=function() 
		{
			if (xmlHTTP.readyState==4)
			{
				if (xmlHTTP.status == 200)
				{
					var strString = xmlHTTP.responseText;
					if (strString != "0")
					{
						//alert(xmlHTTP.responseText);
					}						
				}
				else
				{
					alert('Error:AJAX request status = ' + xmlHTTP.status);
				}
		    }
		}
		xmlHTTP.send("");
	}
	else
	{
		return false;
	}	
}