  function postback(name)
  {
    document.forms[name].submit();
  }
    
  function changePhoto(dropdownlist)
  {
  var foto = document.getElementById('foto');

  foto.src = "../../Content/images/banners/" + dropdownlist.value;

  //document.getElementById('HdnProduct_image').value = filename;
  }
  
  /* Pagina formulier */
  function PostForm(dataString, elementIdToShow)
  {    
      dataString += "&redirect=1";
      $.ajax({
        type: "POST",
        url: "/admin/Menu/update.ashx",
        data: dataString,
        success: function() {
            var today = new Date();
            var h = today.getHours();
            var m = today.getMinutes();
            var s = today.getSeconds();
            var timeString = checkTime(h) + ":" + checkTime(m) + ":" + checkTime(s);
            $("#" + elementIdToShow).html("Opgeslagen op: " + timeString);
        }
      });
      return false;
  }
  


    function SubmitInBackground()
    {        
        if(CheckValid(true))
        {        
            var string = "test=test";
            
            $("input").each(function() {
                var type = $(this).attr('type');
                if(type == "checkbox")
                {
                    string += "&" + $(this).attr('name') + "=" + $(this).attr('checked');                    
                }
                else
                {
                    string += "&" + $(this).attr('name') + "=" + $(this).val();
                }
            });
            $("select").each(function() {
                  string += "&" + $(this).attr('name') + "=" + $(this).val();
            });        
            $("textarea").each(function() {
                    try
                    {
                        if(FCKeditorAPI)
                        {
                            var inst = FCKeditorAPI.GetInstance($(this).attr('id'));
                            if(inst != null)
                            {
                                var sValue = inst.GetHTML();
                                string += "&" + $(this).attr('name') + "=" + php_urlencode(sValue);
                               
                            }
                        }
                    }
                    catch(err)
                    {
                    
                    }
          
           });
           
           PostForm(string, "statusLabel");
        }
        else
        {
           
        }
    }
    
    function CheckValid(showErrors, level) {
        if(level == undefined || level == null)
        {
            level = 2;
        }
        var isValid = true;
        $("#errorRow").hide();
        $(".notEmpty").each(function() {
            $(this).parent().parent().removeClass('error');
           
            var currentValue = $(this).val();
            if($(this).attr("tagName").toLowerCase() == "textarea")
            {
                if(FCKeditorAPI != null)
                {
                    try
                    {
                        var inst = FCKeditorAPI.GetInstance($(this).attr('id'));
                        if(inst != null)
                        {
                            var sValue = inst.GetHTML();
                            currentValue = sValue;
                        }
                    } catch (err) { }
                }
            }
            if(currentValue == "")
            {              
                isValid = false;
                if(showErrors)
                {            
                    if(level == 1)
                    {
                        $(this).parent().addClass('error');
                    }
                    else
                    {        
                        $(this).parent().parent().addClass('error');
                    } 
                }
            }
            else
            {                
				    if(level == 1)
                    {
                        $(this).parent().removeClass('error');
                    }
                    else
                    {        
                        $(this).parent().parent().removeClass('error');
                    } 
            }         
        });
        
        $(".numeric").each(function() {
        
        });
        
        $(".numericNotNull").each(function() {
        
        });
        
        if(!isValid && showErrors)
        {
            $("#errorRow").show();
        }
        
        return isValid;   
    }    
    
    
    
    /* Algemene functies */
    function php_urlencode (str) {
        str = escape(str);
        return str.replace(/[*+\/@]|%20/g,
        function (s) {
            switch (s) {
            case "*": s = "%2A"; break;
            case "+": s = "%2B"; break;
            case "/": s = "%2F"; break;
            case "@": s = "%40"; break;
            case "%20": s = "+"; break;
            }
                return s;
            }
        );
    }
  function checkTime(i) {
    if (i<10)
    {
      i="0" + i;
    }
    return i;
  }
