$.ifixpng('/includes/blank.gif');
var visited = [];
var i, k;
var toolwidth = 0;
$.fn.mailcsere = function()
{
this.each(
    function()
	{
	var emailcim = $(this).text();
	emailcim = emailcim.replace(/\(kukac\)/gi,'@');
	emailcim = emailcim.replace(/\(pont\)/gi,'.');
	$(this).text(emailcim);
//	alert(emailcim);
	return this;
	});
return this;
}
function update_scale(csz)
    {
    $.ajax({
	type: 'POST',
	url: '/ajax.php',
	data: 'op=update_scale&csz='+csz,
	dataType: 'html',
	success: function(data)
	    {
	    $(".gep-ertekeles").html(data);
	    }
	});
    }
function load_page(href)
    {
    var pl = href.match(/#.*/);
    if (pl == null)
	var place = false;
    else
	{
	var place = String(pl);//.substr(1);
	}
    href = href.match(/[^#]*/);
    var xref = href[0].match(/^(http:\/\/)?([\w]*\.)*(ebyte\.)?(web-ep\.)?(hu)?(\/)?(.*)/i);
    visited[visited.length] = xref[7];
    parent.location.hash =xref[7];
    $.ajax({
	type: 'POST',
	url: '/ajax.php',
	data: 'href='+href,
	dataType: 'html',
	success: function(data)
	    {
//	    $("#main_area").animate({height: '30px'},{duration: 700, complete: function() {
	    $("#main_area").html(data);//.animate({height:'100%'},700);
	    clearTimeout(i);
//	    tooltip_move();
	    make_selects();
	    $("#main_area .email").mailcsere();
	    $('#main_area .to-shadow').shadow();
	    $('#main_area .to-border').border('w-');
//	    $('#main_area a:not(.external)').link_to_ajax();
	    $("table").make_odd_rows();
	    $('#main_area a:has(img)[href$=.jpg]').click(function(event){
		    // stop default behaviour
		    event.preventDefault();
		    // remove click border
		    this.blur();
		    // get caption: either title or name attribute
		    var caption = this.title || this.name || "";
		    // get rel attribute for image groups
		    var group = this.rel || false;
		    // display the box for the elements href
		    TB_show(caption, this.href, group);
		      });
//	    }});
//	    $("#back-left, #back-right").correct_height();
	    $('#tool-box').hide();
	    if (place)
		{
		var st = $(place).offset().top;
		window.scroll(0,st);
		}
	    $("#indicator").slideUp(100);
	    $.ajax({
		type: 'POST',
		url: '/ajax.php?script=1',
    		data: 'href='+href,
		dataType: 'script'
	    });
	    }
	});
    }
$.fn.make_odd_rows = function()
{
this.each(
    function()
	{
	if(this.tagName == 'TABLE');
	    {
	    $(this).find('tr:odd').addClass("odd");
	    }
	return this;
	});
return this;
}


$.fn.link_to_ajax = function()
{
this.each(
    function()
	{
	$(this).click(function(){
	    var ret = true;
	    $("#indicator").slideDown(100);
//	    $(this).parents('.menu-item').click();
//	    var index = $(this).parent().parent().parent().prevAll().find('.akkord').size();
//	    $(this).parent().parent().parent().parent().accordion('activate',index);
	    $("#tool-box").hide();
	    load_page(this.href);
	return false;
	    });
	});
}
var gyors = 500;
var q = 400;
$.fn.concept = function()
    {
/*    $(this).animate({width: '195px'},q);
    $(this).find("div.menu-fejez").animate({width: '150px'},q);
    $(this).find("li.menu-item div.menu-item-title").animate({fontSize: '20px'},q);
    $(this).find("li.menu-item div.menu-item-almenuk").animate({fontSize: '14px',lineHeight: '13px'},q);*/
    }
$.fn.unconcept = function()
    {
/*    $(this).animate({width: '165px'},q-20);
    $(this).find("div.menu-fejez").animate({width: '120px'},q);
    $(this).find("li.menu-item div.menu-item-title").animate({fontSize: '15px'},q);
    $(this).find("li.menu-item div.menu-item-almenuk").animate({fontSize: '12px',lineHeight: '11px'},q);*/
    }
function fejlec_main()
    {
    $("#header .title-blue img, #header .title-red img").animate({height: '135px'},gyors+100);
    $("#header .title-blue").animate({paddingRight: '120px'},gyors-100);
    $("#header .title-red").animate({paddingLeft: '120px'},gyors-100);
    $("#header #blue-wraper").animate({width: '450px', height: '140px'},gyors-10);
    $("#header #red-wraper").animate({width: '450px', height: '140px'},gyors);
    $("#belogo").animate({left: '375px'},gyors);
    $("#belogo img").animate({width: '224px', height: '224px'},gyors);
    }
function fejlec_webtech()
    {
    if (concept != 'szamtech')
	{
	$("#belogo img").animate({width: '154px', height: '154px'},gyors);
	$("#header .title-blue img, #header .title-red img").animate({height: '80px'},gyors-100);
	$("#header .title-blue").animate({paddingRight: '90px'},gyors-100);
	$("#header .title-red").animate({paddingLeft: '90px'},gyors-100);
	}
    $("#header #blue-wraper").animate({width: '300px', height: '82px'},gyors-10);
    $("#header #red-wraper").animate({width: '600px', height: '82px'},gyors);
    $("#belogo").animate({left: '258px'},{
	queue: false, 
	duration: gyors, 
	complete: function() {
	    $('#webtech-menu').concept();
	    $('#szamtech-menu').unconcept();
	}
    });
    }
function fejlec_szamtech()
    {
    if (concept != 'webtech')
	{
	$("#header .title-blue img, #header .title-red img").animate({height: '80px'},gyors-100);
	$("#header .title-blue").animate({paddingRight: '90px'},gyors-100);
	$("#header .title-red").animate({paddingLeft: '90px'},gyors-100);
	$("#belogo img").animate({width: '154px', height: '154px'},gyors);
	}
    $("#header #blue-wraper").animate({width: '600px', height: '82px'},gyors);
    $("#header #red-wraper").animate({width: '300px', height: '82px'},gyors-10);
    $("#belogo").animate({left: '558px'},{
	queue: false, 
	duration: gyors, 
	complete: function() {
	    $('#szamtech-menu').concept();
	    $('#webtech-menu').unconcept();
	}
    });
    }
function resize(meret)
    {
    $("#header-top, #header, #main, #footer").animate({width: (meret-199)+'px'},200);
    $("#main-area, fieldset.permalink").amimate({width: (meret-399)+'px'},200);
    $("#back-left").animate({left: (meret-199+60)+'px'},200)
    $("#back-left, #back-right").correct_height();
    }

//$("#belogo img").load(function(){$(this).ifixpng()});

$(document).ready(function(){
    $("#indicator").html("<img src='/images/indicator.gif' alt='Kérem várjon...'/> Kérem várjon, az oldal töltődik.").hide();
    $(".email").mailcsere();
	    $('a:has(img)[href$=.jpeg], a.thickbox').click(function(event){
		    // stop default behaviour
		    event.preventDefault();
		    // remove click border
		    this.blur();
		    // get caption: either title or name attribute
		    var caption = this.title || this.name || "";
		    // get rel attribute for image groups
		    var group = this.rel || false;
		    // display the box for the elements href
		    TB_show(caption, this.href, group);
		      });
/*    $(".menu-item").each(function(){
	var link = $(this).find('a').attr('href');
	$(this).click(function(){window.location = link;}).css({cursor: 'pointer'});
    });*/
//    $('a:not(.external)').link_to_ajax();
    if ($.browser.msie) // kibaszott explorer
	{
	$("#header-cont a").hover(
	    function(){
	    $(this).css({backgroundPosition: '50% -58px'}).css({color: '#fff'});
	    },
	    function(){
	    $(this).css({backgroundPosition: '50% -1px'}).css({color: '#444'});
	    });
    $(".menu-behuz").hover(
	    function(){
		$(this).css({backgroundPosition: '-10px 7px'});
	    },
	    function(){
		$(this).css({backgroundPosition: '-165px 7px'});
	    });
	}
    else
	{
	$("#header-cont a").hover(
	    function(){
	    $(this).stop().animate({backgroundPosition: '(0% -58px)'},250).css({color: '#444'});
	    },
	    function(){
	    $(this).stop().animate({backgroundPosition: '(0% -1px)'},250).css({color: '#fff'});
	    });
	$(".menu-behuz").hover(
	    function(){
		$(this).stop().animate({backgroundPosition: '(-10px 7px)'},100);
	    },
	    function(){
		$(this).stop().animate({backgroundPosition: '(-165px 7px)'},500,'easeOutBounce');
	    });
    }
    $("a.has_almenu").almenuk();
    $("table").make_odd_rows();
    make_selects();
//    $('.termek-row').hover(function() {$(this).css({border: "1px solid navy;"});},function() {$(this).css({border: "none"});});
//    $('.termek-row:not(.termek-row-sotet)').hover(function() {$(this).css({backgroundPosition: "0 -80px"});},function() {$(this).css({backgroundPosition: "0 0px"});});
//    $('.termek-row-sotet').hover(function() {$(this).css({backgroundPosition: "0 -120px"});},function() {$(this).css({backgroundPosition: "0 -40px"});});
    tool_mouse();

});
/*$.fn.almenuk = function()
    {
    $(this).each(function(){
	var t = $(this);
	$(this).parent().hover(
	    function(){
		tid = $(t).attr('id');
		if (!tid)
		    {
		    tid = 'e_'+Math.round(Math.random()*100);
		    $(t).attr({id: tid});
		    }
		i = setTimeout('get_almenus("'+tid+'");',500);
	    },
	    function(){
		clearTimeout(i);
		$(t).next().slideUp(200,function(){$(this).remove();});
	    }
	);
    });
    }*/
$.fn.almenuk = function()
    {
    $(this).each(function(){
	$(this).hover(
	    function(){
		clearTimeout(i);
/*		tid = $(this).attr('id');
		if (!tid)
		    {
		    tid = 'e_'+Math.round(Math.random()*100);
		    $(this).attr({id: tid});
		    }*/
		var o = $(this).offset();
		$("#hover-menu").hide().css({top: (o.top)+'px',left: (o.left+$(this).width())+'px',opacity: '0.9'});
		$("#hover-menu-cont").html("<img src='/images/indicator.gif' alt='pillanat...'/>");
		$(this).almenus();
	    },
	    function(){
		clearTimeout(i);
		i = setTimeout('menu_tuntet()',400);
	    }
	);
    });
    }
function menu_tuntet()
    {
    $("#hover-menu").slideUp(200);
    }
$.fn.almenus = function() 
    {
    if (!$("#hover-menu:visible").size())
	{
	$("#hover-menu").slideDown(200);
	}
    clearTimeout(k);
    k = setTimeout('get_almenus("'+$(this).attr('href')+'");',200);
    $("#hover-menu").hover(
	function(){
	    clearTimeout(i);
	},
	function(){
		clearTimeout(i);
		i = setTimeout('menu_tuntet()',100);
	}
    );
    
    }
function get_almenus(a)
    {
//    $("#hover-menu-cont").html('ittvagyok');
    $.ajax({
	    type: 'POST',
	    url: '/tool_ajax.php',
	    dataType: 'html',
	    data: 'op=get-almenu&menu='+a,
	    success: function(dat)
		{
		$("#hover-menu-cont").html(dat);
		}
	    
	});
    }
function make_selects()
    {
/*    $("#main_area select:not(.buheralt), #jobb-menu select:not(.buheralt)").each(function(){
    if ($.browser.mozilla && $.browser.opera)
	{
	if ($(this).width())
	    {
	    $(this).after('<div style="width:'+($(this).width()+2)+'px; height: '+($(this).height()+2)+'px; background-image: url(\'/images/design/gepbox/input-gradient.gif\'); background-repeat: repeat-x;">&nbsp;</div>');
	    o = $(this).next().offset();
	    $(this).css({position: 'absolute',top: o.top+'px', left: o.left+'px'}).addClass('buheralt');
	    }
	}
        });*/
    }
function show_alter_topbox(conc)
    {
    $("#top-box-alter").animate({opacity: 0},1);    
    if (conc == 'webtech')
	$("#top-box-alter").css({left: '620px'});
    if (conc=='szamtech')
	$("#top-box-alter").css({left: '5px'});
    $("#top-box-alter").animate({opacity: 1},2000);    
    }
    
function show_topbox(conc)
    {
    
//    $("#top-box:visible").slideUp(400);
    if (conc=='webtech')
	{
	$("#top-box").queue(function(){
	    $.ajax({
		type: 'POST',
		url: 'top_box.php',
		data: 'concept='+conc,
		dataType: 'html',
		success: function(data)
		    {
//		    var d = data.split('|');
		    $("#top-box").css({left: '630px'});
		    top_rotate(data);
		    /*
		    $("#top-box").find(".top-box-title").text(d[0]);
		    $("#top-box").find(".top-box-pic img").attr({src: d[1]});
		    $("#top-box").find(".top-box-cont").html(d[2]).append('<span class="ar">'+d[3]+'</span>');
		    $("#top-box").click(function (){$("#indicator").slideDown(400);load_page(d[4])});
		    $("#top-box").css({left: '630px'}).slideDown(300);
		    */
		    }
	    });
	$(this).dequeue();	  
//	alert(conc);
	})
	}
    if (conc=='szamtech')
	{
	$("#top-box").queue(function(){
	    $.ajax({
		type: 'POST',
		url: 'top_box.php',
		data: 'concept='+conc,
		dataType: 'html',
		success: function(data)
		    {
		    $("#top-box").css({left: '50px'});
		    top_rotate(data);
		    }
	    });
	$(this).dequeue();
//	alert(conc);
	});
	}
//    alert(1);
    }
var top_datas = [];
var n = 0;
function top_rotate(datas)
    {
    top_datas = datas.split('¤');
    top_adatok(top_datas[0]);
    setInterval(function(){ n++; if(n >= top_datas.length) n = 0;top_adatok(top_datas[n]);},10000);
    }
function top_adatok(data)
    {
    $("#top-box").slideUp(400, function() {    
//    while($('#top-box:visible').size());
    var d = data.split('|');
    $("#top-box").find(".top-box-title").text(d[0]);
//	alert(d[0].length);
    if (d[0].length > 15)
	$("#top-box").find(".top-box-title").css({fontSize: '16px',lineHeight:'20px'});
    else
	$("#top-box").find(".top-box-title").css({fontSize: '18px',lineHeight:'41px'});
    $("#top-box").find(".top-box-pic img").attr({src: d[1]}).css({marginTop: d[2]+'px'});
    $("#top-box").find(".top-box-cont").html(d[3]).append('<span class="ar">'+d[4]+'</span>');
    $("#top-box").click(function (){
	window.location = d[5];
//	$("#indicator").slideDown(400);load_page(d[5])
	});
    $("#top-box").slideDown(400);
    });
    }
function tool_mouse()
{
var bw = $(document).width();
var bh = $(document).height();
var tw, th = 0;
$(window).resize(function(){bw = $(document).width(); bh = $(document).height();});
$().mousemove(function(e)
    {
    var tbp = {x:e.pageX,y:e.pageY};
    if (tbp.y + $('#tool-box').height() > bh-50)
	th = tbp.y-$('#tool-box').height()-10;
    else
	th = tbp.y+10;
    if (tbp.x+$('#tool-box').width() > bw-30)
	tw = (tbp.x-10-$('#tool-box').width());
    else
	tw = (tbp.x+10);
//        $("#tool-box").css({top: (tbp.y+10)+'px',left: (tbp.x-10-toolwidth)+'px', width: toolwidth+'px'});
        $("#tool-box").css({top: (th)+'px',left: tw+'px', width: toolwidth+'px'});
    });
}
$.fn.toolbox = function(dat)
{
//    $("#tool-box").html($(this).attr('class'));
    var d = dat.split('Ł');
    toolwidth = d[0];
    $('#tool-box').html(d[1].replace(/×/g,"'").replace(/¤/g,"")).show().find('tr:odd').css({backgroundColor: '#cccccc'});
    $(this).mouseout(function(){$('#tool-box').hide()});
}
function kosar_villog() 
    {
    var f = $('#menu-kosar').parent().parent().find('.ebyte-fejlec');
    $(f).toggleClass('kek').toggleClass('piros');
    }
function forum_fress(csz)
    {
    $.ajax({
	type: 'POST',
	url: '/ajax.php',
	data: 'op=forum-refress&cikksz='+csz,
	dataType: 'html',
	success: function(data)
	    {
	    $("#forum-ertekeles").html(data);
	    }
	});
    }
$.fn.toggle_by_legend = function()
    {
    if ($(this).parent().find('ul:first:visible').size())
	$(this).parent().animate({border:'1px dotted #fff'});
    else
	$(this).parent().animate({border:'1px dotted #aaa'});
    $(this).parent().find('ul:first').slideToggle(500);
    }
$.fn.letoltes_kifejtes = function()
    {
    $(this).next().find('.letoltes-leiras').toggle();
    }
$.fn.move_to_kosar = function(num)
    {
    if ($(this).find('img').size() > 0)
	move_and_remove($(this).find('img'),num);
    }
$.fn.move_to_kosar = function(num)
    {
    if ($(this).find('img').size() > 0)
	move_and_remove($(this).find('img'),num);
    }
function move_and_remove(im,num)
    {
    xx = $("<img src='"+$(im).attr('src')+"' id='move_to_kosar_pic' style='position: absolute;'/>");
    $('body').append(xx);
    o = $(im).offset();
    to = $('#menu-kosar').offset();
    $(im).data('num',num);
    $(xx).css({top: o.top+'px', left: o.left+'px'}).animate({top:to.top+'px',left:to.left+'px'},700).animate({opacity: '0'},{duration:(num > 1?50:500),complete: function(){$(this).remove();
    num = $(im).data('num');
    num--;
    $(im).data('num',num);
    if (num > 0)
	move_and_remove(im,num);
    }});
    }
