/*#################################################
*# 
*# script.js
*# @author Záros Zsolt 
*#
*##################################################
*/

var ua = navigator.userAgent.toLowerCase();
var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1));
var isGecko = (ua.indexOf("gecko") != -1);
var isSafari = (ua.indexOf("safari") != -1);
var isKonqueror = (ua.indexOf("konqueror") != -1);


if (!Array.indexOf) {
  Array.prototype.indexOf = function(obj) {
    for( var i=0, to=this.length; i<to; i++) {
      if (this[i]==obj) return i;
    }
    return -1;
  };
}

if (!isIE) {
	if (!HTMLElement.attachEvent) {
		HTMLElement.prototype.attachEvent = function(type, listener) {
			this.addEventListener(type.replace(/on/,""), listener, false);
		};
	}

	if (!HTMLElement.detachEvent) {
		HTMLElement.prototype.detachEvent = function(type, listener) {
			this.removeEventListener(type.replace(/on/,""), listener, false);
		};
	}


	if (!Event.srcElement) {
		Event.prototype.__defineGetter__("srcElement", function() {
			return this.target;
		});
	}


	if (!Node.text) {
		Node.prototype.__defineGetter__("text", function() {
			return this.textContent;
		});
	}

	if (!Node.innerText) {
		Node.prototype.__defineSetter__("innerText", function(t) {
			this.textContent = t;
		});
	}
}


function cancelEvent(e) {
   e = e ? e : window.event;
   if(e.stopPropagation) e.stopPropagation();
   if(e.preventDefault) e.preventDefault();
   e.cancelBubble = true;
   e.cancel = true;
   e.returnValue = false;
   return false;
}

function getKEY(e) {
  try {
    return window.event.keyCode;
  } catch (err) {
    return (e.keyCode != 0) ? e.keyCode : e.charCode;
  }
}

function getMousePos(e) {
  var mouseX,mouseY;
  var pos = new Array();

  e = e ? e : window.event;

  if (e.pageX) {
    pos['X'] = e.pageX;
    pos['Y'] = e.pageY;
  } else {
    pos['X'] = e.clientX + document.body.scrollLeft;
    pos['Y'] = e.clientY + document.body.scrollTop;
  }

  return pos;
}

function disableSelection(el){
  if (typeof el.onselectstart != "undefined") el.onselectstart = function() { return false };
  else if (typeof el.style.MozUserSelect != "undefined") el.style.MozUserSelect = "none";
}

function trim(str) {
    return str.replace(/(^\s+)([^\s]*)(\s+$)/, '');
}

//function $(el) {
//	return document.getElementById(el);
//}



function classZAjax(requestFajl, method, aszinkron, toltesKijelzo) {
  var http = null;
  var targetDiv = null;
  var targetDivAppend = false;
  var targetFunc = null;
  var targetFuncXML = false;

  this.method = method;
  this.aszinkron = aszinkron;
  this.params = new Array();


  function requestObject() {
    var ro;

    if (window.XMLHttpRequest) {
      ro = new XMLHttpRequest();
    } else {
      ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ro;
  }

  this.sendRequest = function() {
    http = null;
    if (toltesKijelzo) toltesKijelzo.style.display = "inline";
    http = requestObject();
    http.onreadystatechange = response;
    if (this.method == "post") {
      http.open("post", requestFajl, this.aszinkron);
      http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http.setRequestHeader("Content-length", this.getParams().length);
      http.setRequestHeader("Connection", "close");
      http.send(this.getParams());
    } else {
      http.open("get", requestFajl+"?"+this.getParams(), this.aszinkron);
      http.send(null);
    }
  }

  this.addParam = function(param) {
    this.params.push(param);
  }

  this.getParams = function() {
    var p = "";

    for(var i=0; i<this.params.length; i++) {
      if (p != "") p += "&";
      p += this.params[i][0]+"="+this.params[i][1];
    }

    return p;
  }

  this.clearParams = function() {
    this.params = [];
  }

  this.setResponseTarget = function(div, append) {
    targetDiv = div;
    targetDivAppend = append;
  }

  this.setResponseFunction = function(func, xml) {
    targetFunc = func;
    targetFuncXML = xml;
  }

  function response() {
    if (http.readyState == 4) {
      if (targetFunc != null) {
        if (!targetFuncXML) targetFunc(http.responseText);
          else targetFunc(http.responseXML);
      } else {
        if (!targetDivAppend) targetDiv.innerHTML = http.responseText;
          else targetDiv.innerHTML += http.responseText;
      }
      if (toltesKijelzo) window.setTimeout('$("'+toltesKijelzo.id+'").style.display = "none"', 1500);
    }
  }

}

function kartya(id, src_php){
	var div = document.getElementById("kartya_"+id);
	
	if(div.style.display != "none"){
		div.style.display = "none";
		document.getElementById("kartya_"+id+"_nyil").src = src_php+"img/h2_nyil_le.jpg";
	}else{
		div.style.display = "block";
		document.getElementById("kartya_"+id+"_nyil").src = src_php+"img/h2_nyil_fel.jpg";
	}
}

function kartya_4(id, src_php){
	var div = document.getElementById("kartya_"+id);
	
	if(div.style.display != "none"){
		div.style.display = "none";
		document.getElementById("kartya_"+id+"_nyil").src = src_php+"img/hirek_box/tartalomjegyzek_nyil_fel.gif";
	}else{
		div.style.display = "block";
		document.getElementById("kartya_"+id+"_nyil").src = src_php+"img/hirek_box/tartalomjegyzek_nyil_le.gif";
	}
}

function kartya_2(id){
	var div = document.getElementById("kartya_"+id);	
	if(div.style.display != "none"){
		div.style.display = "none";		
	}else{
		div.style.display = "block";
	}
}

function kartya_3(id){
	if(document.getElementById("kartya_"+id).style.display == "block"){
		document.getElementById("kartya_"+id).style.display = "none";		
	}else{
		document.getElementById("kartya_"+id).style.display = "block";		
	}
}

function tip(e, str) {
	
	if (str != '') {
		var div = document.createElement('DIV');
		div.id = "tipDiv";
		with(div.style){
			position = "absolute";
			top = getMousePos(e)['Y']+10+"px";
			left = getMousePos(e)['X']+10+"px";
			width = "200px";
			padding = "5px";
			textAlign = "center";
			border ="1px solid #ccc";
			background = "#fff";
			fontSize = "8pt";
			color = "#000";
		}
		div.innerHTML = str;
		
		document.body.appendChild(div);
	} else {
		try {
			document.body.removeChild($('tipDiv'));
		} catch (err) {
			;
		}
	}
}

	// Campus Club
	function campus_foglalas_null(){
		Event.observe(window,'load', campus_foglalas_null2);
	}
	
	function campus_foglalas_null2(){
		$('tr_ejszaka_szam').style.display = '';
		$('tr_datum_valaszto').style.display = '';
		$('tr_datum_kiiro').style.display = 'none';
		$('ajanlat_ev').disabled = true;
		$('ajanlat_honap').disabled = true;
		$('ajanlat_nap').disabled = true;
		$('campus_noartabla').value = "1";
		$('leker_form_valassz').style.display = 'none';
		Element.hide('leker_form_valassz');
		Element.show('leker_form');
		Element.show('leker_gomb');
		$('turnusszam').value = "noturnus";
		$('szobaszam').value = "notszoba";
	}

	
function antihtmlspecialchars(ch) {
ch = ch.replace("&amp;","&")
ch = ch.replace("&quot;","\"")
ch = ch.replace("&#039;","\'")
ch = ch.replace("&lt;","<")
ch = ch.replace("&gt;",">")
return ch
}