String.prototype.trim = function() {
return this.replace(/(^\s+)|(\s+$)/g, "");
}

// Cookie kezelő függvények - http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

var IE = document.all?true:false

function newwindow(url,w,x,y) {
    window.open(url,w,'width='+x+',height='+y+',scrollbars=1,status=0,menubar=1,location=0,resizable=1')
    return false;
}

function popup_window(url,w,x,y) {
    window.open(url,w,'width='+x+',height='+y+',scrollbars=1,status=0,menubar=0,location=0,resizable=1')
    return false;
}

function link(url,x,y) {
    window.open(url,"",'width='+x+',height='+y+',scrollbars=0,status=0,menubar=0,location=0,resizable=1')
}

function wo(url,w,x,y) {
    if (!x) { x=500; }
    if (!y) { y=460; }
    window.open(url,w,'width='+x+',height='+y+',scrollbars=yes,status=0,menubar=0,location=0,resizable=1');
    return false;
}

function emailcimjoe(emilcim) {
    a=emilcim.indexOf('@');
    b=emilcim.indexOf('.',a);
    if(a>0 && b>0 && b>a+1 && b<emilcim.length-1) return true;
    else return false;
}


function getParent(obj,tagname) {
    var p = 0;
	if(!obj) return false;
	if(obj.tagName=='BODY') return false;
	p = obj.parentNode;
	if(!p) return false;
	var p1 = null;
    if(p.tagName==tagname) return p;
	while(p.tagName!='BODY' && p.parentNode) {
		p1 = p.parentNode;
		if(p1.tagName==tagname) return p1;
        p = p1;
		p1 = null;
    }
    return null;
}

function tabHandler(tabprefix, handlerprefix) {
	this.tabprefix = tabprefix;
	this.handlerprefix = handlerprefix;
	this.currenttab = 0;
	this.switchTab = tabHandler_switchTab;
}

function tabHandler_switchTab(tab) {
	if(document.all) {
		var ct = document.all[this.tabprefix+'_'+this.currenttab];
		var ch = document.all[this.handlerprefix+'_'+this.currenttab];
		var ot = document.all[this.tabprefix+'_'+tab];
		var oh = document.all[this.handlerprefix+'_'+tab];
	} else {
		var ct = document.getElementById(this.tabprefix+'_'+this.currenttab);
		var ch = document.getElementById(this.handlerprefix+'_'+this.currenttab);
		var ot = document.getElementById(this.tabprefix+'_'+tab);
		var oh = document.getElementById(this.handlerprefix+'_'+tab);
	}
	ct.style.display = 'none';
	ot.style.display = 'block';
	ch.style.zIndex = 100-this.currenttab;
	ch.style.fontWeight = 'normal';
	oh.style.fontWeight = 'bold';
	oh.style.zIndex = '1000';
	this.currenttab = tab;

// bojti: Tab váltáskor a cikkszerkesztőben tenni kell néhány ellenőrzést, hogy a page_title és a meta_description 
// mezők fölvegyék az alapértelmezett értékeket, ha még nincsenek kitöltve, és talán meg is kell vágni őket.
	if(document.getElementById('tab_6').style.display == 'block') {
		title_and_description();
	}

}

function title_and_description() {
        //csatornaid hack miatt...
	title_and_description_ajax();
}

/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function ismaxlength(obj){
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : "";
	if (obj.getAttribute && obj.value.length > mlength)
		obj.value = obj.value.substring(0,mlength);
}


function kepeslap_textarea() {
	if (document.getElementById('szoveg').value.length > 430) { 
		document.getElementById('szoveg').value = document.getElementById('szoveg').value.substr(0,430); 
		alert('A képeslap szövege maximum 430 karakter lehet!'); 
	} else { 
		document.getElementById('meg_n_karakter').innerHTML = (430-document.getElementById('szoveg').value.length); 
	}
}


function form2array(formname) {
	var f = document.forms[formname];
	if(!f) return false;
	var j = false;
	var arr = new Object;
	for(i in f.elements) {
		j = f.elements[i];
		if(!j || !j.type) continue;
		switch(j.type) {
			case "text":
			case "textarea":
			case "hidden":
				arr[j.name] = j.value;
				break;

			case "checkbox":
			case "radio":
				if(j.checked) arr[j.name] = j.value;
				else arr[j.name] = "";
				break;

			case "select-one":
				arr[j.name] = j.value;
				break;

			case "select-multiple":
				var arr2 = new Array;
				for(ii=0; ii<j.options.length; ii++) {
					jj = j.options[ii];
					if(jj.selected) arr2[arr2.length] = jj.value;
				}
				arr[j.name] = arr2;
		}
	}
	return arr;
}

/*common cuccok*/
function setOpacity(obj,b){
    b = b*20;
    if(b<0){b=0;} if(b>100){b=100;}
    var c=b/100;
    var d=document.getElementById(obj);
    if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
    if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
    if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
    if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}

function isValid(string,allowed) {
    for (var i=0; i< string.length; i++) {
		if (allowed.indexOf(string.charAt(i)) != -1)
		return false;
    }
	return true;
}

function getAbsoluteY(obj) {
	var parentY = 0;
	if(obj && obj.offsetParent) parentY = getAbsoluteY(obj.offsetParent);
	return obj.offsetTop+parentY;
}

function getAbsoluteX(obj) {
	var parentX = 0;
	if(obj && obj.offsetParent) parentX = getAbsoluteX(obj.offsetParent);
	return obj.offsetLeft+parentX;
}

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var mouseX = 0
var mouseY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
  	try {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  	} catch(err) {}
  } else {  // grab the x-y pos.s if browser is NS
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  // document.Show.MouseX.value = mouseX
  // document.Show.MouseY.value = mouseY
  return Array(mouseX, mouseY);
}

function Fly_start() {
	this.state = 1;
	this.frame = 0;
	this.obj.style.visibility = 'visible';
	this.distance = Math.sqrt((this.start_x-this.end_x)*(this.start_x-this.end_x)+(this.start_y-this.end_y)*(this.start_y-this.end_y));
	this.steps = Math.ceil(this.distance/this.speed);
	this.vx = Math.round((this.end_x-this.start_x)/this.steps);
	this.vy = Math.round((this.end_y-this.start_y)/this.steps);
	this.obj.style.left = this.start_x+'px';
	this.obj.style.top = this.start_y+'px';
	this.top = this.start_y;
	this.left = this.start_x;
	a = this;
	this.timer = window.setInterval(new Function('a.run(a)'), this.interval);
}

function Fly_stop() {
	this.obj.style.visibility = 'hidden';
	this.state = 0;
	clearInterval(this.timer);
}

function Fly_run(a) {
	a.frame++;
	if(a.frame>=a.steps) {
		a.stop();
		return;
	}
	a.left = a.left+a.vx;
	a.top = a.top+a.vy;
	a.obj.style.left = a.left+'px';
	a.obj.style.top = a.top+'px';
}

function Fly(start_x, start_y, end_x, end_y) {
	this.interval = 10;
	this.start_x = start_x;
	this.end_x = end_x;
	this.start_y = start_y;
	this.end_y = end_y;
	this.repeat = false;
	this.speed = 30;
	this.state = 0;
	this.distance = 0;
	this.obj = false;
	this.frame = 0;
	this.vx = 0;
	this.vy = 0;
	this.top = 0;
	this.left = 0;


	this.run = Fly_run;
	this.st = Fly_start;
	this.stop = Fly_stop;
}

	function Animation_start() {
		this.state = 1;
		a = this;
		this.timer = window.setInterval(new Function('a.run(a)'), 1000/this.framerate);
	}

	function Animation_stop() {
		this.state = 0;
		clearInterval(this.timer);
	}

	function Animation_run(a) {
		if(a.frame>=a.images.length) {
		  if(!a.repeat) a.stop();
		  a.frame = 0;
		}
		if(a.frame>0) a.images[a.frame-1].style.display = 'none';
		else a.images[a.images.length-1].style.display = 'none';
		a.images[a.frame].style.display = 'inline';
		a.frame++;
	}

	function Animation_preload() {
		var i=0;
		var tmp = false;
		var tmpimage = false;
		while(i<1000 && document.getElementById(this.image+i)) {
			tmp = document.getElementById(this.image+i);
			tmpimage = new Image();
			tmpimage.src = tmp.src;
			this.images[i] = tmp;
			i++;
		}
	}

	function Animation() {
	  this.framerate = 15;
	  this.repeat = false;
	  this.images = new Array();
	  this.timer = false;
	  this.state = 0;  // 0: stopped, 1: running
	  this.frame = 0;
		this.image = false;

	  this.st = Animation_start;
	  this.stop = Animation_stop;
	  this.run = Animation_run;
	  this.preload = Animation_preload;
	}

/*font meret*/
var font_size = 12;
var MAX = 24;
var MIN = 11;

function setFont(num){
  font_size += num;
 if(font_size > MAX){
      font_size = MAX;
 }
 if(font_size < MIN) {
      font_size = MIN;
 }
var oParagraphDiv = document.getElementById("cikkMain");
 oParagraphDiv.style.fontSize = font_size + "px";
 for (j = 0; j < oParagraphDiv.childNodes.length; j++){
  var oP = oParagraphDiv.childNodes[j];
  if ((oP.nodeName == "P") || (oP.nodeName == "A")){
    oP.style.fontSize = font_size + "px";
  }
 }
}

// Cookie osztaly
// HTTP.Cookies - Burak G?rsoy <burak[at]cpan[dot]org>
if (!HTTP) var HTTP = {}; // create base class if undefined

HTTP.Cookies = function () { // HTTP.Cookies constructor
   this.JAR = ''; // data cache
}

HTTP.Cookies.VERSION = '1.01';

HTTP.Cookies.Date = function () { // expire time calculation class
   this.format = {
   's' : 1,
   'm' : 60,
   'h' : 60 * 60,
   'd' : 60 * 60 * 24,
   'M' : 60 * 60 * 24 * 30,
   'y' : 60 * 60 * 24 * 365
   };
}

HTTP.Cookies.Date.prototype.parse = function (x) {
   if(!x || x == 'now') return 0;
   var date = x.match(/^(.+?)(\w)$/i);
   var of = 0;
   return (this.is_num(date[1]) && (of = this.is_date(date[1],date[2]))) ? of : 0;
}

HTTP.Cookies.Date.prototype.is_date = function (num, x) {
   if (!x || x.length != 1) return 0;
   var ar = [];
   return (ar = x.match(/^(s|m|h|d|w|M|y)$/) ) ? num * 1000 * this.format[ar[0]] : 0;
}

HTTP.Cookies.Date.prototype.is_num = function (x) {
   if (x.length == 0) return;
   var ok = 1;
   for (var i = 0; i < x.length; i++) {
      if ("0123456789.-+".indexOf(x.charAt(i)) == -1) {
         ok--;
         break;
      }
   }
   return ok;
}

HTTP.Cookies.prototype.date = new HTTP.Cookies.Date; // date object instance

// Get the value of the named cookie. Usage: password = cookie.read('password');
HTTP.Cookies.prototype.read = function (name) {
   var value  = '';
   if(!this.JAR) {
		this.JAR = {};
      var array  = document.cookie.split(';');
      for (var x = 0; x < array.length; x++) {
         var pair = array[x].split('=');
         if(pair[0].substring (0,1) == ' ') pair[0] = pair[0].substring(1, pair[0].length);
         if(pair[0] == name) {
            value = pair[1];
         }
         this.JAR[pair[0]] = pair[1];
      }
   } else {
      for(var cookie in this.JAR) {
         if(cookie == name) {
            value = this.JAR[cookie];
         }
	   }
   }
   return value ? unescape(value) : '';
}


// Create a new cookie or overwrite existing. Usage: cookie.write('password', 'secret', '1m');
HTTP.Cookies.prototype.write = function (name, value, expires, path, domain, secure) {
   var extra = '';
   if (!expires) expires = '';
   if (expires == '_epoch') {
      expires = new Date(0);
   } else if (expires != -1) {
      var Now  = new Date;
      Now.setTime(Now.getTime() + this.date.parse(expires));
      expires = Now.toGMTString();
   }
   if(expires) extra += "; expires=" + expires;
   //if(path   )
   extra += "; path=/";
   if(domain ) extra += "; domain="  + domain;
   if(secure ) extra += "; secure="  + secure;
   document.cookie = name + "=" + escape(value) + extra;
}

// Delete the named cookie. Usage: cookie.remove('password');
HTTP.Cookies.prototype.remove = function (name, path, domain, secure) {
   this.write(name, '', '_epoch', path, domain, secure);
}


/*osztalyok vege*/

function insertEmotion(file_name, title) {
        title = tinyMCE.getLang(title);

        if (title == null)
        title = "";

        // XML encode
        title = title.replace(/&/g, '&amp;');
        title = title.replace(/\"/g, '&quot;');
        title = title.replace(/</g, '&lt;');
        title = title.replace(/>/g, '&gt;');

        var html = '<img src="' + tinyMCE.baseURL + "/plugins/emotions/images/" + file_name + '" mce_src="' + tinyMCE.baseURL + "/plugins/emotions/images/" + file_name + '" border="0" alt="' + title + '" title="' + title + '" />';

        tinyMCE.execCommand('mceInsertContent', false, html);
    }


function insertEmotion_v3(file_name, title) {

        if (title == null)
        title = "";

        // XML encode
        title = title.replace(/&/g, '&amp;');
        title = title.replace(/\"/g, '&quot;');
        title = title.replace(/</g, '&lt;');
        title = title.replace(/>/g, '&gt;');

        var html = '<img src="/js/tiny_mce/plugins/emotions/images/' + file_name + '" mce_src="/js/tiny_mce/plugins/emotions/images/' + file_name + '" border="0" alt="' + title + '" title="' + title + '" />';

        tinyMCE.execCommand('mceInsertContent', false, html);
    }


/* sok checkbox egyszerre kijelölésére. az id a checkboxok parentNodeja (többnyire form id) */
function checkAllField (id, t) {
	
	var checked = (t.checked) ? true : false;
	
	var el = document.getElementById(id).childNodes;
	
	for (var i = 0; i < el.length; i++) {
		if (el[i].nodeType == 1) el[i].checked = checked;
	}
}

function jelszo_ellenor(pass, white){
			var a;
			var c=1;
			var b=0;
			var d=0;
			var tmp;
			var numb_db=0;
			var bet_db=0;
			var spec_db=0;
			var betuk = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's' , 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ö', 'ü', 'ó', 'ű', 'ő', 'ú', 'é', 'á', 'í']; 
			var spec = ['&#33','%','=','<','>','#','&',',','@',';',':','-',''];
			var spec2 = ['%','=','<','>','#','&',',','@',';',':','-'];
			//rossz: *, |, +
			var kimenet;
			
			//hossz
			a=pass.length;
			
			if(a>4){
				//betu-szam eloszlas
				var i=0;
				while(i<betuk.length && bet_db<1){
					if(pass.search(betuk[i])>-1){
						bet_db++;
					}
					i++;
				}
				var i=0;
				while(i<10 && numb_db<1){
				//for(var i=0; i<10; i++){
					if(pass.search(i)>-1){
						numb_db++;
					}
					i++;
				}
				
				if(bet_db!=0 && numb_db!=0){
					b=1;
				}
				
				//speci karakterek
				var i=0;
				while(i<spec.length-1 && spec_db<1){
				//for(var i=0; i<spec.length; i++){
					if(pass.search(spec[i])>-1){
						spec_db++;
					}else if(pass.indexOf('+')>-1){
						spec_db++;
					}else if(pass.indexOf('|')>-1){
						spec_db++;
					}else if(pass.indexOf('*')>-1){
						spec_db++;
					}
					i++;
				}
				//alert(spec[i-1]+'  '+spec_db);
				
				if(spec_db!=0){
					d=1;
				}
				
				//kisbetu-nagybetu
				tmp=pass.toLowerCase();
				if(pass.search(tmp)>-1){
					c=0; 
				}
				tmp=pass.toUpperCase();
				if(pass.search(tmp)>-1){ 
					c=0; 
				}
				
				kimenet= Math.min(1, ((a-4)/4)*(1+b+c+d)/4);
			
			}else{
				kimenet=0;
			}
			//alert('A='+a+' B='+b+' C='+c+' D='+d+' Kimenet='+ kimenet + 'pötty='+Math.round(kimenet*11));
			if(white) return('/static/imgs/jelszo_ertekelo/w_jelszo'+(Math.round(kimenet*11)+1)+'.gif');
			else return('/static/imgs/jelszo_ertekelo/jelszo'+(Math.round(kimenet*11)+1)+'.gif');
}

function tvpopup(what) {
	width=560;
	height=680;
	LeftPosition=(screen.width)?(screen.width-width)/2:200;
	TopPosition=(screen.height)?(screen.height-height)/2:100;
	winp = open (what, 'tvpopoup', "menubar=no, resizable=1, scrollbars=1, top="+TopPosition+", left="+LeftPosition+", status=no, titlebar=no, toolbar=no, width="+width+", height="+height);
	winp.focus();
} 