// JavaScript Document

        var object= null;
        var cY = 0;

        var objScrBox;
        var objScrTrack;
        var objTxtBox;
        var objTxtMove;
        var objTxtRel;
        var objScrBar;

        var LimitTop = 0;
        var LimitBottom;
        var ScrollHeight;
        var Koef;

        function initPage()
        {
                document.onmousedown = pickIt;
                document.onmousemove = dragIt;
                document.onmouseup   = dropIt;

                objScrBox   = document.getElementById('ScrollBox');
                objScrTrack = document.getElementById('ScrollTrack');
                objScrBar   = document.getElementById('ScrollBar');
                objTxtBox   = document.getElementById('TextBox');
                objTxtMove  = document.getElementById('TextMoving');
                objTxtRel   = document.getElementById('TextRelative');

                objTxtRel.style.overflow = 'hidden';
                objTxtBox.style.width = objTxtMove.style.width = objTxtRel.style.width = '653px';

                var ScrollBoxHeight = (objScrTrack.offsetHeight*objTxtRel.offsetHeight)/objTxtMove.offsetHeight;
                ScrollBoxHeight = ( ScrollBoxHeight>30 ) ? ScrollBoxHeight : 30;

                objScrBox.style.height = (ScrollBoxHeight) + 'px';

                LimitBottom = objScrTrack.offsetHeight - objScrBox.offsetHeight;
                ScrollHeight= LimitBottom - LimitTop;

                if ( objTxtMove.offsetHeight>objTxtBox.offsetHeight )
                        objScrBar.style.visibility = 'visible';
                else {
                        objTxtBox.style.width =
                        objTxtRel.style.width =
                        objTxtMove.style.width =
                        (objScrBar.offsetLeft - objTxtBox.offsetLeft) + 'px';
                }

                Koef = (objTxtMove.offsetHeight-objTxtBox.offsetHeight)/ScrollHeight;
        }


        function pickIt(evt)
        {
                evt= (evt) ? evt : ( (window.event) ? event : null );
                var objectID = (evt.target) ? evt.target.id : ((evt.srcElement) ? evt.srcElement.id:null);
                if(objectID.indexOf('ScrollBox')!=-1 ) object= document.getElementById(objectID);
                if ( object )
                {
                        cY = evt.clientY - object.offsetTop;
                        return;
                }
                else
                {
                        object= null;
                        return;
                }
        }
        function dragIt(evt)
        {
                evt= (evt)?evt:((window.event)?event:null);
                if ( object )
                {
                        var top = evt.clientY - cY;
                        if ( top>=LimitTop && top<=LimitBottom ) {
                                object.style.top= top + 'px';
                                objTxtMove.style.top = -top*Koef + 'px';
                        }
                        return false;
                }
        }

        function dropIt()
        {
                if ( object )
                {
                        object= null;
                        return false;
                }
        }

        //By Yuriy: передача данных из формы в скрипт  MailProcessing.php
        $(document).ready(function()
        {
          $("#SendMailButton").click(function(){

             $.get("/../MailProcessing.php", {Email:$("#Email").val(), name: $("#Name").val()}, function(MailProcessing){
               if(MailProcessing)
               {
                  alert("Thanks")
                  $("#Email").val("");
                  $("#Name").val("");
               }
               else
                  alert("Cannot send letter on this E-mail")
             });
          });

          $("#SignUpSave").click(function(){
              $.get("/admin/modules/SavingSettings.php", {File: "SIGNUP", Value: $("#SignUp").val()}, function(SaveXML){
                        alert(SaveXML)
             });
          });

          //By Yuriy: передача данных из формы в скрипт  SaveSettings.php
          $("#SpecialAreaSave").click(function(){
              $.get("/admin/modules/SavingSettings.php", {
                File: "SAREA",
                HomeArea: $("#HomeArea").val(),
                GalleryArea: $("#GalleryArea").val(),
                ComSoonArea: $("#ComSoonArea").val(),
                WhHapArea: $("#WhHapArea").val(),
                AbUsArea: $("#AbUsArea").val(),
                WhChooseArea: $("#WhChooseArea").val(),
                ContUsArea: $("#ContUsArea").val()
                },
                function(SaveXML){
                      alert(SaveXML)
             });
          });
              $('#upload1').upload({
                  name: 'file',
                  method: 'post',
                  enctype: 'multipart/form-data',
                  action: '/admin/modules/Upload.php',

                  onSubmit: function() {
                   $('#progress1').text('Uploading file...');
                    //alert("Uploading complete")
                    },

                    onComplete: function(data) {
                                //data contains the response from the action url
                                $('#progress1').text('Your file was uploaded succesfuly');
                                if( typeof(data)=='undefined' ){
                                    alert('Failed to update the content!');
                                }
                                else{
                                     //$('#file_table').append(data);

                                     //$('#file_table').append('<td>' + data + '</td><td>empty...</td>');
                                     //$('#last_upload').text(data);
                                }
                                document.location.href = "";
                    }
              });

              $("#delete").click(function(){
                  var count=$("#count_files").val();
                  var a = new Array(count);
                  var id_string="";
                  for(var i=0; i<count; i++)
                  {
                    if($("#"+ i).attr("checked")==true)
                    {
                      id_string = id_string + i + "id" ;
                    }
                  }
                  $('#progress1').text('Deleting file(s)...');
                  $.get("/admin/modules/Upload.php", {
                    count_files: count,
                    string_id: id_string
                    },
                    function(Deleting){
                             //alert(Deleting)
                    });
                  document.location.href = "";
              });
        });
 //