function showPhoto(pict, title, width, height) {
	if ((typeof(pwin) != 'undefined') && !pwin.closed) { pwin.close(); }
	
	if (!width || !height) {
		width  = 800;
		height = 600;
	};
	
	if (!title) { title = '' };
	
	pwin = window.open('','photo','width='+ width +', height='+ height +', directories=0, location=0, menubar=0, toolbar=0, status=0, resizable=0, scrollbars=0');
	pwin.document.open();
	pwin.document.write('<html><head><title>'+ title +'</title></head>');
	pwin.document.write('<body style="margin: 0px; padding: 0px; background-color: #000000;">');
	pwin.document.write('<img src="'+ pict +'" alt="bezár" width="'+ width +'" height="'+ height +'" border="0" onclick="window.close();" style="cursor: pointer;" />');
	pwin.document.write('</body></html>');		
	pwin.document.close();
}

function popup(url, name, width, height, menubar, status, toolbar, scrollbars, resizable, directories, location) {
	if ( !url ) return false;	
	
	if ((typeof(popupWindow) != 'undefined') && !popupWindow.closed) { popupWindow.close(); }
	
	if ( !name )   name = 'popupWin';
	if ( !width )  width = '';
	if ( !height ) height = '';
		
	if ( !directories ) directories = 0;
	if ( !location )    location = 0;
	if ( !menubar )     menubar = 0;
	if ( !status )      status = 0;
	if ( !toolbar )     toolbar = 0;
	if ( !scrollbars )  scrollbars = 0;
	if ( !resizable )   resizable = 0;
	
	var left = Math.round((screen.availWidth - width) / 2);
	var top  = Math.round((screen.availHeight - height) / 2);

  var param = 'width='+ width +', height='+ height +', left='+ left +', top='+ top +', screenX='+ left +', screenY='+ top +', directories='+ directories +', location='+ location +', menubar='+ menubar +', toolbar='+ toolbar +', status='+ status +', resizable='+ resizable +', scrollbars='+ scrollbars;

	popupWindow = window.open(url, name, param);	
}

function textRemaining(char_num, obj, num){
  var counter = (num) ? 'counter' + num : 'counter';
	
	if ((char_num - $F(obj).length) < 0) {
	  $(obj).value = $F(obj).substr(0, char_num);
	  $(counter).value = 0;	  
	} else {	  
	  $(counter).value = char_num - $F(obj).length;	  
	}	
}

function loadScript(file) {
  var js = document.createElement('script');
	
	js.setAttribute('text', 'text/javascript');
  js.setAttribute('language', 'javascript');
  js.setAttribute ('src', file);
  
	document.getElementsByTagName('head')[0].appendChild(js); 
}


/***************** FÓRUM *****************/
function dropTopicMsg(type) {
  if (type == 'topic') {
  	var response = window.confirm('Biztos, hogy törölni akarja a témát?\n\n(A témához tartozó összes üzenet törlődni fog!)');
  } else if (type == 'msg') {
    var response = window.confirm('Biztos, hogy törölni akarja az üzenetet?'); 	
	}
	
	if (response) {	
	  return true;
	} else {
	  return false;	
	}
}

/***************** USERS *****************/
function toggle_more_userdata() {
  if ($('rights_mud')) {
		if ($F('rights_mud') != 0) {		
			for (i = 0; i <= 13; i++) { $('rights_mud').up('tr').next(i).show(); }				
		} else {
			for (i = 0; i <= 13; i++) { $('rights_mud').up('tr').next(i).hide();	} 
		}
		
		if ($F('rights_mud') == 1) { $('club_tr').hide();	$('club_tr').next().hide(); }
	}
}

Event.observe(window, 'load', toggle_more_userdata);

/*************** ATHLETES ***************/
function toggle_athlete_tab(type) {
	if (type == 'main') {		
		$('main').show();
		$('profile').hide();
		$('pics').hide();
															
		$('publictab').down(0).className = '';
		$('publictab').down(1).className = '';
		$('publictab').down(2).className = '';
		$('publictab').down(0).addClassName('active');
		$('publictab').down(1).addClassName('noactive');
		$('publictab').down(2).addClassName('noactive');
		
		$('tabtype').value = 'main'		
	} else if (type == 'profile') {
		$('main').hide();
		$('profile').show();
		$('pics').hide();
		
		$('publictab').down(0).className = '';
		$('publictab').down(1).className = '';
		$('publictab').down(2).className = '';
		$('publictab').down(0).addClassName('noactive');
		$('publictab').down(1).addClassName('active');
		$('publictab').down(2).addClassName('noactive');
		
		$('tabtype').value = 'profile';
	} else if (type == 'pics') {
		$('main').hide();
		$('profile').hide();
		$('pics').show();
		
		$('publictab').down(0).className = '';
		$('publictab').down(1).className = '';
		$('publictab').down(2).className = '';
		$('publictab').down(0).addClassName('noactive');
		$('publictab').down(1).addClassName('noactive');
		$('publictab').down(2).addClassName('active');
		
		$('tabtype').value = 'pics';
	}
	
	if ($$('div.error_box')) { $$('div.error_box').each(function(n) { n.hide(); }); }
	
	return false;
}

/*************** PREENTRY ***************/
function toggle_preentry_tab(type) {
	if (type == 'main') {		
		$('main').show();
		$('entry').hide();
																	
		$('publictab').down(0).className = '';
		$('publictab').down(1).className = '';		
		$('publictab').down(0).addClassName('active');
		$('publictab').down(1).addClassName('noactive');		
	} else if (type == 'entry') {
		$('main').hide();
		$('entry').show();
				
		$('publictab').down(0).className = '';
		$('publictab').down(1).className = '';
		$('publictab').down(0).addClassName('noactive');
		$('publictab').down(1).addClassName('active');	
	}
	
	if ($$('div.error_box')) { $$('div.error_box').each(function(n) { n.hide(); }); }
	
	return false;
}

function nosubscribe_preentry_() {
  var form_ = $('editentry_form');
			
	$('action').value='back';
			
  form_.submit();	
	
	return false;
}

/*************** SEARCH ***************/
function change_category() {
	$('query_full').value = '';
	
	$$('#advanced input, #advanced select').each(function(n) { n.disable(); });
	
	$('searchfull_form').submit();
}
