
function validate_comment_form_not_loggedin(form, url, body, name, email, csrf, record_id, photonotable, article_photonote) {
  $('#script_div').load(url, { 'comment[body]': body, 'comment[author_name]': name, 'comment[author_email]': email, 'comment[_csrf_token]': csrf, 'comment[record_model]': 'article', 'comment[record_id]': record_id, 'photonotable': photonotable, 'article_photonote': article_photonote }, function() { });
}

function validate_comment_form_loggedin(form, url, body, csrf, record_id, photonotable, article_photonote) {
  $('#script_div').load(url, { 'comment[body]': body, 'comment[_csrf_token]': csrf, 'comment[record_model]': 'article', 'comment[record_id]': record_id, 'photonotable': photonotable, 'article_photonote': article_photonote }, function() { });
}

function validate_photonote_form(form, url, subject, body, name, email, csrf, the_article_id, x, y) {
  $('#script_div').load(url, { 'photo_note[subject]': subject, 'photo_note[body]': body, 'photo_note[author_name]': name, 'photo_note[author_email]': email, 'photo_note[_csrf_token]': csrf, 'photo_note[article_id]': the_article_id, 'photo_note[x]': x, 'photo_note[y]': y }, function() { });
}

function validate_photonote_form_loggedin(form, url, subject, body, csrf, the_article_id, x, y) {
  $('#script_div').load(url, { 'photo_note[subject]': subject, 'photo_note[body]': body, 'photo_note[_csrf_token]': csrf, 'photo_note[article_id]': the_article_id, 'photo_note[x]': x, 'photo_note[y]': y }, function() { });
}

function validate_article_form(form, url, file, title, body, csrf, article_type_id, subcategory_id) {
  $('#wait_loader').show();
  $('#script_div').load(url, { 'article[file]': file, 'article[title]': title, 'article[body]': body, 'article[_csrf_token]': csrf, 'article[article_type_id]': article_type_id, 'article[subcategory_id]': subcategory_id }, function() { $('#wait_loader').hide(); });
}

function form_hints(){
  $('form .form_input_text')
  .each(function(idx,elem)
  {
    if($(this).val() != $(this).attr('title'))
      $(this).addClass('focused')
    $(elem).focus(function(){
      $(this).addClass('focused');
      if($(this).val() == $(this).attr('title'))
        $(this).addClass('focused').val('');
    });
    $(elem).blur(function(){
      if($(this).val() == '')
        $(this).val($(this).attr('title'));
      if($(this).val() == $(this).attr('title'))
          $(this).removeClass('focused')
    });
  });
}

$(document).ready(function(){ form_hints(); });
