function Connector(url, message, method)
{
	this.Message 		= message;
	this.Url	 		= url;
	this.ErrorCode 		= 0;
	this.Request 		= false;  				
	this.Method			= "GET" ;
	this.Send			= makeRequest;			
	this.OnLoaded		= "";
	this.Processed		= false;
	
	if (method.toUpperCase()=="POST") this.Method="POST";
}

function makeRequest()
{ 
this.Request = false;

if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
	this.Request = new XMLHttpRequest();
	if (this.Request.overrideMimeType) 
		{
		this.Request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) 
	{ // IE
	try {
		this.Request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
		try {
			this.Request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
if (!this.Request)
	{
	this.ErrorCode=1;
	return false
	}
	this.Request.open(this.Method, this.Url, true);

this.Request.setRequestHeader("Connection", "close");
if (this.Method=="POST") 
{
	this.Message='xmlrequest='+encodeURI(this.Message); 
	this.Request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	this.Request.setRequestHeader("Content-length", this.Message.length);
	
	this.Request.send(this.Message);
}
else this.Request.send(null);
connection = this;
this.Request.onreadystatechange = function (){
				if (connection.Request.readyState == 4)
					{
					if (connection.Request.status != 200) connection.ErrorCode = 2;
					if (!connection.Processed){
						connection.OnLoaded(connection);											
						connection.Processed = true;
						}
					} 
				}
}


function getMessages()
{
self.timerID = self.setTimeout("getMessages()", 3000); //? másodperc múlva ismét ide
var conn = new Connector('http://triumphclub.extra.hu/chat_main.php',"","GET");
conn.OnLoaded= printMessages;
conn.Send();
}

function printMessages(connection)
{
xml = false
    if (connection.ErrorCode==0) {
	xml = connection.Request.responseText;
	frames['msg_frame'].document.getElementById('messages').innerHTML = xml;
	}

}

function addsmiley(symbol) {
  document.postshout.msg_text.value +=' '+symbol+' ';
  document.postshout.msg_text.focus();
}


function oldalnyit(a,param) {
  a.action=param;
  a.submit();
  return;
}

function nagykep(kephely,kepnev){
	imgWin=window.open('about:blank','','scrollbars=yes,width=800,height=600,left=50,top=50');
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px; padding:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('function reSizeToImage(){');
			writeln('width=document.images[0].width+23;');
			writeln('height=document.images[0].height+45;');
			writeln('window.resizeTo(width,height);}');
			writeln('function doTitle(){document.title="'+kepnev+'";}');
			writeln('</sc'+'ript>');
			writeln('</head><body bgcolor=064C89 scroll="yes" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="George" src='+kephely+' onclick="window.close()" style="display:block"></body></html>');
		close();        
}}

function kezdolapbetesz(){
	if(document.all) {
		document.body.style.behavior='url(#default#homepage)'; 
		document.body.setHomePage('http://triumphclub.extra.hu');}
	else {
		alert('Nem támogatott ezt a funkció! (Eszözök/Beállítások menüpont)');}
	if(sethomepage==0) send_data(0);
	sethomepage = 1;
}

function swapImage() {
	var i,j=0,x,a=swapImage.arguments; 
	document.sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){
	      document.sr[j++]=x; 
	      if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	   }
}


function swapImgRestore() {
	var i,x,a=document.sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
	   x.src=x.oSrc;
}

function preloadImages() { 
 	var d=document; 
	if(d.images){ 
	  if(!d.p) d.p=new Array();
	    var i,j=d.p.length,a=preloadImages.arguments; 
	    for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ 
		d.p[j]=new Image; 
		d.p[j++].src=a[i];
		}
	}
}

function findObj(n, d) { 
	var p,i,x;  
	if(!d) 
	  d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
	  d=parent.frames[n.substring(p+1)].document; 
	  n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) 
	  x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
	    x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
	   x=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
	  x=d.getElementById(n); 
return x;
}

function insertOption(elemtext,elemvalue,listahova,listahonnan,listahovau)
  {
  var y=document.createElement('option');
  y.text=elemtext
  y.value=elemvalue
  var x=document.getElementById(listahova);
  var z=document.getElementById(listahonnan);
  var sel=x.options[0]

  try
    {
    x.add(y,sel);
    z.remove(z.selectedIndex);
    }
  catch(ex)
    {
    x.add(y,0); // IE only
    }


  var u=document.getElementById(listahovau);
  u.value="";

if (listahova=="users_lb"){
	for(i=0; i<z.length; i++) {
	  u.value=u.value+(z.options[i].value+",");
		}
	} else {
	for(i=0; i<x.length; i++) {
	  u.value=u.value+(x.options[i].value+",");
		}
	}
    }

function insertOptionm(listahonnan,listahova,listahovagy)
  {
  var y=document.createElement('option');
  y.text=elemtext
  y.value=elemvalue
  var x=document.getElementById(listahova);
  var z=document.getElementById(listahonnan);
  var sel=x.options[0]

  try
    {
    x.add(y,sel);
    z.remove(z.selectedIndex);
    }
  catch(ex)
    {
    x.add(y,0); // IE only
    }


  var u=document.getElementById(listahovau);
  u.value="";

if (listahova=="users_lb"){
	for(i=0; i<z.length; i++) {
	  u.value=u.value+(z.options[i].value+",");
		}
	} else {
	for(i=0; i<x.length; i++) {
	  u.value=u.value+(x.options[i].value+",");
		}
	}
    }
