//------------------------------------------------
// Misc
//------------------------------------------------
function confirmLink(question, url)
{
    var is_confirmed = confirm(question);

    if (is_confirmed)
        window.location = url;

    return is_confirmed;
}

function showhide_field(name, show)
{
    if (document.getElementById(name).style.display == "none"  &&  show == ''  ||  show == 1)
    {
        document.getElementById(name).style.display = "block";
    }
    else
    {
        document.getElementById(name).style.display = "none";
    }
}

//------------------------------------------------
// Chat
//------------------------------------------------
var httpReceiveChat = null;
var httpSendChat = null;
var chatwincurr = 0;
var autocheck = 0;
var autodelay = 8;
var virpath = '';
chatwins = new Array();

function checkChat(path,check,delay)
{
    virpath = path;
    autocheck = check;
    autodelay = delay;
    httpReceiveChat = getHTTPObject();
    httpSendChat = getHTTPObject();
    receiveChatText();
}

function receiveChatText() {
	if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
  	httpReceiveChat.open("GET",virpath+'chat.php?p=check', true);
    httpReceiveChat.onreadystatechange = handlehHttpReceiveChat;
  	httpReceiveChat.send(null);
	}
}

function handlehHttpReceiveChat() {
    if (httpReceiveChat.readyState == 4) {
        memberid = httpReceiveChat.responseText;
        if (memberid != "0") openChatWindow(memberid);
        if (autocheck) setTimeout('receiveChatText();', (autodelay*1000));
    }
}

function openChatWindow(id) {
    if (id > 0 && (typeof(chatwins['chat' + id]) != "object"  ||  chatwins['chat' + id].closed)) {
        chatwins['chat' + id] = window.open(virpath + 'index.php?m=chat&id=' + id, 'chat' + id, 'width=380,height=360,resizable=yes,scrollbars=no,toolbar=no,location=no,status=no,menubar=no');
        if (chatwins['chat' + id].focus) chatwins['chat' + id].focus();
    }
}

function getHTTPObject() {
  var xmlhttp;
  /*@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 @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


