/* GLOBALIS VALTOZOK */
var OLDOVER = null;
var SETTIME = null;

/* ----------------- */

function imageview(img,w,h)
{
	var sw = screen.width;
	var sh = screen.height;
	var x = (sw-w)/2;
	var y = (sh-h)/2;
	if (w>sw || h>sh) sb='yes'; else sb='no';
	window.open("/process/imageview.php?img="+img,"bigwin","modal=yes,dialog=yes,scrollbars="+sb+",width="+w+",height="+h+",left="+x+", top="+y);
}

function createform(inputs, target)
{
	var obj = document.createElement("FORM");
	target.appendChild(obj);
	obj.method='post';
	obj.enctype='multipart/form-data';
	obj.encoding = "multipart/form-data";

	for (i=0;i<inputs.length;i++)
	{
		var	n = document.createElement("INPUT");
		n.type='hidden';
		n.name=inputs[i][0];
		n.value=inputs[i][1];
		obj.appendChild(n);
	}	
	return obj;
}

function isempty(str)
{
	var r = new RegExp("^[ .*]$");
	return (r.test(str) || str.length == '');
}

function iecheck()
{
	var pos = navigator.userAgent.indexOf("MSIE ");
	if (pos == -1) return false;
	var version = navigator.userAgent.substring(pos + 5);
	return (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)  || (version.indexOf("7") == 0)));
}

// PNG ALPHA CHANNEL IMG-RE //
function iepng_alphachannel(imgid,timg,size)
{
	if(iecheck())
	{
		d = document.getElementById(imgid);
		origsrc = d.src;
		d.src = timg;
		d.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + origsrc + "',sizingMethod='image')";
		d.width = size[0];
		d.height = size[1];
	}
}

// PNG ALPHA CHANNEL DIV BACKGROUND //
function iepng_alphachannelbg(divid,bgimg,size)
{
	d = document.getElementById(divid);
	d.style.width = size[0]+"px";
	d.style.height = size[1]+"px";
	if(iecheck())
	{
		d.style.backgroundImage = '';
		d.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bgimg + "',sizingMethod='image')";
	}
}

function emailchange(obj,cim,inner)
{
	d = document.getElementById(obj);
	r = new RegExp("#");
	n = new RegExp("\\*","g");
	cim = cim.replace(r,"@");
	cim = cim.replace(n,".");
	d.href = "mailto:"+cim;
	if(inner) d.innerHTML = cim;
}

function checkValidEmail(mailstr) {
	r = new RegExp("^[0-9a-zA-Z\\._\\-]{2,}@([0-9a-zA-Z_\\-]{2,}\\.){1,7}[a-zA-Z]{2,3}$");
	return r.test(mailstr);
}

function menuover(id)
{
	if(OLDOVER)
	{
		clearTimeout(SETTIME);
		document.getElementById(OLDOVER).style.display = "none";
	}
	
	if(id)
	{	
		document.getElementById(id).style.display = "block";	
	}
	OLDOVER = id;
}

function onlyover()
{
	clearTimeout(SETTIME);
}

function menuout()
{
	if(OLDOVER)
	{
			clearTimeout(SETTIME);
			SETTIME = setTimeout(realHide, 200);
	}
}

function realHide()
{
	if(OLDOVER) document.getElementById(OLDOVER).style.display = "none";
}

function swf_search()
{
	d = document.getElementsByTagName("DIV");
	r = new RegExp("^flash_[0-9]+$");
	for(var i = 0; i<d.length; i++)
	{
		if(r.test(d[i].id))
		{
			path = d[i].innerHTML;
			w = d[i].style.width.replace("px","");
			h = d[i].style.height.replace("px","");
			swf_insert(d[i].id,path,w,h);
		}
	}
}

function swf_insert(to,flash,w,h)
{
	var addflash='';
	addflash+='<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="'+w+'" height="'+h+'">';
	addflash+='<param name="movie" value="'+flash+'">';
	addflash+='<param name="quality" value="high">';
	addflash+='</object>';
	if (!iecheck()) 
	{
		addflash+='<object data="'+flash+'" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'">';
		addflash+='<param pluginurl="http://www.macromedia.com/go/getflashplayer">';
		addflash+='<param name="quality" value="high">';
		addflash+='</object>';
	}
	document.getElementById(to).innerHTML=addflash;
}

function chk_search() {
	if(isempty(document.getElementById('search').value)) {
		alert('Nem adta meg a kulcsszót!');	
	} else {
		document.searchform.submit();	
	}
}

function getAjax()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				//A böngésző nem támogatja az ajaxot
				return false;
			}
		}
	}
	return xmlHttp;
}

function get_cat(id) {		
		var xmlHttp = new getAjax();
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState==4)
			{
				document.getElementById('kategorias').innerHTML = xmlHttp.responseText;
			}
		}
		
		xmlHttp.open("POST","/process/kapcsolat_getcat.php",true);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=iso-8859-2");
		xmlHttp.setRequestHeader("Request-type","XMLHttpRequest");		
		if (xmlHttp.overrideMimeType)	xmlHttp.setRequestHeader("Connection","close");
		querystr = "id="+id;
		xmlHttp.send(querystr);			
}

function send_kapcsolat() {
	if(isempty(document.kapcsolatform.nev.value)) {
		alert('Nem adta meg a nevét!');	
	} else if(isempty(document.kapcsolatform.cegnev.value)) {
		alert('Nem adta meg a cég nevét!');
	} else if(!checkValidEmail(document.kapcsolatform.email.value)) {
		alert('Nem megfelelő e-mail cím formátum!');
	} else if(isempty(document.kapcsolatform.telefon.value)) {
		alert('Nem adta meg a telefonszámát!');
	} else if(isempty(document.kapcsolatform.uzenet.value)) {
		alert('Nem írt üzenetet!');
	} else {
		nev = document.kapcsolatform.nev.value;
		cegnev = document.kapcsolatform.cegnev.value;
		telefon = document.kapcsolatform.telefon.value;
		email = document.kapcsolatform.email.value;
		uzenet = document.kapcsolatform.uzenet.value;
		kod = document.kapcsolatform.kod.value;
		
		document.getElementById('kapcs_gomb').style.display = 'none';
		document.getElementById('kapcs_indicator').style.display = 'block';
		
		var xmlHttp = new getAjax();
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState==4)
			{
				if(xmlHttp.responseText) {
					alert('Helytelen ellenőrző kód!');
				} else {
					document.kapcsolatform.nev.value = '';
					document.kapcsolatform.cegnev.value = '';
					document.kapcsolatform.telefon.value = '';
					document.kapcsolatform.email.value = '';
					document.kapcsolatform.uzenet.value = '';
					document.kapcsolatform.kod.value = '';
					document.getElementById('kapcs_indicator').style.display = 'none';
					document.getElementById('kapcs_kesz').style.display = 'block';
				}
			}
		}
		
		xmlHttp.open("POST","/process/kapcsolat_send.php",true);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=iso-8859-2");
		xmlHttp.setRequestHeader("Request-type","XMLHttpRequest");		
		if (xmlHttp.overrideMimeType)	xmlHttp.setRequestHeader("Connection","close");
		querystr = "nev="+nev+"&cegnev="+cegnev+"&email="+email+"&uzenet="+uzenet+"&kod="+kod+"&telefon="+telefon;
		xmlHttp.send(querystr);	
	}
}

function new_kep() {
	szam = Math.floor(Math.random()*100);
	document.getElementById('kepkod').src = 'process/captcha.php?width=100&height=25&characters=6&valami='+szam;	
}

function show_person(person) {
	document.getElementById('csopkep').src = 'images/cskep/'+person+'.jpg';	
}

function restore_person() {
	document.getElementById('csopkep').src = 'images/csoportkep.jpg';	
}

function imgpre() {
	var ims = new Array ("images/cskep/fodorne.jpg", "images/cskep/horvathlajos.jpg", "images/cskep/meszarosagnes.jpg", "images/cskep/palinkas.jpg", "images/cskep/szendirobert.jpg", "images/cskep/vanhallkaroly.jpg"); 
	var i; 
	for (i=0; i<ims.length; i++) { 
		var img = new Image(); img.src = ims[i]; 
	}
	restore_person();
}