function SaveForm(ID) {
            $("#saveform").attr("style","display:none");
            for (i=0; i<$("#"+ID+" :input").length; i++) {    
                    $("#url").append("&"+$("#"+ID+" :input")[i].id + "="+ $("#"+ID+" :input")[i].value); //формируем УРЛ
                    }

        $.ajax({
              type: "POST",
              url: "/cp/check.php",      
              data: $("#url").text(),
              timeout:15000,  
              success: function(html){ 
                $("#url").empty().append(html); 
                              
                if($("#error").attr("value") == 1) {                      
                  
                 alert($("#url").text());   
                 $("#saveform").removeAttr("style"); 
                 $("#url").empty();
                } else {             
                //$("#"+ID).empty();
                //$("#"+ID).append("<br><h1>"+html+"</h1>");
                jAlert(''+html+'', 'Результат запроса');

                }               
              }
                })};
				
				
function imgOpen(path,title,iWidth,iHeigth) {

    if ($(window).width() - iWidth < 200)
        {
       
            var inWidth = ($(window).width() - 200);
                   
        } else {
            
            var inWidth = parseInt(iWidth)+25;
             
           
       
        }
        
    if($(window).height() - iHeigth < 100) {
    
            var inHeigth = ($(window).height() - 100);
            
    }    else {
    
            var inHeigth = parseInt(iHeigth)+55;
    
    }             
    
    popupWin = window.open(path+'&w='+iWidth+'&h='+iHeigth,'new','0,0,0,0,0,toolbar=no,directories=no,menubar=no,resizable=1,scrollbars=1,width='+inWidth+',height='+inHeigth+',top=50,left=50'); 
    popupWin.focus(); 

}

function SendForm(IdForm, Script, IdOut, TypeOut)
{
  $("#" + IdForm).ajaxSubmit(
  {
    type: "POST",
    data: $("#url").text(),
    timeout:15000,
    url: Script,
    success: function(html)
    {
      $("#url").empty().append(html);
      if($("#error").attr("value") == 1)
      {
        jAlert($("#url").text());
        $("#saveform").removeAttr("style");
        $("#url").empty();
      }
      else
      {
        //$("#"+ID).empty();
        //$("#"+ID).append("<br><h1>"+html+"</h1>");
        jAlert(''+html+'', 'Результат запроса');
        reload();
      }
    }
  });
}

function InputFormat(Id, Format)
{
  $(function($)
  {
    if(Format == 'datee') Format  = "99/99/9999";
    if(Format == 'dateo') Format = "99/9999";
    if(Format == 'phone') Format = "9-999-9999999";
    $("#" + Id).mask(Format);
  });
}
