function SetFontSize(val)
{
	var size = $('.loaded_text').css('font-size');

	if (size.length == 0)
		size = 12;
	else 
		size = size.substr(0,2);
	
	
	size = parseInt(size)+val;
	if (size > 18 || size <12)
		return;
		
	$('.loaded_text, table.text tr td, table.newstitle tr td, table.newstitle tr td font.cim').css('font-size', size);
	$('span.szoveg_kicsi, .laptetejediv').css('font-size', size-1);
	
}

function IncrementFontSize()
{
	SetFontSize(3);
}

function DecrementFontSize()
{
	SetFontSize(-3);
}

function user_login()
{
	if (!checkemail(document.getElementById('email').value))
	{
		window.alert('Hibás e-mail formátum!');
		return false;
	}
	
	document.loginform.submit();
	
	return false;
}

function _check_new_pass()
{
	var p1 = document.getElementById('new_password').value;
	var p2 = document.getElementById('new_password2').value;

	if (p1.length < 5)
	{
		window.alert('A választott jelszó túl rövid! Kérjük hogy legalább 5 karakter hosszú jelszót válasszon!');
		return false;
	}

	if ( p1 != p2 )
	{
		window.alert('A két új jelszó mező nem egyezik!');
		return false;
	}
	
	return true;
}

function user_changepass()
{
	if (_check_new_pass())	
		document.changepassform.submit();
	
	return false;
}

function user_forgottenpass()
{
	var e = document.getElementById('email').value;
	
	if (!checkemail(e))
	{
		window.alert('Hibás e-mail formátum!');
		return false;
	}
	
	document.forgottenpassform.sutmit();
	
	return false;
}

function user_newpass()
{

	if (_check_new_pass())
		document.newpassform.submit();
	
	return false;
}

function regform_validate()
{
	var n = document.getElementById('name').value;
	var e = document.getElementById('email').value;
	var p1 = document.getElementById('password').value;
	var p2 = document.getElementById('password2').value;
	
	
	if (n.length < 2)
	{
		window.alert('Túl rövid név! A név mezőnek minimum 2 karakter hosszúnak kell lennie!');
		return false;
	}
	if (n.length > 50)
	{
		window.alert('Túl hosszú név! A név mező maximum 2 karakter hosszú lehet!');
		return false;
	}
	if (!checkemail(e))
	{
		window.alert('Hibás e-mail formátum!');
		return false;
	}
	if (p1.length < 5)
	{
		window.alert('A választott jelszó túl rövid! Kérjük hogy legalább 5 karakter hosszú jelszót válasszon!');
		return false;
	}
	if (p1 != p2)
	{
		window.alert('A két jelszó mező nem egyezik meg!');
		return false;
	}
	
	document.regform.submit();
	return false;
}

function sendmsg()
{
	var w = document.getElementById('gb_writer');
	var e = document.getElementById('gb_email');
	var t = document.getElementById('gb_text');
	var vfy = document.getElementById('verify');

	if (w.value == '' || t.value == '')
	{
		window.alert('Üres a név vagy az üzenet mező!');
		return false;
	}
	
	if (w.value.match(/<*>/) || t.value.match(/<*>/))
	{
		window.alert('Nem megengedett karakter (< vagy >) használata!');
		return false;
	}
	
	if (e.value.length > 0 && !checkemail(e.value))
	{
		window.alert('Hibás e-mail cím formátum!');
		return false;
	}
	
	document.sendm.submit();
	return false;
}



function removeChildrenFromNode(e) {
  if(!e) {
	  return false;
  }
  if(typeof(e)=='string') {
	  e = document.GetElementById(e);
  }
  
  $(e).empty();
  return true;
}

var pics;

function runSlideshow(pre, album_id)
{
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.80;
	hs.allowSizeReduction = true;
	hs.autoplay = true;
	hs.wrapperClassName = 'highslide-wrapper';
	hs.slideshows = [];
	
	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .50,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});
	
	if (pics != undefined)
		removeChildrenFromNode(pics);
	
	var cont = $('#slideshowElements');
	cont.empty();
	
	$.getJSON(
		(pre == 'g' ? '../' : '') + 'functions/load_gallery.php?'+pre+'album_id='+encodeURIComponent(album_id),
		function(data)
		{
			link = document.createElement('a');
			link.href = data[0]["file"];
			link.id = "slideshowGallery";
			link.className = "highslide";
			link.onclick = function (event) { return hs.expand(this, { slideshowGroup: 1 }); };
			
			cont.append(link)
			
			pics = $('<div>').addClass('hidden-container');

			$(data).each(function(key, row)
			{
				if (key > 0)
				{
					tmp = document.createElement('a');
					tmp.className = "highslide";
					tmp.href = row["file"];
					tmp.onclick = function(event) { return hs.expand(this, { thumbnailId: 'slideshowGallery', slideshowGroup: 1 }) };
			
					pics.append(tmp);
					
				}
			});
			
			cont.append(pics);
			
			hs.expand(link, { slideshowGroup: 1 });
		}
	);
	/*
	new Ajax.Request((pre == 'g' ? '../' : '') + 'functions/load_gallery.php?'+pre+'album_id='+encodeURIComponent(album_id), 
	{
		method: 'get',
		asynchronous: true,
		
		onSuccess: function(ret)
		{
			data = eval('(' + ret.responseText + ')');
			
			link = document.createElement('a');
			link.href = data[0]["file"];
			link.id = "slideshowGallery";
			link.className = "highslide";
			link.onclick = function (event) { return hs.expand(this, { slideshowGroup: 1 }); };
			
			cont.appendChild(link)
			
			pics = document.createElement('div');
			pics.className = "hidden-container";

			
			data.each(function(row, key)
			{
				if (key > 0)
				{
					tmp = document.createElement('a');
					tmp.className = "highslide";
					tmp.href = row["file"];
					tmp.onclick = function(event) { return hs.expand(this, { thumbnailId: 'slideshowGallery', slideshowGroup: 1 }) };
			
					pics.appendChild(tmp);
					
				}
			});
			
			cont.appendChild(pics);
			
			hs.expand(link, { slideshowGroup: 1 });
		},
		onException: function(req, e)
		{
			window.alert("A diavetítő funkció jelenleg nem elérhető");
		},
		onFailure: function()
		{
			window.alert("A diavetítő funkció jelenleg nem elérhető");
		}
	});
	*/
}



function WindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return new Array(myWidth, myHeight);
}


function LapTetejereGomb(limit)
{
	Top = document.getElementById('posTop');
	Bottom = document.getElementById('posBottom');
	topY = findPosY(Top);
	bottomY = findPosY(Bottom);
	
	if ((bottomY - topY) > limit)
		document.getElementById('laptetejediv').innerHTML = '<a href=\"#top\">&laquo;Ugrás a lap tetejére&raquo;</a>';
}

function megnyit($kep) 
{
		window.open($kep,'img','resizable=yes,fullscreen,scrollbars=yes');
}

function findPosX(obj) {
  var curleft = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  } else if (obj.x) curleft += obj.x;
  return curleft;
}

function findPosY(obj) {
  var curtop = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  } else if (obj.y) curtop += obj.y;
  return curtop;
}

function showhide(id)
{
	obj = document.getElementById(id);
	if (obj.style.display == 'block')
	{
		obj.style.display = 'none';
	}
	else
	{
		obj.style.display = 'block';
	}
}

function changeMenu(id)
{
	
}

function checkemail(emailcim)
{
	var filter = /^[a-zA-Z0-9\.\-\_]+\@([a-zA-Z0-9\-\_]+\.)+[a-z]{2,4}$/i;
	return filter.test(emailcim);
}

getOP=function()
{
	OSName="Unknown OS";
	if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
	return OSName;
}

init=function()
{
	if (getOP() == "Windows")
	{
		document.getElementById('cimer').innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"120\" height=\"120\"> <param name=\"movie\" value=\"img/cimer.swf\" /> <param name=\"quality\" value=\"high\" /> <param name=\"wmode\" value=\"transparent\" /> <embed src=\"img/cimer.swf\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"120\" height=\"120\"></embed> </object>";
	}
}

WEBAUDIT=function() {
  this.WACID=null;
  this.WACIDName="WACID";

  this.getCookie=function(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;
  }

  this.setCookie=function(name,value,topDomain) {
    var date = new Date(2020,12,31,23,59,59);
    var expires = "; expires="+date.toGMTString();
    document.cookie = name+"="+value+expires+"; path=/; domain=" + topDomain;  
  }

  this.generateID=function(splitter) {
    var sp=(splitter) ? splitter : 'A';
    var now=new Date();
    return Date.parse(now.toGMTString()) + sp + Math.floor(Math.random()*1000000000);
  }

  this.getTopDomain=function(fullDomain) {
    var darabok=fullDomain.split('.');
    return darabok[(darabok.length-2)] + '.' + darabok[(darabok.length-1)];
  }

  this.getDomain=function(url) {
    var urlDarabok=url.split('/');
    return urlDarabok[2];
  }

  this.WACID=this.getCookie(this.WACIDName);
}

var same =  Math.floor(Math.random()*1000000);
var wa=new WEBAUDIT();
var felbontas = "";
var wa_url = "@u=";
var wa_referrer = "@r=";

if(wa.WACID==null)
{
  wa.WACID=wa.generateID('A');
  wa.setCookie(wa.WACIDName,wa.WACID,wa.getTopDomain(wa.getDomain(document.URL)));
}

same = same + "@c=" + wa.WACID;
if(screen) felbontas='@s='+screen.width+'x'+screen.height;
if(document.referrer) wa_referrer=wa_referrer+document.referrer;
if(document.URL) wa_url=wa_url+document.URL;
same = same + felbontas + wa_url + wa_referrer;