
function nyitzar(targetId) {
target = document.getElementById(targetId);
if (target.style.display == "none"){
target.style.display="";
} else {
target.style.display="none";
}
}

function p_load(serverPage, objID){
var xmlhttp = false;
try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;}}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();}
var obj = document.getElementById(objID);
obj.innerHTML = "<img src='pic/load.gif' border=0>";
xmlhttp.open("GET", serverPage+"&"+new Date().getTime());
xmlhttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-2");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}


szelesseg = screen.width;
flash="";
if(szelesseg>=1280){
flash = "tbdev-hun_nagy.swf";
szeles = 1215;
}
else{
flash = "tbdev-hun.swf";
szeles = 960;
}

function textCounter(field,counter,maxlimit,linecounter) {
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  300;
//	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	
  document.getElementById(counter).innerHTML=percentage+"%"+' (még '+(maxlimit-charcnt)+' karakter)';
	//document.getElementById(counter).innerHTML=charcnt;
	
  setcolor(document.getElementById(counter),percentage,"background-color");
	}
}
$(function(){

		$('#cim_fej span').hover(
			function(){$(this).find('div.cim:hidden').fadeIn(500);},
			function(){$(this).find('div.cim:visible').fadeOut(500);}
		);
});


function komment_eltun(mit_tuntet_el,x){
				$("#" + mit_tuntet_el).fadeOut(500);
				
}

function komment_megjel(mit_jelenit_meg,x){
        $("#" + mit_jelenit_meg).css('left',x);
				$("#" + mit_jelenit_meg).fadeIn(500);

}

function ajax_betolt(mit, hova, ez_alapjan){
if ($('#'+hova).is(":hidden")) {
		$('#'+hova).fadeIn("medium");
	} else {
		$('#'+hova).fadeOut("medium");

		return;
	}
	$('#'+hova).html('<p align=\"center\"><img src=\"pic/ajax_loader.gif\" /></p>');
	$.get(mit, { ez_alapjan: hova },
	  function(data){
		$('#'+hova).html(data);
	  });

}
function ajax_ip_fel_betolt(mit, hova, hova_tolt, ipe, csukodik){
if(csukodik==true){
if ($('#'+hova).is(":hidden")) {
		$('#'+hova).fadeIn("medium");
	} else {
		$('#'+hova).fadeOut("medium");

		return;
	}}
	else{
  if ($('#'+hova).is(":hidden")) {
		$('#'+hova).fadeIn("medium");
	} 
  }
	$('#'+hova_tolt).html('<p align=\"center\"><img src=\"pic/ajax_loader.gif\" /></p>');
	$.get(mit, { ip: ipe },
	  function(data){
		$('#'+hova_tolt).html(data);
	  });


}

function ajax_betolto(mit, hova){
if ($('#'+hova).is(":hidden")) {
		$('#'+hova).fadeIn("slow");
	}
	$('#'+hova).html('<p align=\"center\"><img src=\"pic/ajax_loader.gif\" /></p>');
	$.get(mit, {  },
	  function(data){
		$('#'+hova).html(data);
	  });


}

function ajax_csakbetolto_loader_nelkul(mit, hova, ez_alapjan){
if ($('#'+hova).is(":hidden")) {
		$('#'+hova).fadeIn("slow");
	}
	$.get(mit, { ez_alapjan: hova },
	  function(data){
		$('#'+hova).html(data);
	  });


}

function bejelentes_ajax(hova, bejelenetett_felh, tip, ok){
$('#'+hova).html('<p><img src=\"pic/ajax_loader.gif\" /></p>');
	$.post('bejelentes_ajax_feldolgozo.php', { bejelentett_felhasznalo: bejelenetett_felh, tipus: tip, indok: ok},
	  function(data){
		$('#'+hova).html(data);
	  });


}

function szunet(ms)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < ms);
}



function becsuk(mit, ido_mp){

ido_ms = ido_mp * 1000;
newsid = '#' + mit;
//data = "Indok: <input id=bejelentes_oka type=\"text\" name=\"bejelenetes_oka\" maxlength=\"200\" style=\"width:300px\" tabindex=\"2\" class=\"post\"> <input type=button value=Bejelentem onClick=\"bejelentes_ajax('k" + mit + "', {USER_ID}, 'felhasznalo', getElementById('bejelentes_oka').value); return becsuk('k" + mit + "',3)\">";
// $(newsid).html(data)
becsukasi_ido = setTimeout("$(newsid).fadeTo('slow',0,function(){$(newsid).hide('slow');}); szunet(500)", ido_ms);
}


function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

	function scroll_edit(where,speed) {
		var obj = document.getElementById('scroller');

		obj.start();
		if (speed == 'normal') speed = 6;
			else if (speed == 'more') speed = parseInt(obj.scrollAmount) + 6;
				else if (speed == 'stop') {
					obj.stop();
				}
		
		obj.scrollAmount = speed;
		obj.direction = where;
	}
	
	


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};



function klappe_nyit_zar(){
	if ($('#uzifal').is(":hidden")) {
		$('#uzifal').show('slow',function(){$('#uzifal').fadeTo('slow',1)});
		$.cookie('uzifal', 'block', { expires: 365});
	$('#nyit_zar_szoveg').attr('alt', 'Üzifal elrejtése');
	} else {
		$('#uzifal').fadeTo('slow',0,function(){$('#uzifal').hide('slow');});
		$.cookie('uzifal', 'none', { expires: 365});
  $('#nyit_zar_szoveg').attr('alt', 'Üzifal megjelenítése');
  }
}

$(document).ready(function(){
	var show = $.cookie('uzifal');
	if (show == "block" | show == null){
		$('#uzifal').show();
		$('#nyit_zar_szoveg').attr('alt', 'Üzifal elrejtése');}
		else{
    $('#uzifal').hide();
    $('#nyit_zar_szoveg').attr('alt', 'Üzifal megjelenítése');
    }
});

function radio_nyit_zar(){
	if ($('#radio').is(":hidden")) {
		$('#radio').show('slow',function(){$('#radio').fadeTo('slow',1)});
		$.cookie('radio', 'block', { expires: 365});
	//$('#nyit_zar_szoveg').attr('alt', 'Üzifal elrejtése');
	} else {
		$('#radio').fadeTo('slow',0,function(){$('#radio').hide('slow');});
		$.cookie('radio', 'none', { expires: 365});
 // $('#nyit_zar_szoveg').attr('alt', 'Üzifal megjelenítése');
  }
}



$(document).ready(function(){
	var show = $.cookie('radio');
	if (show == "block" | show == null){
		$('#radio').show();
		//$('#nyit_zar_szoveg').attr('alt', 'Üzifal elrejtése');
    }
		else{
    $('#radio').hide();
    //$('#nyit_zar_szoveg').attr('alt', 'Üzifal megjelenítése');
    }
});




tolt = new Array();
ertek = new Array();
for(i=0;i<20;i++){
ertek[i] = 0;
}
function szavazo_effekt(szazalek,opcio){
szav_csik = document.getElementById('szavazocsik'+opcio);
ertek[opcio]++;
szav_csik.width=ertek[opcio]*2;
if(ertek[opcio]>szazalek){
clearInterval(tolt[opcio]);
ertek[opcio] = 0;
}
}

function szavazo(szazalek,opcio){

tolt[opcio] = setInterval("szavazo_effekt(" + szazalek + "," + opcio + ")",20);
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function hozzaferes(id){
$.get("hozzaferes_ajax_feldolgozo.php", {topic_id:id}, function(data){
 $("#hozzaferes").attr({src: data});
})
}
function hozzaferes_b(id){
$.get("hozzaferes_ajax_feldolgozo.php", {topic_id:id}, function(data){
 $("#hozzaferes_" + id).attr({src: data});
 $("#t_" + id).attr({src: data});
})
}

function delete_vote(id,cid){
    $.get("comment_vote.php",{'delete':id,'cid':cid},function(retval){
    $("#comm_vote_" + cid).html(retval);    
    $("#comment_id_" + cid).fadeIn("slow");
    $("#sec_comment_id_" + cid).fadeIn("slow");
    $("#third_comment_id_" + cid).fadeIn("slow");
    });
}

function comm_vote(cid,value){
    $.get("comment_vote.php",{'add':cid,'value':value},function(retval){
    $("#comm_vote_" + cid).html(retval);
    if(value!="1"){
    $("#comment_id_" + cid).fadeOut("slow");
    $("#sec_comment_id_" + cid).fadeOut("slow");
    $("#third_comment_id_" + cid).fadeOut("slow");
    }    
    });    
}


