var xmlHttp;
var t;
var imgHttp, imgPath;
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
// ------------------------------------------------------------
//send using GET
function goGetAJ(lnk)
{
  xmlHttp.open("GET",lnk,true);
  xmlHttp.send(null);
}

//send using POST
function goPostAJ(lnk)
{
  xmlHttp.open("POST",lnk,true);
  xmlHttp.send(null);
}
// ------------------------------------------------------------

//view select - use for viewing posts
function viewSelectAJ(catIndex)
{
	document.location.href='#TOP';
	xmlHttp = GetXmlHttpObject();
	xmlHttp.onreadystatechange=viewSelectAJOut;
	document.ngeek.viewpostURL.value =("ajviewpost.asp?catIndex=" + (catIndex+1) + "&nostart=1");
	goGetAJ("ajviewpost.asp?catIndex=" + (catIndex+1) + "&nostart=1");
}
function viewSelectAJOut()
{
  try{
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("ajDetails").innerHTML=xmlHttp.responseText;
	}
	else if((xmlHttp.readyState==2)||(xmlHttp.readyState==1)||(xmlHttp.readyState==3))
	{
		document.getElementById("ajDetails").innerHTML="<font class='font11'>" + xmlHttp.readyState + "<br><img src='http://www.webng.com/f1society/thefiles/loading.gif'><br> Click Hard Refresh if it takes too long.</font>";
	}
  }
  catch(err2)
  {
	//alert("Request interrupted. Retry action or click HARD REFRESH. (select out)");
	goThere(document.ngeek.viewpostURL.value);  
  }
	
}

function viewPostDetailsAJ(catIndex,postNo)
{
	document.location.href='#TOP';
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=viewSelectAJOut;
	document.ngeek.viewpostURL.value = ("ajviewpost.asp?catIndex=" + catIndex + "&postNo=" + postNo);
	goGetAJ("ajviewpost.asp?catIndex=" + catIndex + "&postNo=" + postNo);
}

function timeOnlineUsers()
{
 try{
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=timeOnlineUsersOut;
	goGetAJ("onlineuser.asp");
    }
 catch(err4){
     //alert("Request interrupted. Retry action or click HARD REFRESH. (online in)");
     return;
    }
}
function timeOnlineUsersOut()
{
 try{
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("onlineusers").innerHTML=xmlHttp.responseText;
		t=setTimeout("timeOnlineUsers()",120000);
	}
     }
  catch(err3){
      //alert("Request interrupted. Retry action or click HARD REFRESH. (online out)");
	return;
     }
}

function timeCOnline()
{
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=timeCOnlineOut;
	goGetAJ("conlineuser.asp");
}
function timeCOnlineOut()
{
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("chatOnline").innerHTML=xmlHttp.responseText;
		t=setTimeout("timeCOnline()",120000);
	}
}

// working with avatar
function loadImage(imgUrl)
{
	try{
 imgHttp=GetXmlHttpObject();
 imgPath=imgUrl;
 if ((imgPath.longDesc.substr(imgPath.longDesc.length-3,3)=="jpg") || (imgPath.longDesc.substr(imgPath.longDesc.length-3,3)=="png") || (imgPath.longDesc.substr(imgPath.longDesc.length-3,3)=="gif"))
{
 imgHttp.onreadystatechange=imageVerify;
 imgHttp.open("get",imgPath.longDesc,true);
 imgHttp.send(null);
}
else
{
 document.getElementById('h').src='http://www1.webng.com/f1society/thefiles/noavatar1.gif';
 return;
}
	}
	catch(err1)
	{
		document.getElementById('h').src=imgPath.longDesc;;
		}
}
function imageVerify()
{
  	if (imgHttp.readyState==4)
	{
	   if (imgHttp.status!=200)
	   { 
		  // if ((imgPath.width<160) && (imgPath.height<160))
		   	document.getElementById('h').src=imgPath.longDesc;
		  //else
		  //document.getElementById('h').src='thefiles/noavatar1.gif';
	   }
	   else
     	    document.getElementById('h').src='http://www1.webng.com/f1society/thefiles/noavatar1.gif';
	}
}

	//set cookie value passing the cookie name, value and expiredays
	function setCookie(c_name,value,expiredays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
		+";path=/";
	}

	//get cookie value passing the cookie name
	function getCookie(c_name)
	{
	  if (document.cookie.length>0)
	  {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
		  c_start=c_start + c_name.length+1; 
		  c_end=document.cookie.indexOf(";",c_start);
		  if (c_end==-1) c_end=document.cookie.length;
			  return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	  return "";
	}
	
	function ajClearSentChat()
	{
		document.frmChat.txtMessage.value = document.frmChat.txtTempMessage.value;
		document.frmChat.txtTempMessage.value = "";
		chatHttp=GetXmlHttpObject();
		setCookie("chatTimeOut","",1);
		goGetAJ("f1chatboard.asp?txtMessage=" + document.frmChat.txtMessage.value); 
		//document.frames['idChatRoom'].window.location.reload();
		return false;
	}	

imgHttp= GetXmlHttpObject();
xmlHttp = GetXmlHttpObject();




