// JavaScript Document

var requestURL = 'messages.php?uid={literal}{php} print_r($_SESSION[_default][user_id]); {/php}{/literal}';
var requestTimeout = 15000; /** sets the frequency for checking back */
var justStarted = 1;
var oldResult = 0;
var newResult = 0;

function getHTTPObject()
{
  var xmlhttp;

  /** Special IE only code ... */
  /*@cc_on
    @if (@_jscript_version >= 5)
        try
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (E)
            {
                xmlhttp = false;
            }
       }
    @else
       xmlhttp = false;
  @end @*/

  /** Every other browser on the planet */
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
    try
    {
      xmlhttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlhttp = false;
    }
  }

  return xmlhttp;
}


var xmlHttp = false;

function getDynamicData(isStart)
{

  if (isStart) xmlHttp = getHTTPObject();

  if (typeof xmlHttp == 'object') {

    xmlHttp.open('GET', requestURL + '&rnd=' + Math.ceil(Math.random()*100000), true);
    xmlHttp.onreadystatechange = callbackFunction;
    xmlHttp.send(null);

    setTimeout('getDynamicData(0)', requestTimeout);
  }
}


function callbackFunction()
{
  if (xmlHttp.readyState != 4)
    return;

  try {
    //
    // Parse XML and show result
    // 
    var xmlDoc = xmlHttp.responseXML;

    if (xmlDoc != null) {

      oldResult = newResult;
      newResult = xmlDoc.getElementsByTagName('result')[0].firstChild.nodeValue;

      if (justStarted) {

        justStarted = 0;
        blinkTitle(1);
      }
    }
  }
  catch (e) {
  }
}

function blinkTitle(show) {

  if (oldResult != newResult) {
  
    show = 1;
    oldResult = newResult;
  }

  var tmp = document.getElementById('myMessage');

  var text2 = ' ';

  if (tmp) {

    if (newResult == 0) {

      text2 = 'MAIL (0)';
    }
    else {
  
      if (show) {

        text2 = 'MAIL (' + newResult + ')';
      }
    }

    if (tmp.innerHTML != text2) tmp.innerHTML = text2;
  }

  if (document.title != text2) document.title = 'MaleMatch.net - ' + text2;

  setTimeout('blinkTitle(' + Math.abs(show - 1) + ')', 1000);
}
 
 ;

//  window.addEvent('load', function()
//  {
//	var Tips1 = new Tips($$('.Tips1'));
//  });
  




