var myAJAX;
var serverResponse;

var myrules = {
	/*'#moje p' : function(el){
		el.onclick = function(){
			//new Effect2.DropOut(this);
			
		};
		el.onmouseover = function(){
			this.style.color = "orange";
			this.style.backgroundColor = "#CCCC00";
		};
		el.onmouseout = function(){
			this.style.backgroundColor = "#ffffff";
			//this.className = "";
		}
	},*/
	'#menu dt' : function(el){
		el.onclick = function(){
			sDown('smenu' + this.id);
			//new Effect2.DropOut(this);
		};
	},
	'#menu dt a img': function(el){
		el.onmouseover = function(){
			this.src = 'gfx/menu/' + this.id + 'o.gif';
		};
		el.onmouseout = function(){
			this.src = 'gfx/menu/' + this.id + '.gif';
		};
	}
	/*'#menu dd ul li a': function(el){
		el.onclick = function(){
			this.href = 'javascript:showMe(\'html/' + this.id + '.html\');';
		};
		el.onmouseout = function(){
			this.href = 'html/' + this.id + '.html';
		};
	}*/
};

Behaviour.register(myrules);

function positionMe(what)
{
	obj = document.getElementById(what);
	var moveIt = 0;
	if (what == 'main')
		moveIt = 15;
	else if (what == 'rightContent')
		moveIt = 148;
	if (document.getElementById && !document.all)
	{
		//obj.style.left = (window.innerWidth - 750) / 2+'px';
		obj.style.left = moveIt + 'px';
	}
	else
	{	
		if (what == 'rightContent')
			moveIt = moveIt + 4;
		//obj.style.pixelLeft = (document.body.clientWidth - 750) / 2;
		obj.style.pixelLeft = moveIt;
	}
}

function rightMargin(what)
{
	obj = document.getElementById(what);
	if (document.getElementById && !document.all)
	{
		if (window.innerWidth > 750)
		{
			obj.style.width = (window.innerWidth - 185) + 'px';
		}
		else
		{
			obj.style.width = 565 + 'px'; //750-185
		}
	}
	else
	{
		if (document.body.clientWidth > 700)
		{
			obj.style.width = (document.body.clientWidth - 195);
		}
		else
		{
			obj.style.width = 565;
		}
	}
}

function centerMe(what, objWidth, objHeight)
{
	obj = document.getElementById(what);
	if (document.getElementById && !document.all)
	{
		obj.style.left = (window.innerWidth-objWidth)/2+'px';
		obj.style.top = 140+'px';
	}
	else
	{
		obj.style.pixelLeft = 100+(document.body.clientWidth-objWidth)/2;
		obj.style.pixelTop = 140;
	}
	//window.status='wrx';
}

function showMe(what)
{
	if (what != '')
	{
		obj = document.getElementById('asynContent');
		//obj.style.visibility = 'visible';
		//centerMe('asynContent', 240, 0);
		
		myAJAX = createXMLHttpRequest();
		myAJAX.open("GET", what, false);
		//myAJAX.setRequestHeader("Content-Type", "text/xml; charset=iso-8859-2")
		myAJAX.send(null);
		serverResponse = myAJAX.responseText;
		//alert();
		
		obj.innerHTML = serverResponse;
		wResize();
	}
}

function createXMLHttpRequest()
{
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest nie jest obslugiwane!");
   return null;
}

function closeMe(what)
{
	obj = document.getElementById(what);
	obj.style.visibility = 'hidden';
	obj.innerHTML = "";
}
