function getRealStyle(element)
{
  if (element.currentStyle) return element.currentStyle;
  else return window.getComputedStyle(element,null);
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function CutPx(s)
{
  var pos=s.indexOf('px');
  s=s.slice(0, pos);
  return s;
}

function Refresh()
{
  location.href=location.href;
}

function AjaxTest(valami)
{
  alert(valami);
}

//feldolgozo php neve, POST-ba mi menjen, visszakapott adatokat feldolgozo fgv
function ajaxFunction(php, poststring, fanksen)
{
	var ajaxRequest;
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("No AJAX support!");
				return false;
			}
		}
	}
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
      fanksen(ajaxRequest.responseText);
		}
	}
	ajaxRequest.open("POST", php, true);
	ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxRequest.send(poststring); 
}

//kozepre tesz egy divet
function CenterDiv(name) {
  if (document.getElementById) {
    var windowHeight = getWindowHeight();
    var windowWidth = document.body.offsetWidth;
    if (windowHeight > 0) {
      var contentElement = document.getElementById(name);
      var contentHeight = contentElement.offsetHeight;
      var contentWidth = contentElement.offsetWidth;
      if (windowHeight - contentHeight > 0) {
        contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
        contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
      }
      else {
        contentElement.style.position = 'static';
      }
    }
  }
}

function HorCenterDiv(name) {
  if (document.getElementById) {
    var windowWidth = document.body.offsetWidth;
    var contentElement = document.getElementById(name);
    var contentWidth = contentElement.offsetWidth;
    contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
  }
}

function getWindowHeight() {
  var windowHeight = 0;
  if (typeof(window.innerHeight) == 'number') {
    windowHeight = window.innerHeight;
  }
  else {
    if (document.documentElement && document.documentElement.clientHeight) {
      windowHeight = document.documentElement.clientHeight;
    }
    else {
      if (document.body && document.body.clientHeight) {
        windowHeight = document.body.clientHeight;
      }
    }
  }
  return windowHeight;
}

function RetekSemmi()
{
}

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^| )"+searchClass+"( |$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function OpenTOC(langcode)
{
  w = 640;
  h = 480;
  if(langcode==1){url="toc_hu.php"};
  if(langcode==2){url="toc_en.php"};  
  pWin = window.open(url,"piWin","width="+w+",height="+h+",status=0,resizable=0,scrollbars=1");
}

function OpenBeta(langcode)
{
  w = 640;
  h = 480;
  if(langcode==1){url="beta_hu.php"};
  if(langcode==2){url="beta_en.php"};  
  pWin = window.open(url,"piWin","width="+w+",height="+h+",status=0,resizable=0,scrollbars=1");
}

