// JavaScript Document
function active_licensee(client,active)
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
	var relocation = 'active'+client;		
    if(xmlHttp.readyState==4)
      {
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState==3)
	  {
	      document.getElementById(relocation).innerHTML = 'Loading';		
	  }
    }
  xmlHttp.open("GET","user_active.php?client="+client+"&active="+active,true);
  xmlHttp.send(null);
  }
// JavaScript Document
function SearchNow(value,type,location,caset)
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  var relocation = 'results';
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState!=4)
	  {
	      document.getElementById(relocation).innerHTML = '<div id="loading-background"><div id="loading"><img src="greybox/indicator.gif"></div></div>';		
	  }
    }
  xmlHttp.open("GET","SearchNow.php?value="+value+"&type="+type+"&location="+location+"&caset="+caset,true);
  xmlHttp.send(null);
  }

function active_user(client,active)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  var relocation = 'activeportal';
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","user_activation.php?client="+client+"&active="+active,true);
  xmlHttp.send(null);
  }
 // Green House Functions
 // Function Save Changes to Log
function save_statuslog(id,logvalue)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
	var relocation = 'greenhousecontainer';		
    if(xmlHttp.readyState==4)
      {
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState==3)
	  {
	      document.getElementById(relocation).innerHTML = 'Loading';		
	  }
    }
  xmlHttp.open("GET","upate_crmlog.php?id="+id+"&logvalue="+logvalue,true);
  xmlHttp.send(null);
  }
  
 
function save_crmrecord(id,comp_name,c_fname,c_lname,c_email,c_stage)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
	var relocation = 'greenhousecontainer';		
    if(xmlHttp.readyState==4)
      {
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState==3)
	  {
	      document.getElementById(relocation).innerHTML = 'Loading';		
	  }
    }
  xmlHttp.open("GET","update_crmrecord.php?id="+id+"&comp_name="+comp_name+"&c_fname="+c_fname+"&c_lname="+c_lname+"&c_email="+c_email+"&c_stage="+c_stage,true);
  xmlHttp.send(null);
  }


  
function Delete_lead(id)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
	var relocation = 'greenhousecontainer';		
    if(xmlHttp.readyState==4)
      {
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState==3)
	  {
	      document.getElementById(relocation).innerHTML = 'Loading';		
	  }
    }
	
  xmlHttp.open("GET","delete_crm.php?id="+id,true);
  xmlHttp.send(null);
  }

function add_crmrecord(uid,comp_name,c_fname,c_lname,c_phone,c_statuslog,c_email,c_stage)
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
	var relocation = 'greenhousecontainer';		
    if(xmlHttp.readyState==4)
      {
		  location.reload(true);
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState==3)
	  {
	      document.getElementById(relocation).innerHTML = 'Loading';		
	  }
    }
  xmlHttp.open("GET","add_crmrecord.php?uid="+uid+"&comp_name="+comp_name+"&c_fname="+c_fname+"&c_lname="+c_lname+"&c_phone="+c_phone+"&c_statuslog="+c_statuslog+"&c_email="+c_email+"&c_stage="+c_stage,true);
  
  xmlHttp.send(null);
  }
 //Seach Function
 function SearchCompany(value)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  var relocation = 'greenhousecontainer';
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState!=4)
	  {
	      document.getElementById(relocation).innerHTML = '<div id="loading-background"><div id="loading"><img src="greybox/indicator.gif"></div></div>';		
	  }
    }
  xmlHttp.open("GET","SearchCRM.php?value="+value,true);
  xmlHttp.send(null);
  }
  
function TrackCRM(page)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  var relocation = 'greenhousecontainer';
      	  document.getElementById(relocation).innerHTML = xmlHttp.responseText;
      }
	  else if(xmlHttp.readyState!=4)
	  {
	      document.getElementById(relocation).innerHTML = '<div id="loading-background"><div id="loading"><img src="greybox/indicator.gif"></div></div>';		
	  }
    }
  xmlHttp.open("GET","TrackCRM.php?page="+page,true);
  xmlHttp.send(null);
  }
 
