function nopicsave()
	{
	alert('Amennyiben képekre van szüksége, kérjük szíveskedjen felvenni velünk a kapcsolatot a megadott elérhetőségek valamelyikén! Köszönjük!');
	return false;
	}

function shareContent(share, url)
	{
	share_url='';

	a = document.createElement('a');
	a.href = url ? url : document.location.href;

	url_href=a.href;
	url_pathname = a.pathname.indexOf('/')!=0 ? '/'+a.pathname : a.pathname ; /// IE hiba miatti '/' korrekció...
	url_search = a.search;

	if (share=='print')
		{
		openwindow('/misc/printpage.php?pageurl='+escape(url_pathname)+'&'+url_search.substring(1)+'&printpage=1', '720','450', 'yes');
		}
	else if (share=='email')
		{
		openwindow('/misc/sendbyemail.php?pageurl='+escape(url_pathname)+'&fullurl='+escape(url_pathname+url_search)+'&'+url_search.substring(1)+'&printpage=1', '629','323','no');
		}
	else if (share=='facebook')
		{
		share_url='http://www.facebook.com/share.php?u='+escape(url_href);
		}
	else if (share=='twitter')
		{
		share_url='http://twitter.com/home?status='+escape(url_href);
		}

	if (share_url) window.open(share_url);
	}


function catMenu(database_name,catrootid,cols,levels)
	{
	/// setup
	if (database_name=='setup')
		{
		$("DIV.cat_head_w,DIV.cat_head_n").hover(   /// set onmouseover/out
			function() {$(this).find("img").attr("src", $(this).find("img").attr("src").replace('.gif','_white.gif'));},
			function() {$(this).find("img").attr("src", $(this).find("img").attr("src").replace('_white.gif','.gif'));}
			);
		}
	/// load content and setup
	else if (!content_loaded['cat_menu'])
		{
		loadContent('cat_menu','database_name='+database_name+'&catrootid='+catrootid+'&cols='+cols+'&levels='+levels,0,'','',catMenu); /// load content
		}
	/// content has loaded, so set the content height and show for first time
	else if (content_loaded['cat_menu']==1)
		{
		$("#cat_menu").css('display','block').animate({height: $("#cat_menu_table").height()}, 500); /// show
		arrowimg=$("DIV.cat_head_w,DIV.cat_head_n").find("img");
		arrowimg.attr("src", arrowimg.attr("src").replace('cat+','cat-')); /// swap arrow
		content_loaded['cat_menu']=2; /// ...so we know we have been here...
		}
	/// toggle
	else
		{
		$("#cat_menu").slideToggle(500, function()
			{
			arrowimg=$("DIV.cat_head_w,DIV.cat_head_n").find("img");
			if ($(this).css("display")=='none')
				{
				arrowimg.attr("src", arrowimg.attr("src").replace('cat-','cat+'));
				}
			else
				{
				arrowimg.attr("src", arrowimg.attr("src").replace('cat+','cat-'));
				}
			});
		}
	}

function openwindow(pageurl,width,height,scroll,winname)
	{
	showscroll=(scroll!='yes' && scroll!=true) ? true : false;
	$("#bpopup_popup").html('<iframe src="'+pageurl+'" width="'+width+'" height="'+height+'" frameborder="no"></iframe><span class="bClose" style="display:none;"></span>');
	$("#bpopup_popup").openPopup({amsl:0, followSpeed:100, fadeSpeed: 500, scrollBar:showscroll, fixed:true, modalClose:true});
	}


content_loaded=Array();
newscript=Array();
function loadContent(contentid,contentparam,forcereload,outputid,lang,onloadfunct)
	{
	outputid=(outputid ? outputid : contentid);
	contentparam=contentparam ? contentparam : '';
	if (content_loaded[outputid]!=1 || forcereload==1)
		{
		if (lang=='en' || contentparam.indexOf('lang=en')!=-1)
			{
			loading_text='Loading...';
			}
		else if (lang=='de' || contentparam.indexOf('lang=de')!=-1)
			{
			loading_text='Loading...';
			}
		else
			{
			loading_text='Betöltés...';
			}
		document.getElementById(outputid).innerHTML='<br/><br/><center>'+loading_text+'</center>';

		content_loaded[outputid]=1;

		sitemapidparam=sitemap_id ? '&sitemap_id='+sitemap_id : '';
		contentidparam='&contentid='+contentid;
		langparam=lang ? '&lang='+lang : '';
		contenturl='/inc/functions/content_'+contentid+'.php?'+(contentparam.indexOf('contentid')==-1 ? sitemapidparam+contentidparam+langparam+'&' : '') + contentparam;

		if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();} else {	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		if (!xmlhttp && typeof xmlhttprequest!='undefined') {xmlhttp = new xmlhttprequest();}
		xmlhttp.onreadystatechange = function (e)
			{
			if (xmlhttp.readyState == 4)
				{
				content=xmlhttp.responseText;
				document.getElementById(outputid).innerHTML=content;
				if (onloadfunct) onloadfunct();
				}
			};
		xmlhttp.open('GET',contenturl,true);
		xmlhttp.send();
		}

	return true;
	}


function zoomimg() /// itt ezt nem használjuk
	{
	return false;
	}


function showGallery(img,database_name,database_id)
	{
	gallery_params=(typeof gallery_params==='undefined') ? '' : gallery_params;

	/// manuálisan meghívva
	if (database_name)
		{
		gallery_url='/gallery/gallery.php?'+gallery_params+'&database_name='+database_name+'&database_id='+database_id;
		}
	/// képre katt
	else
		{
		img=this;

		reg=/(id\=\d+\&ext\=[^&]+|id\=\d+|database_name\=.+\&database_id\=[^&]+)/g;
		imgid=reg.exec(img.src);

		reg2=/(http:\/\/[^\/]+)\//g;
		imgroot=reg2.exec(img.src);

		reg3=/\&type\=([^&]+)/g;
		imgtype=reg3.exec(img.src);
		imgtype=imgtype ? '&type='+imgtype[1] : '';

		if ((imgroot[1].indexOf('sport')!=-1)) /// saját kép?
			{
			gallery_url='/gallery/gallery.php?'+gallery_params+'&'+imgid[1]+imgtype+(img.src.indexOf('video')!=-1 ? '&media=video' : '');
			imgid=reg.exec(''); /// FF hiba miatt...
			imgroot=reg2.exec(''); /// FF hiba miatt...
			imgtype = reg3.exec(''); /// FF hiba miatt...
			}
		}
	window.open(gallery_url);
	///openwindow(gallery_url,1138,714,0,'gallery');
	///$("#bpopup_popup").html('<iframe src="'+gallery_url+'" width="1138" height="800" frameborder="no"></iframe><span class="bClose" style="display:none;"></span>');
	/// ez scroll nélküli: $("#bpopup_popup").openPopup({amsl:0, followSpeed:100, fadeSpeed: 500, scrollBar:true, fixed:true, modalClose:false, modalColor:'rgb(34,34,34)', opacity: 1.0});
	///$("#bpopup_popup").openPopup({amsl:0, follow:false, fadeSpeed: 500, scrollBar:true, fixed:false, modalClose:false, modalColor:'rgb(34,34,34)', opacity: 1.0});

	}


function doFilter()
	{
	querystr='?';

	for(i=0;i<doFilter_fieldnames.length;i++)
		{
		field=document.getElementsByName(doFilter_fieldnames[i])[0];
		querystr+='&'+doFilter_fieldnames[i]+'='+field.value;
		}

	document.location=querystr;
	}


function doABC(letter)
	{
	document.getElementsByName('letter')[0].value=letter;
	doFilter();
	return void(0);
	}


news_active='top';

function news(action,box)
	{
	if(box=='ew')
		{
		if (news_active==action)
			{
			if (action=='top')
				{
				document.location=top_url;
				}
			else
				{
				document.location=fresh_url;
				}
			}		
		}
	document.getElementById(box).className='news_'+action+' most';
	document.getElementById(box+'_'+news_active).style.display='none';
	news_active=action;
	document.getElementById(box+'_'+news_active).style.display='block';
	}

/// basket
function basket(action,item_type,item_id,item_url,redirect)
	{
	action=action ? action : 'read';
	item_type=item_type ? item_type : '';
	item_id=item_id ? item_id : '';
	item_url=item_url ? item_url : item_id!='' ? encodeURIComponent(window.location) : '';
	redirect=((redirect==undefined && action!='read') || redirect==1) ? encodeURIComponent(window.location) : redirect ? redirect : '';

	if (action!='delete' || confirm('Biztosan törölni szeretné a kosár tartalmát?'))
		{
		document.location='/kosar/?action='+action+'&item_type='+item_type+'&item_id='+item_id+'&item_url='+item_url+'&redirect='+redirect;
		}
	}


/// favourites
function favourites(action,item_type,item_id,item_url,redirect)
	{
	action=action ? action : 'read';
	item_type=item_type ? item_type : '';
	item_id=item_id ? item_id : '';
	item_url=item_url ? item_url : item_id!='' ? encodeURIComponent(window.location) : '';
	redirect=((redirect==undefined && action!='read') || redirect==1) ? encodeURIComponent(window.location) : redirect ? redirect : '';

	if (action=='send')
		{
		openwindow('/misc/sendbyemail.php?mailtype=favourites&pageurl=/kedvencek/&fullurl=/kedvencek/', '629','323','no');
		}
	else
		{
		if (action=='delete' && ((item_id && !confirm('Biztosan törölni szeretné ezt az elemet a kedvencek közül?')) || (!item_id && !confirm('Biztosan törölni szeretné a kedvenceket?'))))
			{
			return;
			}
		document.location='/kedvencek/?action='+action+'&item_type='+item_type+'&item_id='+item_id+'&item_url='+item_url+'&redirect='+redirect;
		}
	}


/// magazin scroll in right column...
magazin_scroll_pos=0;
function magazin_scroll(dir,magazin_id)
	{
	magazin_scroll_pos_new=Math.max(0, magazin_scroll_pos+dir);
 	$.post('/inc/functions/content_magazin_scroll.php', {magazin_scroll_pos: magazin_scroll_pos_new, magazin_id: magazin_id}, function(data)
		{
		if (data)
			{
			magazin_scroll_pos=magazin_scroll_pos_new;
			$("#magazin_scroll").html(data);
			}
		});
	}


/// promo box, váltás és automata lapozás
tabserial_current = new Array();
tabtimer = new Array();
changePromo = function(id,tabserial)
	{
	if (tabserial===0) /// init auto cycle
		{
		/// if at least 2 tabs exist
		if ($("#"+id+"_legend2").html() || $("#"+id+"_tab2").html())
			{
			$("#"+id).mouseleave(function() {tabtimer[id]=setInterval('changePromo(\''+id+'\')', 5500);}).mouseleave();
			$("#"+id).mouseenter(function() {clearInterval(tabtimer[id]);});
			changePromo(id,1);
			return;
			}
		 /// only 1 tab, init that now
		else
			{
			tabserial=1;
			}
		}
	else if (tabserial===undefined) /// auto cycle
		{
		tabserial=tabserial_current[id]+1;
		if (!$("#"+id+"_legend"+tabserial).html() && !$("#"+id+"_tab"+tabserial).html()) tabserial=1;
		}
	else if (tabserial==tabserial_current[id]) /// no action
		{
		return;
		}

	if (tabserial_current[id])
		{
		$("#"+id+"_tab"+tabserial_current[id]).addClass('inactive').removeClass('active');
		$("#"+id+"_img"+tabserial_current[id]).fadeTo(700,0);
		$("#"+id+"_legend"+tabserial_current[id]).css('display','none');
		}

	$("#"+id+"_tab"+tabserial).removeClass('inactive').addClass('active');
	$("#"+id+"_img"+tabserial).fadeTo(1500,1);
	$("#"+id+"_legend"+tabserial).css('display','block');

	if ($("#"+id+"_legend1").html())
		{
		$("#"+id+"_legend"+tabserial+", #"+id+"_img"+tabserial).click(function()
			{
			linkattr=$("#"+id+"_legend"+tabserial).attr('link');
			if (linkattr.indexOf('/')===0)
				{
				document.location=linkattr;
				}
			else
				{
				$.globalEval(linkattr);
				}
			});
		}

	tabserial_current[id]=tabserial;
   	}


processing_map_id=0;
function showMap(id)
	{
	if (id && !content_loaded['map_'+id]) /// load map
		{
		processing_map_id=id;
		loadContent('map', 'id='+id, 0, 'map_'+id, '', showMap); /// load content
		}
	else if (processing_map_id) /// setup the loaded map
		{
		/// create map and markers
		$('#map_area_'+processing_map_id).goMap(
			{
			maptype: 'ROADMAP',
			mapTypeControlOptions: {position: 'TOP_RIGHT',style:'DROPDOWN_MENU'},
			markers: [{id:map_markers[processing_map_id]['id'],latitude:map_markers[processing_map_id]['lat'],longitude:map_markers[processing_map_id]['lng'],title:map_markers[processing_map_id]['title']}]
			});
		$.goMap.fitBounds();
		$.goMap.createListener({type:'marker', marker:map_markers[processing_map_id]['id']}, 'click', function() {document.location=map_markers[$(this).data('id')]['url'];});

		/// setup the hide button
		$("#map_toggle_"+processing_map_id).click(
			function()
				{
				$(this).parent().slideUp(500);
				$(this).parent().find("[id^='map_area_']").slideUp(500);
				});

		processing_map_id=0;
		}
	else /// show (already loaded) map
		{
		$('#map_div_'+id+',#map_area_'+id).slideDown(500);
		}
	}


function outboundClicks()
	{
	var owndomain = document.domain;
	$("A").each(function()
		{
		linkhref=$(this).attr("href");
		if (((owndomain!='' && linkhref.indexOf(owndomain)<0) || owndomain=='') && linkhref.indexOf('://')>0)
			{
			$(this).click(function()
				{
				_gaq.push(['_trackEvent', 'outbound', 'click', $(this).attr("href").substring(7)]);
				});
			}
		});
	}


function to_furl(r,isfullurl)
	{
	r = r.toLowerCase(r);
	r = r.replace(new RegExp('[\\s\_]', 'gi'),'-');
	r = r.replace(new RegExp('[áâä]', 'g'),'a');
	r = r.replace(new RegExp('[ÁÂÄ]', 'g'),'A');
	r = r.replace(new RegExp('ç', 'g'),'c');
	r = r.replace(new RegExp('Ç', 'g'),'C');
	r = r.replace(new RegExp('[éë]', 'g'),'e'); 
	r = r.replace(new RegExp('[ÉË]', 'g'),'E'); 
	r = r.replace(new RegExp('[íî]', 'g'),'i'); 
	r = r.replace(new RegExp('[ÍÎ]', 'g'),'I');
	///r = r.replace(new RegExp('', 'gi'),'n');                             
	r = r.replace(new RegExp('[óôöő]', 'g'),'o'); 
	r = r.replace(new RegExp('[ÓÔÖŐ]', 'g'),'O'); 
	r = r.replace(new RegExp('[úüű]', 'g'),'u');
	r = r.replace(new RegExp('[ÚÜŰ]', 'g'),'U');
	r = r.replace(new RegExp('[ý]', 'g'),'y'); 
	r = r.replace(new RegExp('[Ý]', 'g'),'Y');
	r = r.replace(new RegExp('-+', 'gi'),'-');
	r = r.replace(new RegExp('^-', 'gi'),'');
	r = r.replace(new RegExp('-$', 'gi'),'');
	if (isfullurl) /// "/" allowed
		{
		r = r.replace(new RegExp('[^/\\w-]', 'gi'),'');
		}
	else
		{
		r = r.replace(new RegExp('[^\\w-]', 'gi'),'');
		}
	return r; 
	}

/// onload
$(document).ready(function()
	{
	/// kattinthatóvá teszi a képeket
	$('IMG.showgallery, DIV.img_inline IMG, DIV.img_inline_left IMG, DIV.img_inline_right IMG, DIV.img_inline_center IMG').click(showGallery);

	/// képeket ne lehessen jobb klikkelni
	$("IMG").bind("contextmenu",function(e)
		{
		return false;
		});

	/// mérje a kifele mutató linkeket
	outboundClicks();

	/// ne lehessen másolni vagy kivágni
	$("BODY").bind("copy cut", function (e)
		{
		e.preventDefault();
		});
	});
