function atkapcsolas(mezo){
var mezoid='#'+mezo;

if ($(mezoid).is(":visible"))
  $(mezoid).hide();
else
  $(mezoid).show();

return false;
};

function atkapcsolas_vis(mezo){
if (document.getElementById(mezo).style.visibility=='hidden')
   document.getElementById(mezo).style.visibility='visible';
 else
   document.getElementById(mezo).style.visibility='hidden';
 return false;
};



function fldCheck(field,len,tx){

 if ($('#'+field).val().length<len){
   alert(tx);
   return false;
 }
 return true; 
}

function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) 
			return false;
		return true;
};

function c2input(div,url,field,width,id){
 cont=div+"_cont";
 vl=document.getElementById(cont).innerHTML;
 document.getElementById(div).innerHTML='<form method=post action='+url+'><input name=form_id type=hidden value=\"' +id + '\"><input type=text id='+field+' name='+field+' size='+ width+ ' value=\"' +vl + '\"></form>';
 document.getElementById(field).focus();
 return false;
};








var schat_start=0;

function schatscroll(qq)
{
   schat_start=schat_start+qq;

  if (schat_start<0)
    schat_start=0;
  if (schat_start>1000)
    schat_start=1000;

  ajax('schatbox',AJAX_URL + '_schat.php?start='+schat_start+'&szoveg=');
//  chat_start=parseInt(document.getElementById("qw").value);
  return false;
};

function schatfunc()
{
  c=document.getElementById("szvg").value;
  schat_start=0;
  ajax('schatbox',AJAX_URL + '_schat.php?start=0&szoveg='+c);
  document.getElementById("szvg").value="";
  return false;
};



function showschatBox()
{
  ajax('schatbox',AJAX_URL + '_schat.php?start='+schat_start+'&szoveg=');
  setTimeout("showschatBox()",6000);
  return false;

};


function supportBox()
{
  ajax('supportbox',AJAX_URL + '_support.php?start='+schat_start+'&szoveg=');
  setTimeout("supportBox()",10000);
  return false;

};

var supportid=0;
function support(as)
{
  if (as)
    supportid=as;

  ajax('supportkliensbox',AJAX_URL + '_supportkliens.php?id=' + supportid );
  setTimeout("support(0)",6000);
  return false;
};

function support1(as)
{
  if (as)
    supportid=as;

  ajax('supportkliensbox',AJAX_URL + '_supportkliens.php?id=' + supportid );
  supporttime=900;
  return false;
};



function supportfunc()
{
  c=document.getElementById("szvg").value;
  ajax('supportkliensbox',AJAX_URL + '_supportkliens.php?id='+supportid+'&start=0&szoveg='+c);
  ajax('supportbox',AJAX_URL + '_support.php?start='+schat_start+'&szoveg=');
  document.getElementById("szvg").value="";
  supporttime=900;
  return false;
};


supporttime=900;

function supporttimefunc()
{
  document.getElementById("supporttime").value=supporttime;
  if (supporttime==0)
    location.href ="http://www.onlinepokerhu.com";
  supporttime-=5;
  setTimeout("supporttimefunc()",5000);
  return false;
};
var bgcolor;
var hovercolor;

function hover_in(id,color){
 bgcolor=document.getElementById(id).style.backgroundColor;
 document.getElementById(id).style.backgroundColor=color;
 hovercolor=color;
};
function hover_out(id){
 document.getElementById(id).style.backgroundColor=bgcolor;
};
function field_change(id,action,ajax,mit,class_div,class_text){
clt='';
if (class_text)
   clt=' class='+class_text+' ';

document.getElementById(id).innerHTML='<form id='+id+'_form name='+id+'_form><textarea '+clt+' name='+ id +'_area id='+ id +'_area onblur="field_send(\''+id+'\',\''+action+'\',\''+ajax+'\',\''+mit+'\',\''+class_div+'\',\''+class_text+'\')">' + document.getElementById(id+'_in').innerHTML + '</textarea><input type=hidden name=action id=action value="'+action+'"><input type=hidden name=divname id=divname value="'+id+'"><input type=hidden name=mit id=mit value="'+mit+'"></form>';
document.getElementById(id+'_area').focus();
};

function field_send(id,action,ajax,mit,class_div,class_text){
orival=document.getElementById(id+'_area').value;
get1(id+'_form',id,ajax);
sp='';
if (orival=='')
  sp='&nbsp;'
cld='';
if (class_div)
   cld=' class='+class_div+' ';

document.getElementById(id).innerHTML='<div '+cld+' id='+id+'_in onMouseOver="hover_in(\''+id+'_in\',\''+hovercolor+'\');" onMouseOut="hover_out(\''+id+'_in\');"  onclick="field_change(\''+id+'\',\''+action+'\',\''+ajax+'\',\''+mit+'\',\''+class_div+'\',\''+class_text+'\');">'+sp+ orival +'</div>';

};


var divname='';
var _divname='';
function whichDiv(e){
if (divname=='' && _divname=='')
  return;
if (_divname!=''){
 divname=_divname; _divname=""; return;
}
var div=document.getElementById(divname);
var target=e?e.target:event.srcElement;
var parent;
divok=0;
src=target;

if (target.id==div.id)
   divok=1;
else{
  while (parent=src.parentNode){
   if (parent.id==div.id){
    divok=1;
     break;
   } 
   if (parent.nodeName=="BODY"){
     break;
   }
   src=parent;  
  }
}
if (!divok){
  document.getElementById(divname).style.display='none';
  divname='';
}
};
document.onclick=whichDiv;
var cache = [];


function menu_popup1(tm,id,start){
 lastpopup=start; lasthide='';
 setTimeout(function(){menu_popup(id,start)},tm);
}

var lastpopup, lasthide;

function menu_popup(id,start){

//$('#tabs-1').prepend("lp: "+lastpopup+" ------ lh:"+lasthide+"<br>");
if (lastpopup!=start) {return;}
if (lasthide==start) {lasthide='';return;}

var celid='#menu_popup_'+id;

if (hide==1) {hide=0;return;}
if (start!=""){
 var mezoid='#'+start;  
 var tp=$(mezoid).position().top+50;
 var lf=$(mezoid).position().left;
 $(celid).css("top", tp +"px");
 $(celid).css("left", lf +"px");
// $(celid).css("width", width +"px");
// $(celid).attr('class', cl);

}
if (divname=='') {

    _divname='menu_popup_'+id;
//    divname='menu_popup_'+id;

}
  $('.menu_popup').hide();
  $(celid).show();
// $(celid).slideDown(190);



}

function selecton1(tm,divid,ajax_url,start,mode,cachediv,width,cl){
 lastpopup=start; lasthide='';
 setTimeout(function(){selecton(divid,ajax_url,start,mode,cachediv,width,cl)},tm);
}



function selecton(divid,ajax_url,start,mode,cachediv,width,cl){

cl = typeof(cl) != 'undefined' ? cl : "titan_select";
mode = typeof(mode) != 'undefined' ? mode : "0";
width= typeof(width) != 'undefined' ? width : "280";
start = typeof(start) != 'undefined' ? start : "";
cachediv = typeof(cachediv) != 'undefined' ? cachediv : "";
DoCache = cachediv;
var dt = new Date();
var celid='#'+divid;

if (cachediv){
  if (lastpopup!=start) {return;}
  if (lasthide==start) {lasthide='';return;}
}

//$('#tabs-1').prepend("lp: "+lastpopup+" ------ lh:"+lasthide+" --- start: "+start+"<br>");

if (start!=""){
 var mezoid='#'+start;  
 var tp=$(mezoid).offset().top+24;
 var lf=$(mezoid).offset().left-85;
 $(celid).css("top", tp +"px");
 $(celid).css("left", lf +"px");
 $(celid).css("width", width +"px");
 $(celid).attr('class', cl);

}
if (divname=='') {

  if (mode==0) 
    _divname=divid; 
  else
    divname=divid; 

  $(celid).show();
  if (cache[cachediv] && dt.getTime()/1000-cache_time[cachediv]<60)
    $(celid).html(cache[cachediv]);
  else {
    $(celid).html('');
    ajax(divid,ajax_url,DoCache);
  }
 } else 
   { 
    if (mode==0)   $(celid).show();
    divname=divid; 
    if (cache[cachediv] && dt.getTime()/1000-cache_time[cachediv]<60)
      $(celid).html(cache[cachediv]);
    else{
      $(celid).html('');
      ajax(divid,ajax_url,DoCache);
    }
   
 }
return false;

};


var hide=0;
function delayhide(mit){
if (!titan && hide) {$('#titan_layer').hide(); lasthide=mit;hide=0; divname="";}
}

function delayhide_menu(mit){
if (!popup && hide) {$('.menu_popup').hide(); lasthide=mit; hide=0; divname="";}
}



function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
};
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
};
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
};


function pic_pos(w,h,mode){


if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

if (mode==1 && winH>h){
  var a=parseInt((winH-h)/2);
  document.getElementById('galeria_kep_big').style.paddingTop=a;
}
if (mode==2){
  var a=parseInt((winH-h)/2)-15;
  var b=parseInt((winW-w)/2)+parseInt(w)-15;
  document.getElementById('img_full_close').style.top=a;
  document.getElementById('img_full_close').style.left=b;
}


};
var titan=0;
var popup=0;



function preview(lnk){
htm='<br><br><a style="margin-left: 100px; background-color : yellow; color : red; font-size : 26px;" href=# onclick="divname=\'\';$(\'#cikk_preview_div\').hide(); return false;">(X)</a><center><iframe background=white height=1100 width=800 src="'+lnk+'"></iframe></center>';
$('#cikk_preview_div').html(htm);
$('#cikk_preview_div').show();
_divname='cikk_preview_div';
return false;
}


function msgboxclose(){
$('#uzenet_kuldes').remove();
return false;
}

function msg_box(nev,divid){
var order = "nev="+nev;
$('#uzenet_kuldes').remove();
$('#'+divid).parent().before('<div id=uzenet_kuldes></div>');
$.post(AJAX_URL + 'msgbox.php', order,function(dt){$("#uzenet_kuldes").html(dt+"<br><a href=# onclick='$(\"#uzenet_kuldes\").remove(); return false;'>(X)</a>");});
return false;

}



var hd=0;

$.fn.fblike =function(){

$(this).mouseenter(function() {
 if (!hd){
 pad=parseInt($('.img_fblike',this).css("padding-top"))-30;
 lft=$('.forum_kep',this).position().left;
 $('.img_fblike',this).css("left",lft).css("top",$(this).position().top+$(this).height()-$('.img_fblike',this).height()-pad).show();
// $('.img_fblike',this).css("left",lft).css("top",$(this).position().top+$(this).height()).show();
 hd=1;}
 });

$(this).mouseleave(function(){
  if (hd==1){$('.img_fblike',this).hide();hd=0;}
});
}


$.fn.longtext_out =function(){
$(this).mouseleave(function(){
  $(this).prev().show();
  $(this).remove();
});
}


$.fn.longtext =function(){
$(this).mouseenter(function(){
id='long_'+parseInt(Math.random()*100000);
$(this).after('<li class=long_text id='+id+'>'+$(this).attr("lng")+'</li>');
$(this).hide();
$('#'+id).longtext_out();
});

}

function src_list(mit,apa){
 if ($(mit).is(":visible"))
    return;
 var mezoid='#'+apa.get(0).id;  
 var tp=$(mezoid).offset().top+24;
 var lf=$(mezoid).offset().left;
 $(mit).css("top", tp +"px");
 $(mit).css("left", lf +"px");
 $(mit).show();
// divname=mit;
}


$.fn.srch_ajax =function(o){
    var defaults = {
	celpont		:	'#celpont',
	ajaxfunc :  AJAX_URL + 'srch.php'
    };
  var sts= $.extend({}, defaults, o);
  apa=this;
  $('input',this).keyup( function(event){ 
  hol=$('select',apa).val();
  if (hol==3 || hol==4 || hol==5 || hol[1]=='_')
     return;
   if ($(this).val().length>2){ 
    var order = "&mit="+$(this).val()+"&hol="+hol;
    $.post(sts.ajaxfunc, order,function(dt){src_list(sts.celpont,apa);$(sts.celpont).html(dt);});
   } else {
     $(sts.celpont).html(""); $(sts.celpont).hide();
   }

});

  $('select',this).change(function() {
   $(sts.celpont).html(""); $(sts.celpont).hide();
   hol=$('select',apa).val();
   if (hol==3 || hol==4 || hol==5 || hol[1]=='_')
     return;
   if ($('input',apa).val().length>2){ 
    var order = "&mit="+$('input',apa).val()+"&hol="+$('select',apa).val();
    $.post(sts.ajaxfunc, order,function(dt){src_list(sts.celpont,apa);$(sts.celpont).html(dt);});
   }
});


  $(sts.celpont).mouseleave(function(){
    $(sts.celpont).hide(); 
  });

}

var ajanlo=0;

$(function(){

$("#top_srch_box").srch_ajax();
$(".long_text").longtext();
$("#calendar1").calendar();
$(".forum_kep_div").fblike();  
$("#insertText").draggable();
$("input#color").simpleColorPicker();
$("input.pickcolor").simpleColorPicker();

$("#titan_layer").mouseenter(function() {titan=1;});
//$("#titan_layer").mouseleave(function() { if (titan) {$("#titan_layer").hide(); titan=0; divname="";}});
$("#titan_layer").mouseleave(function() {titan=0;hide=1; setTimeout('delayhide()',150);});

$(".menu_popup").mouseenter(function() {popup=1;});
//$(".menu_popup").mouseleave(function() { if (popup) {$(".menu_popup").hide(); popup=0; divname="";}});
$(".menu_popup").mouseleave(function() { popup=0;hide=1; setTimeout('delayhide_menu()',150);});

 


$(window).scroll(function(){
 if ($(window).scrollTop()/$(window).height()>0.65 && ajanlo==0){
   $('#ajanlo_div').slideDown('slow'); ajanlo=1;

 }
 if ($(window).scrollTop()/$(window).height()<0.65 && ajanlo==1){
   $('#ajanlo_div').slideUp('slow',function(){ $('#ajanlo_div').hide()}); ajanlo=0;
 }
    

});


$( "#accordion" ).accordion({
active : false,
collapsible: true,
			autoHeight: false,
			navigation: true
		});

$( "#accordion1" ).accordion({
active : false,
collapsible: true,
			autoHeight: false,
			navigation: true
		});

$( "#accordion_admin" ).accordion({
active : false,
collapsible: true,
			autoHeight: false,
			navigation: true
		});

$( "#accordion_klubtagsag" ).accordion({
active : false,
collapsible: true,
			autoHeight: false,
			navigation: true
		});

//$("ul.css-tabs").tabs("div.css-panes > div", {effect: 'ajax', event:'mouseover' });
$("ul.css-tabs").tabs("div.css-panes",{event:'mouseover'});

mh=$("#col1").height();
$("#col2").css("min-height", mh+"px");
mh=$("#topdoboz").height();
if (mh>310)
  $(".css-panes").css("height", mh+"px");


  	$("#addButton1").fancybox({
		'zoomSpeedIn'		: 600,
		'zoomSpeedOut'		: 500,
		'easingIn'			: 'easeOutBack',
		'easingOut'			: 'easeInBack',
		'hideOnContentClick': false,
		'frameWidth'			: 620,
		'frameHeight'			: 640,
		'padding'			: 15
	});
  	$(".addButton2").fancybox({
		'zoomSpeedIn'		: 600,
		'zoomSpeedOut'		: 500,
		'easingIn'			: 'easeOutBack',
		'easingOut'			: 'easeInBack',
		'hideOnContentClick': false,
		'frameWidth'			: 820,
		'frameHeight'			: 680,
		'padding'			: 15
	});




$(".infoicon b").hover(function() {
var lf=35;
if ($(this).offset().left>800)
   lf=-270;
$(this).next(".ibox").stop(true, true).animate({opacity: "show", left : lf, top: "-40"}, "slow");
}, function() {
$(this).next(".ibox").animate({opacity: "hide", top: "-30"}, "fast");
});


$(".close").click(function() {
   $(this).parent().hide();
});

$(".hsz_nick").click(function() {
if (divname){
 $('#'+divname).hide();
 divname='';
}
_divname=$('.forum_select',this).get(0).id;
$('.forum_select',this).show();
});

$(".hsz_over").mouseover(function() {
if (divname){
 $('#'+divname).hide();
 divname='';
}
divname=$('.forum_select',this).get(0).id;
$('.forum_select',this).show();
});


$(".hsz_nick").mouseleave(function() {
if (divname){
 $('#'+divname).slideUp('slow',function(){ $(this).hide();});
// $('#'+divname).hide();
 divname='';
}
});
$(".hsz_over").mouseleave(function() {
if (divname){
 $('#'+divname).slideUp('slow',function(){ $(this).hide();});
// $('#'+divname).hide();
 divname='';
}
});


$(".hsz_avatar_min").mouseover(function() {
//$('.hsz_avatar2',this).show().animate({opacity: 1},250);
$('.hsz_avatar2',this).show().animate({opacity: 1},250);
});
$(".hsz_avatar_min").mouseleave(function() {
$('.hsz_avatar2',this).animate({opacity: 0},250,function(){ $(this).hide();});

});




$(".menu_popup_span").mouseleave(function() {
 var xx;
 xx=$(this).get(0).id;
 hide=1;
 setTimeout(function(){delayhide_menu(xx);},50);
});


$(".movable").mouseout(function() {
 var xx;
 xx=$(this).get(0).id;  
//$('#tabs-1').prepend("xx: "+xx+"<br>");
 hide=1;
 setTimeout(function(){delayhide(xx);},50);
});



/*
$("img[title]").tooltip({

		tip: '.tooltip4',
		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 400,
                relative : true,
		offset: [0,0],
         position : "top"
	});

*/

$(".tooltip_down").tooltip({ 		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 750,
                relative : true,
                opacity : 0.85,
		offset: [0,-30],
 position : "bottom center"});

$(".tooltip_up").tooltip({ 		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 750,
                relative : true,
                opacity : 0.85,
		offset: [0,0],
 position : "top center"});

$(".tooltip_up2").tooltip({ 		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 750,
                relative : true,
		offset: [0,0],
 position : "center left"});

$(".tooltip_up3").tooltip({ 		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 750,
                relative : true,
		offset: [0,0],
 position : "center right"});

});


$("#insertText").live("hover",function(){($( "#insertText" ).draggable())});
$('#color').live("hover",function(){($("#color").simpleColorPicker())});
/*
$('img').live("hover",function(){($("img[title]").tooltip({

		tip: '.tooltip4',
		effect: 'fade',
		fadeOutSpeed: 100,
		predelay: 400,
                relative : true,
		offset: [0,0],
         position : "top center"
	}))});

*/


