
	/* =========================== Common =================================== */

	/* addEvent, removeEvent functions from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent = function ( obj, type, fn ) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}

	/*
	JSTarget function by Roger Johansson, www.456bereastreet.com
	*/
	var JSTarget = {
		init: function(att,val) {
			if (document.getElementById && document.createElement && document.appendChild) {
				var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
				var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
				var arrLinks = document.getElementsByTagName('a');
				var oLink;
				var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
				for (var i = 0, il = arrLinks.length; i < il; i++) {
					oLink = arrLinks[i];
					if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
						oLink.onclick = JSTarget.openWin;
					}
				}
				oWarning = null;
			}
		},
		openWin: function(e) {
			var event = (!e) ? window.event : e;
			if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
			else {
			    var oWin = window.open(this.getAttribute('href'), '_blank');
				if (oWin) {
					if (oWin.focus) oWin.focus();
					return false;
				}
				oWin = null;
				return true;
			}
		}
	};

	getElementsByClassName = function( oElm, strTagName, strClassName ) {
		var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
		var arrReturnElements = new Array();
		strClassName = strClassName.replace(/-/g, "\-");
		var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
		var oElement;
		for (var i=0, il=arrElements.length; i<il; i++) {
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
				arrReturnElements.push(oElement);
			}
		}
		return (arrReturnElements)
	}

	var editClassName = {

		toggle : function( oElm, clsName ) {

			var oRegExp = new RegExp("(^|\\s)" + clsName + "(\\s|$)");
			oElm.className = (oRegExp.test(oElm.className)) ? oElm.className.replace(oRegExp, '') : oElm.className + ' ' + clsName;

		},

		remove : function( oElm, clsName ) {
			var oRegExp = new RegExp("(^|\\s)" + clsName + "(\\s|$)");
			oElm.className = oElm.className.replace(oRegExp, '');
		},

		add : function( oElm, clsName ) {
			oElm.className += ' ' + clsName;
		}
	}

	initPrintLink = function() {

		if ( ! document.getElementById('cikk_body') ) {
			return;
		}

		var aLinks = document.getElementsByTagName('a');
		var oRegExp = new RegExp("(^|\\s)" + 'print' + "(\\s|$)");

		for ( var i = 0, il = aLinks.length; i < il; i++ ) {

			if ( ! aLinks[i].getAttribute('rel') ) {
				continue;
			}

			if ( oRegExp.test( aLinks[i].getAttribute('rel') ) ) {
				aLinks[i].style.display = 'block';
				aLinks[i].onclick = function() {
					window.print();
					return false;
				}
			}

		}

	}

	initHideElements = function( tagName, clsName ) {

		var aHideElements = getElementsByClassName( document, tagName, clsName );

		for ( var i = 0, il = aHideElements.length; i < il; i++ ) {
			aHideElements[i].style.display = 'none';
		}

		return true;

	}

	/* =========================== Content =================================== */

	tabBox = function() {
		var aTabBox = getElementsByClassName( document, 'ul', 'tabs' );

		for ( var i = 0, il = aTabBox.length; i < il; i++ ) {

			var aLi = aTabBox[i].getElementsByTagName( 'li' );

			for ( var n = 0, nl = aLi.length; n < nl; n++ ) {

				if (aLi[n].parentNode == aTabBox[i]) {

					var aLink = aLi[n].getElementsByTagName( 'a' );

					aLink[0].onclick = function() {

						var ul = this.parentNode.parentNode;
						var aLocalLi = ul.getElementsByTagName( 'li' );

						for( q = 0, ql = aLocalLi.length; q < ql; q++ ) {

							if (aLocalLi[q].parentNode == ul) {
								editClassName.remove( aLocalLi[q], 'selected' );

								//IE6
								if ( false /*@cc_on || @_jscript_version < 5.7 @*/ ) {
									var span = aLocalLi[q].getElementsByTagName( 'span' );
									var filterVal = span[0].currentStyle.filter;
									filterVal = filterVal.replace( /_ieo.png/, '_ie.png' );
									span[0].style.filter = filterVal;
								}

							}

						}

						editClassName.add( this.parentNode, 'selected' );

						//IE6
						if ( false /*@cc_on || @_jscript_version < 5.7 @*/ ) {
							var span = this.getElementsByTagName( 'span' );
							var filterVal = span[0].currentStyle.filter;
							filterVal = filterVal.replace( /_ie.png/, '_ieo.png' );
							span[0].style.filter = filterVal;
						}

						var prntLi = this.parentNode;
						var aHidContent = getElementsByClassName( prntLi, 'div', 'screenrdr' );
						var contentTarget = getElementsByClassName( ul.parentNode, 'div', 'content' );

						contentTarget[0].innerHTML = aHidContent[0].innerHTML;

						return false;

					}
				}

			}


		}
	}

	equalBoxes = function() {

		var aColWrp = getElementsByClassName(document, 'div', 'colwrp');

		for ( var i = 0, il = aColWrp.length; i < il; i++ ) {

			var aCol05 = getElementsByClassName(aColWrp[i], 'div', 'col05');

			for ( var e = 0, el = aCol05.length; e < el; e++ ) {

				if ( aCol05[e].parentNode == aColWrp[i] ) {

					var aBox = getElementsByClassName(aCol05[e], 'div', 'box');

					for ( var n = 0, nl = aBox.length; n < nl; n++ ) {
						if ( n == aBox.length - 1 && aCol05[e].offsetHeight < aColWrp[i].offsetHeight ) {
							var aBoxContent = getElementsByClassName(aBox[n], 'div', 'boxcontent');

							//aBox[n].style.height = ( aBox[n].offsetHeight + aColWrp[i].offsetHeight - aCol05[e].offsetHeight ) + 'px';
							if ( aBoxContent[0] ) {
								aBoxContent[0].style.height = ( aBoxContent[0].offsetHeight - 19 + aColWrp[i].offsetHeight - aCol05[e].offsetHeight ) + 'px';
							}
						}
					}
/*
					var aBoxTab = getElementsByClassName(aCol05[e], 'div', 'boxtab');

					for ( var n = 0, nl = aBoxTab.length; n < nl; n++ ) {

						var aBoxContent = getElementsByClassName(aCol05[e], 'div', 'visible');
						var aUl = aBoxContent[0].getElementsByTagName('ul');

						//Az ul magassagat kell allitani.
					}
*/
				}

			}

			var aCol1 = getElementsByClassName(aColWrp[i], 'div', 'col1');


			for ( var e = 0, el = aCol1.length; e < el; e++ ) {



				if ( aCol1[e].parentNode == aColWrp[i] ) {

					var aBox = getElementsByClassName(aCol1[e], 'div', 'box');

					for ( var n = 0, nl = aBox.length; n < nl; n++ ) {

						if ( n == aBox.length - 1 && aCol1[e].offsetHeight < aColWrp[i].offsetHeight ) {
							var aBoxContent = getElementsByClassName(aBox[n], 'div', 'boxcontent');

							//aBox[n].style.height = ( aBox[n].offsetHeight + aColWrp[i].offsetHeight - aCol05[e].offsetHeight ) + 'px';

							if ( aBoxContent.length ) {
								aBoxContent[0].style.height = ( aBoxContent[0].offsetHeight - 19 + aColWrp[i].offsetHeight - aCol1[e].offsetHeight ) + 'px';
							}

						}
					}

				}

			}

		}

		return true;

	}
	
	equalCikkHeads = function() {
		
		var cikkRel = document.getElementById('rel_cikk_noprint');
		
		if ( ! cikkRel) {
			return true;
		}

		// ColWrp divek
		for (var i=0, il = cikkRel.childNodes.length; i < il; i++) {
			if ( cikkRel.childNodes[i].nodeName != 'DIV' || cikkRel.childNodes[i].className.indexOf('colwrp') == -1 ) {
				continue;
			}
			
			var arrH3 = cikkRel.childNodes[i].getElementsByTagName('h3');
			
			if ( arrH3[0].offsetHeight > arrH3[1].offsetHeight ) {
				arrH3[1].style.paddingTop = ( arrH3[0].offsetHeight - arrH3[1].offsetHeight ) + 'px';
			} else if ( arrH3[0].offsetHeight < arrH3[1].offsetHeight ) {
				arrH3[0].style.paddingTop = ( arrH3[1].offsetHeight - arrH3[0].offsetHeight ) + 'px';
			}
		}
		
	}

	initAjanloBoxes = function() {

		var aAjanloBoxes = getElementsByClassName(document, 'ul', 'boxajanlo');

		for	( var i = 0, il = aAjanloBoxes.length; i < il; i++ ) {

			var aLi = aAjanloBoxes[i].getElementsByTagName('li');

			for (var e = 0, el = aLi.length; e < el; e++) {

				aLi[e].onmouseover = function() {
					var ul = this.parentNode;
					var aLocalLi = ul.getElementsByTagName('li');

					for ( var q = 0, ql = aLocalLi.length; q < ql; q++ ) {
						editClassName.remove( aLocalLi[q], 'selected' );
					}

					editClassName.add( this, 'selected' );

				};

			}

		}

	}


	switchOnlineIcos = function( onlineUsers ) {

		var arrOnlineUsers = onlineUsers.split(',');

		if (  arrOnlineUsers.length == 0 ) {
			return true;
		}

		var arrPageUsers;
		try {
			arrPageUsers = document.getElementById('forum_hozzaszolasok_container').getElementsByClassName('ico-offline');
		} catch(err) {
			arrPageUsers = getElementsByClassName( document.getElementById('forum_hozzaszolasok_container'), 'span', 'ico-offline');
		}

		var actUserId;
		var elId;
		var i = 0;
		for ( i in arrPageUsers ) {

			try {
				elId = arrPageUsers[i].id;
				actUserId = elId.split('_')[2];
			} catch(err) {
				continue;
			}

			for( e in arrOnlineUsers ) {

				if ( arrOnlineUsers[e] == actUserId ) {
					arrPageUsers[i].className = 'ico-online';
					arrPageUsers[i].title = 'Felhasználó online';
					break;
				}

			}
		}

	}



	initAuthBox = function() {

		if ( ! document.getElementById('login_email') ) {
			return false;
		}

		document.getElementById('login_email').value = 'E-mail, felhasználónév';

		try	{
  			var ua = navigator.userAgent.toLowerCase();
			if(!((ua.indexOf('konqueror')!=-1) && (document.all ||
				(ua.indexOf('khtml/3.4')!=-1))) && !(((ua.indexOf('safari')!=-1) &&
				!window.print) || (document.defaultCharset && !window.print))) {
			    	changeInputType( document.getElementById('login_pwd'), 'text', 'Jelszó', false, true );
			}
		} catch (err) {}

		if ( typeof YAHOO == 'object' ) {
			YAHOO.util.Event.addListener( 'login_email', 'click', function() { if (this.value == 'E-mail, felhasználónév') this.value = ''; } );
			YAHOO.util.Event.addListener( 'login_email', 'focus', function() { if (this.value == 'E-mail, felhasználónév') this.value = ''; } );
			YAHOO.util.Event.addListener( 'login_pwd', 'click', function() { if (this.type == 'text') { this.value = ''; this.type = 'password' }} );
			YAHOO.util.Event.addListener( 'login_pwd', 'focus', function() { if (this.type == 'text') { this.value = ''; this.type = 'password' }} );
		}

	}

	//http://www.dynamicsitesolutions.com/javascript/dynamically-changing-input-type/
	changeInputType = function(
		oldElm, // a reference to the input element
		iType, // value of the type property: 'text' or 'password'
		iValue, // the default value, set to 'password' in the demo
		blankValue, // true if the value should be empty, false otherwise
		noFocus) {  // set to true if the element should not be given focus

		if ( ! oldElm || !oldElm.parentNode || (iType.length<4 ) ||
				!document.getElementById || !document.createElement) return;

		var newElm = document.createElement('input');
		//var newElm = oldElm.cloneNode( false );
		//newElm.value = '';
		newElm.type = iType;

		if(oldElm.name) newElm.name = oldElm.name;
		if(oldElm.id) newElm.id = oldElm.id;
		if(oldElm.className) newElm.className = oldElm.className;
		if(oldElm.size) newElm.size = oldElm.size;
		if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
		if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;

		newElm.onfocus = function() { return function() {
			if(this.hasFocus) return;

			var newElm = changeInputType(this,'password',iValue,
				(this.value.toLowerCase()==iValue.toLowerCase())?true:false);

			if(newElm) newElm.hasFocus=true;
		}}();

		newElm.onblur = function(){return function(){
			if(this.hasFocus) {
				if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
					changeInputType(this,'text',iValue,false,true);
				}
			}
		}}();

		// hasFocus is to prevent a loop where onfocus is triggered over and over again
		newElm.hasFocus=false;
		oldElm.parentNode.replaceChild(newElm,oldElm);
		if(!blankValue) newElm.value = iValue;

		if(!noFocus || typeof(noFocus)=='undefined') {
			window.tempElm = newElm;
			setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
		}

		return newElm;

	}

/*
	submitRegForm = function( mode ) {
		document.getElementById('regisztracio_mode').value = mode;
		document.getElementById('regisztracio_form').onsubmit();
		return false;
	}
*/

	//Profil adatmodositas
	displayWarnings = function() {

		if ( document.getElementById('profil__bemszem__email').value != document.getElementById('profil__bemszem__email_orig').value ) {
			var confrm = confirm( "FIGYELEM!\n\nAmennyiben megváltoztatod az e-mail címedet, a rendszer a felhasználói profilodat inaktív állapotúra állítja.\n\nEzért amíg nem aktiválod az e-mail címedet, addig nem tudsz majd belépni.\n\nA módosítás után a rendszer kiléptet.\n\nBiztos, hogy megakarod változtatni az e-mail címedet?" );

			if ( confrm == true ) {
				return true;
			} else {
				return false;
			}
		}
	}

	var bannernum = {};
	hideAds = function( mode ) {
		var arr = document.getElementsByTagName('iframe');

		for ( var i = 0, il = arr.length; i < il; i++ ) {
			if ( mode ) {
				if( ! bannernum[i] ) bannernum[i] = [arr[i].width,arr[i].height];
				arr[i].width = '0px';
				//arr[i].height = '1px';
			} else {
				try {
				arr[i].width = bannernum[i][0];
				//arr[i].height = bannernum[i][1];
				} catch (e) {}
			}
		}

		/*@cc_on
		if ( @_jscript_version < 5.7 ) {
			var arrSelect = document.getElementsByTagName('select');
			for ( var e = 0, el = arrSelect.length; e < el; e++) {

				if ( mode ) {
					arrSelect[e].style.visibility = 'hidden';
				} else {
					arrSelect[e].style.visibility = 'visible';
				}

			}
		}
		@*/

	}
	
	/* =========================== IE Spec =================================== */

	/* IE 6 & 7 */
	initVerticalAlignAjanloBox = function() {

		var aAjanloBoxes = getElementsByClassName(document, 'ul', 'boxajanlo');

		for	( var i = 0, il = aAjanloBoxes.length; i < il; i++ ) {

			var aInner = getElementsByClassName(aAjanloBoxes[i], 'span', 'inner');

			for (var e = 0, el = aInner.length; e < el; e++) {
				aInner[e].style.marginTop = 24 - Math.floor( aInner[e].offsetHeight / 2 ) + 'px';
			}

		}
	}

	/* IE6 */
	initAttrSbmtOver = function() {

		var aAttrSbmt = getElementsByClassName(document, 'input', 'attrsbmt');

		for ( var i = 0, il = aAttrSbmt.length; i < il; i++ ) {

			aAttrSbmt[i].onmouseover = function() {
				editClassName.add( this, 'attrsbmt_ieo' );
			}

			aAttrSbmt[i].onmouseout = function() {
				editClassName.remove( this, 'attrsbmt_ieo' );
			}

		}


		var aAttrBttn = getElementsByClassName(document, 'input', 'attrbttn');

		for ( var i = 0, il = aAttrSbmt.length; i < il; i++ ) {

			aAttrSbmt[i].onmouseover = function() {
				editClassName.add( this, 'attrbttn_ieo' );
			}

			aAttrSbmt[i].onmouseout = function() {
				editClassName.remove( this, 'attrbttn_ieo' );
			}

		}

		var aBigBttn = getElementsByClassName(document, 'button', 'bigbttn');

		for ( var i = 0, il = aBigBttn.length; i < il; i++ ) {

			aBigBttn[i].onmouseover = function() {
				editClassName.add( this, 'bigbttn_ieo' );
			}

			aBigBttn[i].onmouseout = function() {
				editClassName.remove( this, 'bigbttn_ieo' );
			}

		}

	}

	/* IE6 */
	initArrowBg = function() {

		/* CSS: .warrow_bg:hover .arrow_bg */
		var aWarrowBg = getElementsByClassName(document, 'a', 'warrow_bg');
		for ( var i = 0, il = aWarrowBg.length; i < il; i++ ) {

			aWarrowBg[i].onmouseover = function() {
				var aArrowBg = getElementsByClassName(this, '*', 'arrow_bg');
				editClassName.add( aArrowBg[0], 'arrow_bg_ieo' );
			}

			aWarrowBg[i].onmouseout= function() {
				var aArrowBg = getElementsByClassName(this, '*', 'arrow_bg');
				editClassName.remove( aArrowBg[0], 'arrow_bg_ieo' );
			}
		}

		/* Insert clearing divs */
/*
		var aBoxContent = getElementsByClassName(document, 'div', 'boxcontent');
		for( var i = 0, il = aBoxContent.length; i < il; i++ ) {

			//prnt.innerHTML = '<div class="ie_clr"></div>' + prnt.innerHTML;
			var div = document.createElement('div');
			div.className = 'ie_clr';

			aBoxContent[i].appendChild( div );
		}
*/
	}

	/* IE6 */
	initCikkep = function() {

		if ( ! document.getElementById('cikk_body') ) {
			return false;
		}

		var aCikkep = getElementsByClassName( document.getElementById('cikk_body'), 'img', 'cikkep' );

		for ( var i = 0, il = aCikkep.length; i < il; i++ ) {

			if ( aCikkep[i].align == 'left' ) {
				editClassName.add( aCikkep[i], 'cikkep_attrleft' );
			}

			if ( aCikkep[i].align == 'right' ) {
				editClassName.add( aCikkep[i], 'cikkep_attrright' );
			}
		}
        
        //Peti: a tablazatokat is igazitani kell
        var aCikkep = document.getElementsByTagName('table');

		for ( var i = 0, il = aCikkep.length; i < il; i++ ) {

			if ( aCikkep[i].align == 'left' && aCikkep[i].ClassName != 'cikkep_attrleft' ) {
				editClassName.add( aCikkep[i], 'cikk_txt_table_left' );                
			}

			if ( aCikkep[i].align == 'right' && aCikkep[i].ClassName != 'cikkep_attrright' ) {
				editClassName.add( aCikkep[i], 'cikk_txt_table_right' );                
			}
            
            if ( aCikkep[i].align == 'center' && aCikkep[i].ClassName != 'cikkep_attrright' ) {
				editClassName.add( aCikkep[i], 'cikk_txt_table_center' );                
			}
		}

	}

	addEvent(window, 'load', initPrintLink);
	addEvent(window, 'load', function() { initHideElements( "input", "hideit"); });
	addEvent(window, 'load', function() { JSTarget.init("rel","external"); });
	addEvent(window, 'load', equalCikkHeads);
	addEvent(window, 'load', equalBoxes);
	addEvent(window, 'load', initAjanloBoxes);
	addEvent(window, 'load', tabBox);

/*
	if ( typeof YAHOO == 'object' ) {
		//YAHOO.util.Event.onDOMReady( initAuthBox );
		YAHOO.util.Event.onContentReady( 'login_box', initAuthBox );
	}
*/

	/*@cc_on
	addEvent(window, 'load', initVerticalAlignAjanloBox);

	// 1024x768-ban az IE scrollbart jol leveszi (teljes kepernyon).
	if ( document.documentElement.clientWidth == 1020 ) {
		document.getElementsByTagName( 'html' )[0].style.overflowX = 'hidden';
	}

	addEvent(window, 'resize', function (){
		if ( document.documentElement.clientWidth == 1003 ) {
			document.getElementsByTagName( 'html' )[0].style.overflowX = 'hidden';
		} else {
			document.getElementsByTagName( 'html' )[0].style.overflowX = 'auto';
		}
	} );

	@*/

	/*@cc_on
	if ( @_jscript_version < 5.7 ) {
		addEvent(window, 'load', initCikkep);
		addEvent(window, 'load', initAttrSbmtOver);
	}
	@*/
    
    // Peti: beallitas kezdolap  
    function addHomePage() {
        //IE 6
        if ( false /*@cc_on || @_jscript_version < 5.7 @*/ ) {
            document.body.style.behavior='url(#default#homepage)';   
            document.body.setHomePage('http://www.nlcafe.hu');
        }else{        
            alert('Ha az NlCafét szeretnéd kedőlapként, húzd a fenti navigációs sávban lévő kis bögre ikont a házacskára!');
        }
        
    }
    
    
    

