var httpRemoveComments      = getHTTPObject();
var httpUpdate      		= getHTTPObject();
var httpCheckUser           = getHTTPObject();
//
function getHTTPObject()
{
  var xmlhttp;

  if (!xmlhttp )
  {
    if(window.XMLHttpRequest) 
    {
      try {
           xmlhttp = new XMLHttpRequest();
      } 
      catch(e) {
             xmlhttp = false;
      }
    }
    else if(window.ActiveXObject)
    {
       try {
           xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
            catch(E) {
                  try {
                       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } 
                  catch(e) {
                          xmlhttp = false;
                  }
            }
     }
  }
  return xmlhttp;
}
//============= Email Matching ==================

var fixedh = "8";
var fixedm = "01";
var fixeds = "01 PM";
function countTime()
{   
	var dateObject = new Date();	
	var displaytime = dateObject.toLocaleTimeString();
	
	var now = displaytime.split(':');
	var hr =trim(now[0]);
	var mm =trim(now[1]);
	var ss =trim(now[2]);
		
	//alert(hr);alert(mm);alert(ss);
	setTimeout("countTime()",1000);
	
	if(fixedh==hr && fixedm==mm && fixeds==ss)
	{	
		sendRequest4matchingEmail();	
		//alert(displaytime); 
	}
}

function sendRequest4matchingEmail()
{
	  httpUpdate.onreadystatechange = handleSaveResponse;
	  httpUpdate.open("GET", 'index.php?app=home&cmd=email_matching', true);  	
  	  httpUpdate.send(null);
}
function handleSaveResponse()
{
   
    if(httpUpdate.readyState == 4)
    {    	
    	//alert(trim(httpUpdate.responseText));      
    }   
    
}
//==============End Email Matching=============

function showTip()
{ 
  document.getElementById('ltip').style.display = 'block';
  document.getElementById('ltip').style.visibility = 'show';  
  if(document.getElementById('ltip').style.visibility =="hidden")
  {
  	document.getElementById('ltip').style.visibility = 'show'; 	
  }
     
} 
function hideTip()
{ 	 
 document.getElementById('ltip').style.display = 'none';
 document.getElementById('ltip').style.visibility = 'show'; 	
	    
 } 
function _select(elid)
{
	if(elid.checked == true)
	{
		elid.checked = true;
	}
	else 
	{
		elid.checked= false;
	}
}

function _selectAll(elid)
{
	if(elid.checked == true)
	{
		elid.checked = false;
	}
	else 
	{
		elid.checked= true;
	}
}


function CheckAll(chk, frm)
{
	var chkall = document.getElementById('chkall');
	var tf;
	if(chkall.checked == true)
	{
		tf = true;
	}
	else
	{
		tf = false;
	}
		var el_collection = eval("document.forms."+frm+"."+chk);
		for(c=0;c<=el_collection.length;c++)
		{
			if(tf)
			{
				//el_collection[c].checked = false;
				_selectAll(el_collection[c]);
			}
			else
			{
				//el_collection[c].checked = true;
				_selectAll(el_collection[c]);
			}
		}
}//EoF CheckAll


function addFaq_user()
{
	var user_question = document.getElementById('user_question').value;	
	if(user_question)
	{
		return true;	
	}
	else
	{
		alert('Question can not be empty...');
		faq_frm.user_question.focus();
		return false;		
	}
	
}
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){

return "";
}

else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
