
//---------------------------------------------------------------------------------------------------

   function loadPage(bodyContent,headerFile,footerFile,shortMenuContent,menuContent,jQueryFunctions,containers)
   {
      $(document).ready(function(){
                                     $.ajaxSetup({cache:false, contentType: "text/html; charset:utf-8"})
                                     maximize();
                                     $('#contentJQuery').parent().hide()
                                     $('#contentHeader').load(headerFile);
                                     $('#contentFooter').load(footerFile);
                                     footerUserInfo()
                                     $('#contentShortMenu').html(shortMenuContent)
                                     $('#shortMenu').jqDock({align:'top',labels:'bc',coefficient:1,distance:50,duration:100,size:36})

                                     $('#contentBody').html(bodyContent);
                                     for(i=0;i<containers.length;i++)
                                        $(containers[i].box).html(containers[i].content)
                                     $('#contentJQuery').html("<SCRIPT TYPE='text/javascript'>"+jQueryFunctions+"</SCRIPT>");

                                     if($('div').is('#contentMenu')==true)
                                     {
                                        $('#contentMenu').html(menuContent);
                                        ddsmoothmenu.init({
   	                                                         mainmenuid: "menuContent", //Menu DIV id
	                                                           orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
	                                                           classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
	                                                                                        //customtheme: ["#804000", "#482400"],
	                                                           contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
                                                         })
                                        adjustHeight()
                                        alwaysCall()
                                     }

                                     $('a').live('click',function(event){
                                                                           if($(this).attr('title')!='noop' & queryStringKey($(this).attr('href'),'title')!='noop')
                                                                           {
                                                                              $('#hideAfterClick').hide(300)
                                                                              jQueryFunctions=queryStringKey($(this).attr('href'),'functions')
                                                                              ajaxInProgress()
                                                                              $.get($(this).attr('href'),function(data){
                                                                                                                          if(data!='')
                                                                                                                          {
                                                                                                                             maximize();
                                                                                                                             destroyModalDialogs()
                                                                                                                             $('#contentBody').html(data)
                                                                                                                             adjustHeight()
                                                                                                                             alwaysCall()
                                                                                                                          }
                                                                                                                          $('#contentJQuery').html("<SCRIPT TYPE='text/javascript'>"+jQueryFunctions+";serviceForm()</SCRIPT>")

                                                                                                                       });
                                                                              event.preventDefault()
                                                                              return false;
                                                                           }
                                                                        });
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function keepSession()
   {
      $(document).ready(function(){
                                    setInterval("$.get('control.php5?op=keepSession');",180000);
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function queryStringKey(address,key)
   {
      var queryString=address.substring(address.indexOf('?')+1,address.length)
      var arrValuesKeys=new Array()

      arrValuesKeys=queryString.split('&')
      for(var i=0;i<arrValuesKeys.length;i++)
      {
         if(arrValuesKeys[i].split("=")[0] == key)
            return arrValuesKeys[i].split("=")[1];
      }
   }

//---------------------------------------------------------------------------------------------------

   function eventSendForm(customBehavior)
   {
      $(document).ready(function(){
                                     $('#insert,#update').click(function(){
                                                                             $('ul.formTab').hide()
                                                                             $('#tabs').tabs('destroy')
                                                                          })
                                     $('input[type="submit"]').click(function(){sendForm(this,customBehavior)})
                                     $('input[name="filterCondition0"]').keypress(function(e){
                                                                                                if((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
                                                                                                   sendForm(this,customBehavior)
                                                                                             })
                                 })
   }

//---------------------------------------------------------------------------------------------------


   function sendForm(formant,customBehavior)
   {

      if($(formant).attr('name')=='cancel')
      {
         $('a.MultiFile-remove').click()
         $('form *').removeClass('required')
      }

      theForm=$(formant).parents('form')

      if(customBehavior==null || customBehavior.constructor!=Array)
         customBehavior=Array({},{})

      if($('input[name="functions"]',theForm).val()==null)
      {
         if((functionExists('afterSend_'+theForm.attr('name'))==true))
            jQueryFunctions='afterSend_'+theForm.attr('name')+'()'
         else
            jQueryFunctions=""
      }
      else
         jQueryFunctions=$('input[name="functions"]',theForm).val()

      operation=theForm.attr('name')+'_'+$(formant).attr('name')

      if($('input[name="op"]',theForm).val()!='noop')
         noop=false
      else
         noop=true

      $('input[name="op"]').attr('value',operation)
      ajaxInProgress()

      var options={
                     contentType: "application/x-www-form-urlencoded",
                     success:     function(data){
                                                   maximize();
                                                   destroyModalDialogs()
                                                   $('#contentBody').html(data)
                                                   adjustHeight()
                                                   alwaysCall()
                                                   $('#contentJQuery').html("<SCRIPT TYPE='text/javascript'>"+jQueryFunctions+";serviceForm();</SCRIPT>")
                                                }
                  }

      if(noop==true)
         return true;

//      $('ul.formTab').hide()
//      $('#tabs').tabs('destroy')

      theForm.validate({
                           submitHandler: function(){
                                                       theForm.ajaxSubmit(options)
                                                    },
                           invalidHandler: function(form,validator){
                                                                      $('ul.formTab').show()
                                                                      $('#tabs').tabs({fx:{opacity:'toggle'}})
                                                                      var invalidElements=validator.invalidElements()
                                                                      $('#tabs').tabs('select','#'+$('#'+invalidElements[0].id).parents('div.formTab').attr('id'))
                                                     },
                           errorPlacement:function(error,element){
                                                                     error.insertAfter(element)
                                                                 },
                           rules:customBehavior[0],
                           messages:customBehavior[1]
                        })
   }

//---------------------------------------------------------------------------------------------------

   function serviceForm()
   {
      $(document).ready(function(){
                                     if(document.forms.length>0)
                                     {
                                        formFieldsHighlight()
                                        $('form').each(function(i){
                                                                     formName=$(this).attr('name')
                                                                     submitOnEnter();
                                                                     $(this).append("<INPUT NAME='op' TYPE='hidden' VALUE=''>")

                                                                     if($('input[name="_edit"]',this).val()=='true')
                                                                     {
                                                                        $('textarea[readonly="readonly"]').each(function(j){
                                                                                                                              disableIframe($(this).attr('id'))
                                                                                                                              $('#d'+$(this).attr('id')).attr('contentEditable','false')
                                                                                                                           })
                                                                     }

                                                                     if($('input[name="_show"]',this).val()=='true')
                                                                     {
                                                                        disableFormFields(formName)
                                                                        $('textarea').each(function(j){
                                                                                                         disableIframe($(this).attr('id'))
                                                                                                      })
                                                                        $('.required').attr('title','')
                                                                        $('form *').removeClass('required')
                                                                     }

                                                                     if($('input[name="_search"]',this).val()=='true')
                                                                     {
                                                                        $('.required').attr('title','')
                                                                        $('form *').removeClass('required')
                                                                     }


                                                                     $("input:text:visible:enabled:first").focus().focus()

                                                                     multiselectableService()

                                                                     if($('input[name="functions"]',this).val()==null)
                                                                     {
                                                                        if(functionExists('beforeSend_'+formName)==true)
                                                                           customBehavior=eval('beforeSend_'+formName+'()')
                                                                        else
                                                                           customBehavior=""

                                                                        if($('input[name="_search"]',this).val()=='true')
                                                                           eventSendForm()
                                                                        else
                                                                           eventSendForm(customBehavior)
                                                                     }
                                                                     else
                                                                        eventSendForm()

                                                                     $('ul.formTab').show()
                                                                     $('#tabs').tabs({fx:{opacity:'toggle'}})
                                                                  })
                                     }
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function hideMenu()
   {
      $(document).ready(function(){
                                     $('#contentMenu').parent().hide('slow')
                                     $('#hideMenu').css('display','none')
                                     $('#showMenu').css('display','inline')
                                     $('body').bind('mouseover',function(event){
                                                                                  if(event.pageX<=10)
                                                                                  {
                                                                                     $('#contentMenu').parent().show('slow')
                                                                                  }
                                                                                  if(event.pageX>=((screen.width)/2))
                                                                                  {
                                                                                     $('#contentMenu').parent().hide('slow')
                                                                                  }
                                                                               })

                                  })
   }

//---------------------------------------------------------------------------------------------------

   function showMenu()
   {
      $(document).ready(function(){
                                     $('body').unbind('mouseover')
                                     $('#contentMenu').parent().show('slow')
                                     $('#hideMenu').css('display','inline')
                                     $('#showMenu').css('display','none')
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function formFieldsHighlight()
   {
      $(document).ready(function(){
                                     $('input,textarea').focus(function(){
                                                                            $(this).addClass('formFieldsHighlight')
                                                                         })
                                     $('input,textarea,checkbox').blur(function(){
                                                                                    $(this).removeClass('formFieldsHighlight')
                                                                                 })
                                  })
   }


//---------------------------------------------------------------------------------------------------

   function adjustHeight()
   {
      $('#contentMenu').parent().css('height','')
      boundsFooter = $('#contentFooter').parent().bounds()

      if($('div').is('#contentShortMenu')==true)
         boundsHeader = $('#contentShortMenu').parent().bounds()
      else
         boundsHeader = $('#contentHeader').parent().bounds()

      $('#contentMenu').parent().css('height',boundsFooter.top-boundsHeader.bottom)
   }

//---------------------------------------------------------------------------------------------------

   function ajaxInProgress()
   {
      if(CFG_BUSY_VISUALIZE==true)
      {
         $('.loading').ajaxError(function(){$(this).hide()})

         topPos=$('#contentHeader').parent().bounds().bottom
         bottomPos=$('#contentFooter').parent().bounds().top
         $('.loading').ajaxStart(function(){$(this).css('height',bottomPos-topPos).css('top',topPos)
                                            $(this).css('background-position','center '+1+'px')
                                            $(this).show()})
         $('.loading').ajaxComplete(function(){$(this).hide()})
      }
   }

//---------------------------------------------------------------------------------------------------

   function alwaysCall()
   {
      $(document).ready(function(){
                                     htmlEditor()
                                     $('input[type="submit"],input[type="button"]').css('cursor','pointer')
                                     $('.dateForm').mask("9999/99/99")
                                     deletePrintColumnsService()
                                     modalsService()
                                     headerFilterService()
                                     multiFileService()
                                     $("td:empty").text(" ");
                                     dynaTreeService()
                                     listSearch()
                                     databaseSearch()
                                     calendarsService()
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function listSearch()
   {
      $(".listSearchIcon,.listShowIcon").click(function(){
                                               iconClickedId=$(this).attr('id')
                                               $('.listSearch').each(function(){
                                                                                   idSelect=$(this).attr('name')
                                                                                   if((iconClickedId=="listSearchIcon"+idSelect) | (iconClickedId=="listShowIcon"+idSelect))
                                                                                   {
                                                                                      if($('#'+idSelect).css('display')=='none')
                                                                                      {
                                                                                         searchValue=$("#listSearchInput"+idSelect).val()
                                                                                         $('#'+idSelect+" option[selected]").removeAttr("selected")
                                                                                         $("#"+idSelect+" option:contains("+searchValue+"):first").attr("selected","selected");
                                                                                         $("#listSearchSpan"+idSelect).hide()
                                                                                         $("#"+idSelect).show()
                                                                                         $("#listShowIcon"+idSelect).hide()
                                                                                         $("#listSearchIcon"+idSelect).show()
                                                                                      }
                                                                                      else
                                                                                      {
                                                                                         $("#"+idSelect).hide()
                                                                                         $("#listSearchSpan"+idSelect).show()
                                                                                         $("#listShowIcon"+idSelect).show()
                                                                                         $("#listSearchIcon"+idSelect).hide()
                                                                                      }
                                                                                   }
                                                                                })
                                            })
   }

//---------------------------------------------------------------------------------------------------

   function databaseSearch()
   {
      $(".databaseSearchIcon,.databaseShowIcon").click(function(){
                                               iconClickedId=$(this).attr('id')
                                               $('.databaseSearch').each(function(){
                                                                                   idSelect=$(this).attr('name')
                                                                                   if((iconClickedId=="databaseSearchIcon"+idSelect) | (iconClickedId=="databaseShowIcon"+idSelect))
                                                                                   {
                                                                                      if($('#'+idSelect).css('display')=='none')
                                                                                      {
                                                                                         searchValue=$("#databaseSearchInput"+idSelect).val()

                                                                                         $.getJSON('control.php5?op='+$('#databaseSearchFunc'+idSelect).attr('name'),
                                                                                         {typedText:searchValue},
                                                                                         function populateListBox(json){
                                                                                                                          var options=""
                                                                                                                          for (var i=0;i<json.length;i++)
                                                                                                                             options+="<option value="+json[i].optionValue+">"+json[i].optionDisplay+"</option>;";
                                                                                                                          $('#'+idSelect).html(options);
                                                                                                                       })
                                                                                         $("#databaseSearchSpan"+idSelect).hide()
                                                                                         $("#"+idSelect).show()
                                                                                         $("#databaseShowIcon"+idSelect).hide()
                                                                                         $("#databaseSearchIcon"+idSelect).show()
                                                                                      }
                                                                                      else
                                                                                      {
                                                                                         $("#"+idSelect).hide()
                                                                                         $("#databaseSearchSpan"+idSelect).show()
                                                                                         $("#databaseShowIcon"+idSelect).show()
                                                                                         $("#databaseSearchInput"+idSelect).show()
                                                                                         $("#databaseSearchIcon"+idSelect).hide()
                                                                                      }
                                                                                   }
                                                                                })
                                            })
   }

//---------------------------------------------------------------------------------------------------

   function multiFileService()
   {
      $(".multi").MultiFile({
                               list:'#fileList',
                               STRING:{
                                         remove:'<img src="images/delete.gif" style="border:0;" alt="x"/>',
                                         selected:MSG_SELECTED+': $file',
                                         denied:MSG_FILE_TYPE_PROHIBITED+': $ext',
                                         duplicate:MSG_FILE_ALREADY_CHOOSEN+':\n$file'
                                      }
                            })
   }

//---------------------------------------------------------------------------------------------------

   function dynaTreeService(expanded)
   {
      if(expanded==true)
         $('#tree li').addClass('expanded')

      $('#tree').dynatree({
                              onActivate: function(dtnode){
                                                             if(dtnode.data.url)
                                                             $.ajax({
                                                                    type: "GET",
                                                                    url: dtnode.data.url,
                                                                    data: dtnode.data.key,
                                                                    success: function(data){
                                                                                              maximize();
                                                                                              destroyModalDialogs()
                                                                                              $('#contentBody').html(data);
                                                                                              $('input[type="submit"]').bind('click',function(){serviceForm()})
                                                                                              adjustHeight()
                                                                                              alwaysCall()
                                                                                              serviceForm()
                                                                                           }
                                                                    })
                                                          }
                         })
      if(expanded!=true)
      {
         dynaTreeExpand()
         dynaTreeCollapse()
      }
   }

//---------------------------------------------------------------------------------------------------

   function dynaTreeExpand()
   {
      $('#expand').click(function(){
                                      $("#tree").dynatree("getRoot").visit(function(dtnode){
                                                                                              dtnode.expand(true);
                                                                                           })
                                      return false
                                   })
   }


//---------------------------------------------------------------------------------------------------

   function dynaTreeCollapse()
   {
      $('#collapse').click(function(){
                                      $("#tree").dynatree("getRoot").visit(function(dtnode){
                                                                                              dtnode.expand(false);
                                                                                           })
                                      return false
                                   })
   }

//---------------------------------------------------------------------------------------------------

   function multiselectableService()
   {
      $('select[multiple]').multiSelect({selectAllText:'['+MSG_SELECT_ALL+']',
                                                      noneSelected:'',
                                                      oneOrMoreSelected:'*'
                                       });
   }

//---------------------------------------------------------------------------------------------------

   function deletePrintColumnsService()
   {
      $('#printIcon,#deleteIcon').mouseover(function(){
                                                         $(this).css('cursor','pointer')
                                                      })
      $('#printIcon').click(function(){
                                         $('input[name="checkPrint[]"]').each(function(){
                                                                                           if($(this).is(':checked'))
                                                                                              this.checked=false
                                                                                           else
                                                                                              this.checked=true
                                                                                        })
                                      })
      $('#deleteIcon').click(function(){
                                          $('input[name="checkDelete[]"]').each(function(){
                                                                                             if($(this).is(':checked'))
                                                                                                this.checked=false
                                                                                             else
                                                                                                this.checked=true

                                                                                          })
                                       })
      $('#printForm').click(function(){dataPrint()})
      $('#printReport').click(function(){dataPrint()})
   }

//---------------------------------------------------------------------------------------------------

   function modalsService()
   {
      $('.requiredConfirmation').click(function(){
                                                    modalConfirmation($('#'+$(this).attr('id')).attr('name')+'ConfMsg',$(this).attr('id'))
                                                    return false
                                                 })

      $("#closeModalSortDialog").click(function(){$("#modalSortDialog").dialog('close')})
      $("#closeModalFilterDialog").click(function(){$("#modalFilterDialog").dialog('close')})

      $("#modalSortDialog").dialog({autoOpen:false,
                                    bgiframe:true,
                                    modal:true,
                                    width:273,
                                    minWidth:273,
                                    maxWidth:273,
                                    height:220,
                                    minHeight:220});
      $("#modalFilterDialog").dialog({autoOpen:false,
                                      bgiframe:true,
                                      modal:true,
                                      width:490,
                                      minWidth:490,
                                      maxWidth:490,
                                      height:240,
                                      minHeight:240});

      $("#modalSortDialog *").attr('disabled','')
      $("#modalFilterDialog *").attr('disabled','')
      $('#sort').bind('click',function(){$("#modalSortDialog").dialog('open')})
      $('#filter').bind('click',function(){$("#modalFilterDialog").dialog('open')})
   }

//---------------------------------------------------------------------------------------------------

   function calendarsService()
   {
      $(".dateForm:not(:hidden)").datepicker({dateFormat:'yy/mm/dd',
                                  dayNames:[MSG_SUNDAY,MSG_MONDAY,MSG_TUESDAY,MSG_WEDNESDAY,MSG_THURSDAY,MSG_FRIDAY,MSG_SATURDAY],
                                  dayNamesShort:[MSG_SUN,MSG_MON,MSG_TUE,MSG_WED,MSG_THU,MSG_FRI,MSG_SAT],
                                  dayNamesMin:[MSG_SU,MSG_MO,MSG_TU,MSG_WE,MSG_TH,MSG_FR,MSG_SA],
                                  firstDay:1,
                                  gotoCurrent:true,
                                  changeYear:true,
                                  changeMonth:true,
                                  showOn:'button',
                                  buttonImage:'images/calendar.png',
                                  monthNames:[MSG_JANUARY,MSG_FEBRUARY,MSG_MARCH,MSG_APRIL,MSG_MAY,MSG_JUNE,MSG_JULY,MSG_AUGUST,MSG_SEPTEMBER,MSG_OCTOBER,MSG_NOVEMBER,MSG_DECEMBER],
                                  monthNamesShort:[MSG_JAN,MSG_FEB,MSG_MAR,MSG_APR,MSG_MAY,MSG_JUN,MSG_JUL,MSG_AUG,MSG_SEP,MSG_OCT,MSG_NOV,MSG_DEC],
                                  nextText:MSG_NEXT,
                                  prevText:MSG_PREV});

      $(".dateFilter:not(:hidden)").datepicker({dateFormat:'yy/mm/dd',
                                    dayNames:[MSG_SUNDAY,MSG_MONDAY,MSG_TUESDAY,MSG_WEDNESDAY,MSG_THURSDAY,MSG_FRIDAY,MSG_SATURDAY],
                                    dayNamesShort:[MSG_SUN,MSG_MON,MSG_TUE,MSG_WED,MSG_THU,MSG_FRI,MSG_SAT],
                                    dayNamesMin:[MSG_SU,MSG_MO,MSG_TU,MSG_WE,MSG_TH,MSG_FR,MSG_SA],
                                    firstDay:1,
                                    gotoCurrent:true,
                                    changeYear:true,
                                    changeMonth:true,
                                    monthNames:[MSG_JANUARY,MSG_FEBRUARY,MSG_MARCH,MSG_APRIL,MSG_MAY,MSG_JUNE,MSG_JULY,MSG_AUGUST,MSG_SEPTEMBER,MSG_OCTOBER,MSG_NOVEMBER,MSG_DECEMBER],
                                    monthNamesShort:[MSG_JAN,MSG_FEB,MSG_MAR,MSG_APR,MSG_MAY,MSG_JUN,MSG_JUL,MSG_AUG,MSG_SEP,MSG_OCT,MSG_NOV,MSG_DEC],
                                    nextText:MSG_NEXT,
                                    prevText:MSG_PREV});
   }

//---------------------------------------------------------------------------------------------------

   function headerFilterService()
   {
      $('.headerFilter').each(function(){
                                           i=1
                                           while($('div').is('#headerFilter'+i)==true & $('#headerFilter'+i).html()!='')
                                              i++
                                           $('#headerFilter'+i).html($(this).html())
                                           $('#headerFilter'+i).show()
                                      })

   }

//---------------------------------------------------------------------------------------------------

   function htmlEditor()
   {
      $(document).ready(function(){
                                     $('textarea:not(.nowysiwyg)').htmlarea({toolbar: [["bold","italic","underline","strikethrough"],
                                                                       ["increasefontsize","decreasefontsize"],
                                                                       ["orderedlist","unorderedlist"],
                                                                       ["indent","outdent"],
                                                                       ["justifyleft","justifycenter","justifyright"],
                                                                       ["link"]
                                                                      ],
                                                             toolbarText: $.extend({}, jHtmlArea.defaultOptions.toolbarText, {
                                                                       "bold": "pogrubiony",
                                                                       "italic": "kursywa",
                                                                       "underline": "podkreslony"
                                                                       })
                                                            });
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function maximize()
   {
      top.window.resizeTo(screen.availWidth-1,screen.availHeight-1);
      top.window.outerHeight=screen.availHeight;
      top.window.outerWidth=screen.availWidth;
      window.moveTo(0,0);
   }

//---------------------------------------------------------------------------------------------------

   function disableFormFields(theForm)
   {
      $(document).ready(function(){
                                     $('form[name='+theForm+'] input:not([type="submit"][type="button"][type="checkbox"][type="radiobutton"]),textarea').attr('readonly','readonly')
                                     $('form[name='+theForm+'] input[type="checkbox"],[type="radio"],select').attr('disabled','disabled')
                                 })
   }

//---------------------------------------------------------------------------------------------------
                                                                                                                          //4655a2     f1eff2
   function disableIframe(id)
   {
      $(document).ready(function(){
                                     $("#i"+id).after("<div id='d"+id+"' class='textarea' style='overflow:auto;padding:12px 10px 12px 10px;display:block;border-top:2px solid #aca899;border-left:2px solid #aca899;border-bottom:1px solid #f1eff2;border-right:1px solid #f1eff2'></div>")
                                     scrollWidth=($.browser.msie ? 23 : 19)
                                     $('#d'+id).width($('#i'+id).width()-scrollWidth)
                                     $('#d'+id).height($('#i'+id).height())
                                     $('#d'+id).html($('#'+id).text())

                                     $("#i"+id).css('display','none')
                                     $("#t"+id).css('display','none')
//                                     $("#i"+id).focus(function(){$('.jHtmlArea').focus()})
//                                     $("#t"+id).css('display','none')
                                 })
   }

//---------------------------------------------------------------------------------------------------

  function dataPrint()
  {
      $(document).ready(function(){
                                     $('input[type="submit"],input[type="button"]').hide()
                                     $('#contentHeader').parent().hide()
                                     $('#contentShortMenu').parent().hide()
                                     $('#contentMenu').parent().hide()
                                     $('#printColumnHeader').hide()
                                     $('.printColumn').hide()
                                     $('#printColumnFooter').hide()
                                     $('#deleteColumnHeader').hide()
                                     $('.deleteColumn').hide()
                                     $('#deleteColumnFooter').hide()
                                     $('#pager').hide()
                                     dynaTreeService(true)
                                     print()
                                    // $('#pager').show()
                                     $('#printBackIcon').show()
                                     $('#printLegend').show()
                                     $('#deleteColumnFooter').show()
                                     $('.deleteColumn').show()
                                     $('#deleteColumnHeader').show()
                                     $('#printColumnFooter').show()
                                     $('.printColumn').show()
                                     $('#printColumnHeader').show()
                                     $('#contentMenu').parent().show('slow')
                                     $('#contentShortMenu').parent().show('slow')
                                     $('#contentHeader').parent().show('slow')
                                     $('input[type="submit"],input[type="button"]').show()

                                 })
  }

//---------------------------------------------------------------------------------------------------

  function destroyModalDialogs()
  {
      $(document).ready(function(){
                                     $("#modalSortDialog").remove();
                                     $("#modalFilterDialog").remove();
                                     $(".requiredConfirmation").each(function(){
                                                                                  idMsg=$(this).attr('name')
                                                                                  $('.'+idMsg).remove()
                                                                               })
                                  })
  }

//---------------------------------------------------------------------------------------------------

   function modalMsg(wide)
   {
      $(document).ready(function(){
                                    $("#modalMessageDialog").dialog({autoOpen:true,
                                                                     bgiframe:true,
                                                                     modal:true,
                                                                     show:'slide',
                                                                     width:wide,
                                                                     buttons: {Ok: function(){
					                                                                                      $(this).dialog('close');
                                                                                                $("#modalMessageDialog").remove();
                                                                                             }
				                                                                      }
                                                                    });
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function modalConfirmation(idMsg,idSubmit)
   {
      $(document).ready(function(){
                                    $('#'+idMsg).dialog({autoOpen:true,
                                                         bgiframe:true,
                                                         modal:true,
                                                         show:'slide',
                                                         width:300,
                                                         buttons: {Nie: function(){
				                                                                             $(this).dialog('close');
                                                                                   },
                                                                   Tak: function(){
  				                                                                           $(this).dialog('close');
                                                                                     $('#'+idSubmit).trigger('submit');
                                                                                  }
				                                                            },
                                                          close: function(){
				                                                                      $(this).dialog('destroy')
			                                                                     }
                                                        });
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function functionExists(functionName)
   {
      var isFunc=eval('(typeof '+functionName+'==\'function\');')
      return isFunc
   }

//---------------------------------------------------------------------------------------------------

   function openWindow(URL)
   {
      newWin=window.open(URL,"_blank",'scrollbars=yes,toolbar=no,menubar=no,personalbar=no,directories=no,status=no,resizable=yes')
      newWin.resizeTo(screen.availWidth-20,screen.availHeight-20);
      newWin.moveTo(10,10);
      return false;
   }

//---------------------------------------------------------------------------------------------------

   function autoListboxPopulate(sourceListboxId,destinationListboxId,opQueryString)
   {
      $(document).ready(function(){
                                     $(sourceListboxId).change(function(){
                                                                            $.getJSON('control.php5?op='+opQueryString,
                                                                            {id:$(this).val()},
                                                                            function replaceListBox(json){
                                                                                                            var options=""
                                                                                                            for (var i=0;i<json.length;i++)
                                                                                                               options+="<option value="+json[i].optionValue+">"+json[i].optionDisplay+"</option>;";
                                                                                                            $(destinationListboxId).html(options);
                                                                                                         })
                                                                          })
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function forceLogout()
   {
      $(document).ready(function(){
                                     $("#menuLogout").click(function(){
                                                                         location.href = this.href+"&force=true";
                                                                      });
                                     $("#menuLogout").click();
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function submitOnEnter()
   {
      $(document).ready(function(){
	                                   $(".listSearchInput").keypress(function (e)
                                     {
		                                    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
                                        {
                                           $(".listSearchIcon").trigger('click');
                                           return false;
		                                    }
                                     })

	                                   $(".databaseSearchInput").keypress(function (e)
                                     {
		                                    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
                                        {
                                           $(".databaseSearchIcon").trigger('click');
                                           return false;
		                                    }
                                     })
                                  })
   }

//---------------------------------------------------------------------------------------------------

   function passwordPolicy(theForm,idPasswordField)
   {
      if($('input[name="_edit"]','form[name="'+theForm+'"]').val()=='true')
         $('#update','form[name="'+theForm+'"]').bind('click',function(){return checkPolicyRules(theForm,$('#passwordPolicy').attr('checked'),$('#key').val(),idPasswordField)})
   }

//---------------------------------------------------------------------------------------------------

   function checkPolicyRules(theForm,policy,idUser,idPasswordField)
   {
      if(policy==false || $('#'+idPasswordField).val()=='')
         return true;
      else
      {
         $.getJSON('control.php5?op=passwordPolicyJson',
                    {key:idUser,password:$('#'+idPasswordField).val()},
                    function checkPolicy(json){
                                                 if(json.passwordAllowed==true)
                                                 {
                                                    $('#update','form[name="'+theForm+'"]').unbind('click')
                                                    $('#update','form[name="'+theForm+'"]').submit()
                                                 }
                                                 else
                                                 {
                                                    $('form[name="'+theForm+'"]').append("<DIV ID='modalMessageDialog' CLASS='modalDialogContent'>"+MSG_PASSWORD_POLICY_NOT_MATCH+"<BR><BR>"
                                                                                                                                                   +"<U>"+MSG_PASSWORD_POLICY_RULES+"</U>:<BR>"
                                                                                                                                                   +MSG_PASSWORD_MIN_LENGTH+": "+json.minlength+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_MIN_NUMBERS+": "+json.minnumbers+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_MIN_SPECIALS+": "+json.minspecials+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_MIN_UPPER+": "+json.minupper+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_DAYS_VALID+": "+json.daysvalid+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_NUM_REMEMBER+": "+json.numremember+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_NUM_MISTAKES+": "+json.nummistakes+"<BR>"
                                                                                                                                                   +MSG_PASSWORD_DAYS_NO_LOGIN+": "+json.daysnologin
                                                                                                                                                   +"</DIV>")
                                                    modalMsg(400)
                                                 }
                                              }
                  )
      }
      return false
   }

//---------------------------------------------------------------------------------------------------

   function footerUserInfo()
   {
      $.getJSON('control.php5?op=formLogin_getUserNameJson',
                 {},
                 function getData(json){
                                          $('#footerInfo').html(json.userName)
                                             if(json.menuIcon=="menu")
                                                $('.footerMenuIcon').show()
                                       }
               )
   }

//---------------------------------------------------------------------------------------------------

   function dumpProps(obj)
   {
      var result = "";
      for (var i in obj)
         result += i + " = " + obj[i] + " \r\n "
      alert(result);
   }

//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
