var scrw=640;
var scrh=480;

var Screen_Center_x = (scrw)/2;
var Screen_Center_y = (scrh)/2;

function initMain()
{
 try
 {
  var scrw=(window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
  var scrh=(window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));  
  var Screen_Center_x = (scrw)/2;
  var Screen_Center_y = (scrh)/2;

 }
 catch(e)
 {
  txt="There was an error on this page.\n\n"
  txt+="Error description: " + e.description + "\n\n"
  txt+="Click OK to continue.\n\n"
  myAlert(txt);
 }
}

function SetValue(Name, Val)
{
 try
  {eval(Name+' = '+Val);}
 catch(e)
  {
   txt="There was an error on this page.\n\n"
   txt+="Error description: " + e.description + "\n\n"
   txt+="Click OK to continue.\n\n"
   myAlert(txt);
  }
}

function GetValue(Name)
{
 try
  {
   var Val;
   eval(Val+' = '+Name);
  }
 catch(e)
  {
   txt="There was an error on this page.\n\n"
   txt+="Error description: " + e.description + "\n\n"
   txt+="Click OK to continue.\n\n"
   myAlert(txt);
  }
 return Val;
}

function initAJAX()
{
 var xmlHttp;
 try
 {xmlHttp=new XMLHttpRequest();/* Firefox, Opera 8.0+, Safari*/}
 catch (e)
 {/*Internet Explorer*/
  try
  {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  catch (e)
  {
   try
   {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
   catch (e)
   {
    myAlert("Your browser does not support AJAX!");
    return null;
   }
  }
 }
 return xmlHttp;
}

function myAlert(s)
{
 alert(s);
 return;
}

function add_onload(func)
{
 if (window.attachEvent)
 {
  window.attachEvent('onload', func);
 }
 else if (window.addEventListener) 
 {
  window.addEventListener('load', func,true);
 }
}

function ShowLayer(URL,width,height)
{
 if (!document.getElementById('newLayer'+n))
 {
  var o=document.createElement('div');
  o.id='newLayer'+n;
  document.body.appendChild(o);
  var os=document.createElement('div');
  os.id='newLayerSh'+n;
  document.body.appendChild(os);
 }
 else if (document.getElementById('newLayer'+n).style.display!='none')
 {
//    _showOnTop(n);
  document.getElementById('layerContent'+n).innerHTML='<div align="left"><div class="myWinLoad"></div></div>';
//  get_ajax_content(u,f,multypart);
  return '';
 }
}

function getPageSize()
{
 var xScroll, yScroll;

 if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
 xScroll = document.body.scrollWidth;
 yScroll = document.body.scrollHeight;
 }
 else if (window.innerHeight && window.scrollMaxY) {
 xScroll = window.innerWidth + window.scrollMaxX;
 yScroll = window.innerHeight + window.scrollMaxY;
 }
 // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari.
 else {
 xScroll = document.body.offsetWidth;
 yScroll = document.body.offsetHeight;
 }

 var windowWidth, windowHeight;

 if (self.innerHeight) { // All except Explorer.
 if (document.documentElement.clientWidth) {
 windowWidth = document.documentElement.clientWidth;
 }
 else {
 windowWidth = self.innerWidth;
 }
 windowHeight = self.innerHeight;
 }
 // Explorer 6 Strict Mode.
 else if (document.documentElement && document.documentElement.clientHeight) {
 windowWidth = document.documentElement.clientWidth;
 windowHeight = document.documentElement.clientHeight;
 }
 else if (document.body) { // Other Explorers.
 windowWidth = document.body.clientWidth;
 windowHeight = document.body.clientHeight;
 }


 // For small pages with total height less then height of the viewport.
 if (yScroll < windowHeight) {
 pageHeight = windowHeight;
 }
 else {
 pageHeight = yScroll;
 }


 // For small pages with total width less then width of the viewport.
 if (xScroll < windowWidth) {
 pageWidth = windowWidth;
 }
 else {
 pageWidth = xScroll;
 }

 arrayPageSize = [pageWidth, pageHeight, windowWidth, windowHeight];
 return arrayPageSize;
}

var IsWorkingPrivateChatRequest = false;
function PrivateChatRequest(UserName)
{
 if (!confirm("Request private chat with user "+UserName+" ?")) return;
 if (IsWorkingPrivateChatRequest) return;
 IsWorkingPrivateChatRequest = true;
 xmlHttp = initAJAX();
 function ProcessResponse()
 {
  try
  {
   if (xmlHttp.readyState==4)
   {
    IsWorkingPrivateChatRequest = false;
    if(xmlHttp.responseText!='Ok')
   { alert(xmlHttp.responseText);}
    else
     { myAlert('Request sent to user: '+UserName);}
   }
  }
  catch(e)
  {myAlert("Error: ("+e.descr+") ("+e.name+" "+e.message+") in common lib");} 
  return;
 }
 if (!xmlHttp)
 { myAlert('Can`t send'); return 0;}
 try
 {
  var s = 'user='+escape(UserName);
  xmlHttp.onreadystatechange=ProcessResponse;
  xmlHttp.open("POST","/functions/PrivateChatRequest.php",true);
  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
  xmlHttp.send(s);
 }
 catch(e)
 {myAlert("Error: ("+e.descr+") ("+e.name+" "+e.message+")");} 
 return;

}

function writeDocument(s){document.write(s);}

add_onload(initMain);
