var timerID = null
var timerRunning = false
var timerID2 = null
var timerRunning2 = false

var time_tag_2 = '<font face="Verdana" style="font-size: 8pt" color="#66FF33"><b>T_M</b></font>'; 
var to_v_2 = '<b><font face="Verdana" color="#000000" size="1">TOT_V</font></b>'; //document.getElementById("tot_vote").innerHTML;
var to_p_2 = '<b><font face="Verdana" color="#FFFFFF" size="1">TOT_P</font></b>';//document.getElementById("tot_post").innerHTML;
var to_pageviews_2 = '<b><font face="Verdana" color="#FFFFFF" size="1">VIEWS_TOT</font></b>';//document.getElementById("tot_visitors").innerHTML;

var delay = 1000


function InitializeTimer()
{
   StartTheTimer();
   StartTheTimer2();
	showHint();
}
function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    timerRunning = true;
    timerID = self.setTimeout("StartTheTimer()", delay);
    	
}

function StartTheTimer2()
{
       timerRunning2 = true;
       timerID2 = self.setTimeout("StartTheTimer2()", 60000);
	   showHint();
}
function showHint()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  		alert ("Browser does not support HTTP Request")
  		return
  	} 
	
	var url=len + "scripts/timer.php?rp=yes"
	//alert(url);
	url=url +"?sid="+ Math.random();
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 

		var rep_ly = xmlHttp.responseText;

		//******************************************
		var rep_arr = rep_ly.split("*H*"); 
		
		//******for total post**************
		var to1_p = to_p_2.replace("TOT_P",rep_arr[1]);
		//******for total post**************

		//******for total pageview count***********
		var  kk = parseInt(rep_arr[2]);
		//******for total pageview count**************

		//******for total pageview count**************
		var to1_pgviews = to_pageviews_2.replace("VIEWS_TOT",kk);
		//******for total pageview count**************
		
		//******for time**************
		var	rep = time_tag_2.replace("T_M",rep_arr[0]);
		//******for time**************

		document.getElementById("txtHint").innerHTML= rep;
		document.getElementById("tot_post").innerHTML = to1_p;
		document.getElementById("tot_visitors").innerHTML = to1_pgviews;
		//********************************************
		
	 	//********************most recent comment
		if(recent_post == "yes")
		{
			var temp_comment = rep_ly;
			var temp_comment_arr = temp_comment.split("*ST-COMT*"); 
			
			var total_row= temp_comment_arr[1];
			
			if(temp_comment_arr[1] == "hide_table")
			{
				document.getElementById("hide_table").style.display ="none";			
			}
			else
			{
				
				var b=1;
				var dy_temp_table='';
				for(var k=1; k<=total_row; k++)
				{
					var b_temp =b%2;
					if(b_temp != 0)
					{
						var tbl1=comment_arr["table1"];
						var temp_table =tbl1;
					}
					else
					{
						var tbl2=comment_arr["table2"];
						var temp_table =tbl2;
					}
					
					var recent_comm = temp_comment_arr[k+1];
					var comment_var_arr = recent_comm.split("*//*"); 

					//****************total comment************
					var var_comm1 = comment_var_arr[0];
					var tot_comm_arr = var_comm1.split("-->"); 
					var tot_comm_id = tot_comm_arr[0];
					var tot_comm_val = tot_comm_arr[1];
					var image_name = tot_comm_arr[2];
					var main_link = tot_comm_arr[3];
									

					//****************comment for************
					var var_comm2 = comment_var_arr[1];
					
					var comment_for_arr = var_comm2.split("-->"); 
					var comm_for_id = comment_for_arr[0];
					var comm_for_val = comment_for_arr[1];
					var comm_for_link = comment_for_arr[2];
				
					
					
					
					//****************comment of user************
					var var_comm3 = comment_var_arr[2];					
					var comment_user_arr = var_comm3.split("-->"); 
					var comm_user_id = comment_user_arr[0];
					var comm_user_name = comment_user_arr[1];		
					var comm_user_city = comment_user_arr[2];	
					
					var comm_user_country = comment_user_arr[3];
					var comm_user_flag = comment_user_arr[4];
					var comm_user_date = comment_user_arr[5];
					
					
					
					//****************comment detail************
					var var_comm4 = comment_var_arr[3];
					var comment_desc_arr = var_comm4.split("-->"); 
					var comm_desc_id = comment_desc_arr[0];
					var comm_desc_val = comment_desc_arr[1];				

					

					//****************title detail************
					var var_comm5 = comment_var_arr[4];
					var title_desc_arr = var_comm5.split("-->"); 
					var title_desc_id = title_desc_arr[0];
					var title_desc_val = title_desc_arr[1];
					var title_for_link = title_desc_arr[2];

					temp_table = temp_table.replace("comm_for_link",comm_for_link);
					temp_table = temp_table.replace("main_forum_link",main_link);
					temp_table = temp_table.replace("main_forum_link",main_link);
					temp_table = temp_table.replace("title_for_link",title_for_link);

					temp_table =temp_table.replace("comm_for_val",comm_for_val);
					temp_table =temp_table.replace("comm_for_val",comm_for_val);


					temp_table = temp_table.replace("tot_comm_val",tot_comm_val);
					temp_table =temp_table.replace("image_name_val",image_name);
					
					temp_table = temp_table.replace("comm_user_name",comm_user_name);
					temp_table =temp_table.replace("comm_user_city",comm_user_city);
					temp_table =temp_table.replace("comm_user_country",comm_user_country);
					temp_table =temp_table.replace("image_flag",comm_user_flag);
					temp_table =temp_table.replace("comm_user_date",comm_user_date);
										
					temp_table = temp_table.replace("comm_desc_val",comm_desc_val);
					temp_table =temp_table.replace("title_desc_val",title_desc_val);
									

					dy_temp_table = dy_temp_table + temp_table;
					b++;

				}	
				document.getElementById("recent_table").innerHTML=dy_temp_table;
			}
			//********************************************************
		}
	 } 
}
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;
}