/* 
 * jQuery tools settings
 */

$(document).ready( function() {

/* banner kepek */
     $('img:hidden').show(1);
     $('ul#animated-portfolio').animatedinnerfade({
            speed: 3000,
            timeout:  5000,
            type: 'sequence',
            containerheight: '250px',
            containerwidth: '100%',
            animationSpeed: 0,
            animationtype: 'fade',
            controlBox: 'none',
            controlBoxClass: 'mycontrolboxclass',
            displayTitle: 'yes'
      });

/* menu */
//    $('#enged').accordion({
//        header: 'a.kitolt',
//        navigation: false,
//        autoheight: false,
//        fillSpace: false,
//        clearStyle: true,
//        active: 0,
//        alwaysOpen: false
//    });
        $("#navigation").accordion({
        header: 'a.head',
        navigation: true,
        autoheight: false,
        alwaysOpen: false,
        fillSpace: false,
        clearStyle: false,
        icons: {
            header: "ui-icon-circle-arrow-e",
            headerSelected: "ui-icon-circle-arrow-s",
            headerCurrent: "#navigation a.current"
        }
    });

/* roll up image */
    $('div.popup').show('slow', function(){
        $(this).hover(function(){
                $(this).stop();
            },function() {
                    $(this).hide('slow');
            });
        $(this).hide(9999);
    }).css({
       top: 0,
       right: 0,
       display: 'block'
    });

/* hiba es kozlemeny box */
        $('.messages').bind('click',function(){
            $(this).hide('slow');
        });
        $('.error').bind('click',function(){
            $(this).hide('slow');
        });

/* tool tip */

//	$("label.tooltip").hover(function(e){
//        xOffset = 10;
//		yOffset = 20;
//		this.t = this.title;
//		this.title = "";
//		$("body").append("<label id='tooltip'>"+ this.t +"</label>");
//		$("#tooltip")
//			.css("top",(e.pageY - xOffset) + "px")
//			.css("left",(e.pageX + yOffset) + "px")
//			.fadeIn("fast");
//    },
//	function(){
//		this.title = this.t;
//		$("#tooltip").remove();
//    });
//	$("label.tooltip").mousemove(function(e){
//		$("#tooltip")
//			.css("top",(e.pageY - xOffset) + "px")
//			.css("left",(e.pageX + yOffset) + "px");
//	});

	$("area.tooltip2").hover(function(e) {
        xOffset = 150;
		yOffset = -150;
		this.t = this.title;
		this.title = "";
		$("body").append("<div id='tooltip2'>"+ this.t +"</div>");
		$("#tooltip2")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function() {
		this.title = this.t;
		$("#tooltip2").remove();
    });
	$("area.tooltip2").mousemove(function(e){
		$("#tooltip2")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});

	$("a.tooltip3").hover(function(e) {
        xOffset = 15;
		yOffset = 20;
		this.t = this.title;
		this.title = "";
		$("body").append("<a id='tooltip3'>"+ this.t +"</a>");
		$("#tooltip3")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function() {
		this.title = this.t;
		$("#tooltip3").remove();
    });
	$("a.tooltip3").mousemove(function(e){
		$("#tooltip3")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});

    $('#sel_h').jec();
    $('#sel_f').jec();
    $('#ertesules').jec();

/* hasznalat
 * <label><input />foo</label>
 * cursor poziciojat teszi az input mezohoz
 */
    $.fn.shiftClick = function() {
        var lastSelected;
        var checkBoxes = $(this);

        this.each(function() {
            $(this).click(function(ev) {
                if (ev.shiftKey) {
                    var last = checkBoxes.index(lastSelected);
                    var first = checkBoxes.index(this);

                    var start = Math.min(first, last);
                    var end = Math.max(first, last);

                    var chk = lastSelected.checked;
                    for (var i = start; i < end; i++) {
                        checkBoxes[i].checked = chk;
                    }
                } else {
                    lastSelected = this;
                }
            })
        });
    };

});

