﻿/**
 * $Id: main.js 2322 2008-02-05 13:32:51Z javer $
 *
 * @copyright Copyright (c) 2007-2008, Effective Solution Band Ltd, All rights reserved.
 * @url http://www.esb.com.ua
*/

function _$(id){
  return document.getElementById(id);
}

function $(id){
  return document.getElementById(id);
}

function reloadCaptcha(){
  _$('imgCaptha').src = g_base_url + 'captcha.php?' + Math.round(Math.random(0)*1000)+1;
}

function reloadCaptchaLight(){
  _$('imgCaptha').src = g_base_url + 'captcha_light.php?' + Math.round(Math.random(0)*1000)+1;
}

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}

function sendFeedbackForm()
{
//  var pattern_text = /^[^\s]+$/;
  var pattern_text = /^\s*$/;
  var pattern_email = /^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/;

  if(pattern_text.test(trim(_$('feedback_fio').value)))
  {
    alert(localization.web_feedback_error_fio);
    return false;
  }

  if(pattern_email.test(trim(_$('feedback_email').value)) === false)
  {
    alert(localization.web_feedback_error_email);
    return false;
  }

  if(pattern_text.test(trim(_$('feedback_subject').value)))
  {
    alert(localization.web_feedback_error_subject);
    return false;
  }

  if(pattern_text.test(trim(_$('feedback_message').value)))
  {
    alert(localization.web_feedback_error_message);
    return false;
  }

  if(pattern_text.test(trim(_$('security_code').value)))
  {
    alert(localization.web_feedback_error_security_code);
    return false;
  }

  return true;
}
