

      // BASE


      function refresh()
      {
        var sURL = unescape(window.location.pathname);
        window.location.href = sURL;
      }

      function baseonload(base_url)
      {
            var base = "";
            var pars = $H({base: base}).toQueryString();

            new Ajax.Request(base_url + "index.php/admin/get_date_ajax",
                    {method:"post", parameters:pars, onSuccess:response_get_date});

      }

      function response_get_date(transport)
      {

           var data = transport.responseText;

           if (data)
            $('orddate').innerHTML = data + "&nbsp;&nbsp;&nbsp;";
      }

      function panel_click(panel)
      {
          var checkbox = "checker_" + panel.id;

          if ($(checkbox).checked)
            $(checkbox).checked = false;
          else
            $(checkbox).checked = true;
      }

      function panel_normal(panel)
      {
          panel.style.backgroundColor = 'white';
      }

      function panel_light(panel)
      {
          panel.style.backgroundColor = '#ece75e';
      }

      function clear_msg()
      {
          $('msg').style.display = 'inline';
          setTimeout("$('msg').innerHTML = '';$('msg').className= 'operation_none';",5000);
      }


      function clear_fck(name)
      {
          var fck = FCKeditorAPI.GetInstance(name);
          fck.SetHTML("");
      }

      function clear_form(form)
      {
          for (var i = 0; i < document.forms[form].elements.length; i++)
          {
              if (document.forms[form].elements[i].type == 'text' ||
                  document.forms[form].elements[i].type == 'password')
                document.forms[form].elements[i].value = "";
          }
      }


      function isInt(x)
      {
          var y = parseInt(x);
          if (isNaN(y))
            return false;
          return x==y && x.toString()==y.toString();
      }

      function hide_all()
      {
          var divs = document.getElementsByTagName('div');

          for (var i = 0; i < divs.length; i++)
          {
              if (!isInt(divs[i].id))
                $(divs[i].id).style.display = 'none';
          }
      }

      function hide_panel()
      {
          var foo = typeof document.forms['form_list'] != 'undefined';

          if (foo)
          {
          $('panel_list').style.display = 'none';
          }

          foo = typeof document.forms['form_edit'] != 'undefined';

          if (foo)
          {
          $('panel_edit').style.display = 'none';
          }

          foo = typeof document.forms['form_add'] != 'undefined';

          if (foo)
          {
          $('panel_add').style.display = 'none';
          }
      }

      function show_panel(form, panel)
      {
          hide_panel();
          clear_form(form);

          $(panel).style.display = 'inline';
      }

      function check_textbox(t, text)
      {
          if (t == '')
          {
            alert ('Заполните поле ' + text + ' !');
            return false;
          }

          return true;
      }


      function check_num(form, num)
      {
          var j = 0;
          for (var i = 0; i < document.forms[form].elements.length; i++)
          {
              if (document.forms[form].elements[i].type == 'checkbox')
                if (document.forms[form].elements[i].checked)
                  j++;
          }
          if ((j <= num) && (j != 0))
            return true;
          return false;
      }

      function get_prod()
      {

		var str = "";
		$$(".numof").each(function(e)
		{
			if (e.value != '')
			if (str != '')
                  	str = str + '&' + e.id + "=" + e.value;
                	else
                  	str = e.id + "=" + e.value;

		});
            return str;		
      }


      function check_mail(base_url, number_, name_, contact_, date_, phone_)
      {

		var num  = $('number').value;
		var nam = $('name').value;
		var con  = $('contact').value;
		var d  = $('date').value;
		var ph  = $('phone').value;
		var sh  = $('shop').value;

            if (check_textbox(num, number_))
		if (check_textbox(nam, name_))
		if (check_textbox(con, contact_))
		if (check_textbox(d, date_))
		if (check_textbox(ph, phone_))
            {
			var str = "";
			str = get_prod();
			
                var pars = $H({number:num, name: nam, contact:con, date:d, phone:ph, shop:sh, data:str }).toQueryString();

                new Ajax.Request(base_url + "index.php/sender/send_ajax",
                    {method:"post", parameters:pars, onSuccess:response_send});
            }
      }


      function response_send(transport)
      {

          var data = transport.responseText;

          switch (data)
          {
              case '0':
                alert("Письмо не отправлено. Произошла ошибка.");
                break;
              case '1':
			alert("Спасибо. Ваш заказ принят.");
                break;
          }
		
      }




