
        var globalOnLoad = new Array();
        
    function scrollWin(){
        $('html, body').animate({
            scrollTop: 0
        },0);
    }
    function closeParentDialog(element){
        var $element = $(element);
        var parent = $element.parents().find("div.ui-dialog");
        parent.dialog("close");
    }

    function markPresentation(pid,mark, creator){
        $.ajax({
            type: 'POST',
            url: markUrl,
            data: {
                'id':pid,
                'mark':mark
            },
            success: function(data){
                $(creator).parents("div.markContainerTop:eq(0)").html(data);
            }
        });
    }
    function checkSubmit(submittedForm){
        var $form = $(submittedForm);
        var notSubmit = $form.data('notSubmit');
        $form.data('notSubmit', false);
        return notSubmit;

    }
    function submitParentForm(element){
        $(element).parents('form:eq(0)').submit();
        return false;
    }


    $.validator.addMethod('prefill', function(value, element, param) {
        var $this = $(element);
        if($this.data("isFilled")){
            return $.validator.methods.required.call(this, $.trim(element.value), element);
        }
	},"Wypełnij pole.");


    $.validator.addMethod('requireAll', function(value, element, param) {
        var valid = true;
        var elems = $(param.selector);
        for (var i=0; elems.length  >i ; i++){
            var element = elems[i];
            var valval = $.validator.methods.required.call(this, $.trim(element.value), element);
            if(!valval){
                valid=false;
            }
        }
        valid &= ($(param.checked).length == param.requiredCount);
        return valid;
	},"My effing cusotm message");


    $.validator.addMethod('requiredIf', function(value, element, param) {
        if(param.isRequired()){
            var valid = $.validator.methods.required.call(this, $.trim(element.value), element);
            return valid==true;
        }else{
            return true;
        }
	},"Pole wymagane");
    $.validator.addMethod('fixedValue', function(value, element, param) {
        return element.value == param;
	},"Sprawdź wynik działania.");
    $.validator.addMethod('datePL', function(value, element, param) {
        return this.optional(element) || /^\d{2}[\/-]\d{2}[\/-]\d{4}$/.test(value);
	},"Sprawdź porawność daty");

    jQuery(document).ready(function() {
        jQuery.each(globalOnLoad, function(i) {
            if (typeof(globalOnLoad[i]) == 'function') {
                globalOnLoad[i]();
            }
        });
    });
    globalOnLoad.push(function() {
        $('img.starImage').live('mouseover', function(evt){
            var $this = $(this);
            var $nextAll=$this.nextAll('img');
            var $prevAll=$this.prevAll('img');
            $this.animate({opacity:1},1);
            $this.parent().parent().find('img:nth-child(1)').animate({opacity:1},1);
            $nextAll.animate({opacity:0},1);
            $prevAll.animate({opacity:1},1);
        });
        $('div.starsSelector').live('mouseout', function(evt){
            var $this = $(this);
            $this.parent().find('img:nth-child(1)').animate({opacity:0},1);
            $('img.starImage').animate({opacity:0},1);
        });
    });
    $('.addToClipboardLink').live('click',function(evt){
        evt.preventDefault();
        var $this = $(this);
        if(!$this.data('ajaxized')){
            var removeParentSelector = false;
            if($this.is(".removeParentRow")){
                removeParentSelector = ".row:eq(0)";
            }
            $this.ajaxlink({ajaxLinkOnce:true, force: true, tabbed: false, target: '#clipboardBox', 'removeParentSelector':removeParentSelector});
            $this.click();
        }
    });
    $('a.tag').live('click',function(evt){
        evt.preventDefault();
    });

    function scenario(hideOther) {
        if ($("#preparedQueryHolder").is(":visible")) {
            $('#showHideQueryButton').removeClass("headerQueryGreenButtonMoreHidden");
            $('#showHideQueryButton').addClass("headerQueryGreenButtonMore");
            $(".preparedQueryHolder").slideUp("slow");
        } else {
            $.post("/generator/preparedQuery", function(data) {
                $("#preparedQueryPlace").html(data);
                $('#showHideQueryButton').removeClass("headerQueryGreenButtonMore");
                $('#showHideQueryButton').addClass("headerQueryGreenButtonMoreHidden");
                $(".preparedQueryHolder").slideDown("slow");
                if(hideOther && ($("#searchHolder").css('display') != "none")){
                    searchToggle(false);
                }
            });
        }
    }
    function searchToggle(hideOther) {
        var visible = ($("#searchHolder").css('display') != "none");
        if (visible) {
            $('#showHideSearchButton').removeClass("headerSearchButtonMoreHidden");
            $('#showHideSearchButton').addClass("headerSearchButtonMore");
            $("#searchHolder").slideUp("slow");

        } else {
            $('#showHideSearchButton').removeClass("headerSearchButtonMore");
            $('#showHideSearchButton').addClass("headerSearchButtonMoreHidden");
            $("#searchHolder").slideDown("slow");
            if(hideOther && $("#preparedQueryHolder").is(":visible")){
                scenario(false);
            }
        }
    }

     function downloadPdf(url, iFrameId){
         var oIFrm = document.getElementById(iFrameId);
         oIFrm.src = url;
     }

    function simpleConfirm(text){
        return confirm(text);
    }
