  /* Настройка для lib jquery ----------------------------------------------- */ 
  $(document).ready(function(){
      $('.round, .legend').cornerz({radius:2});       
      $('.boxes_body').cornerz({radius:2,corners:'bl br'});      
      $('.title').tooltip({track: true, extraClass: "tt"});
      $('a').click(function(){this.blur();});
      $('a').focus(function(){this.blur();});
      $('#noscript').hide();
  
      /* caption on images */
      $('.boxgrid.captionfull').hover(function(){
          $(".cover", this).stop().animate({top:'122px'},{queue:false,duration:150});
      }, function() {
          $(".cover", this).stop().animate({top:'182px'},{queue:false,duration:150});
      });

  });
  
  function textCounter(field, countfield, maxlimit){ 
	  if (field.value.length > maxlimit){ 
		  field.value = field.value.substring(0, maxlimit);
	  } else { 
		  countfield.value = maxlimit - field.value.length;
	  }
  }

  if ('undefined' == typeof String.prototype.ltrim) {
    String.prototype.ltrim = function() {
      return this.replace(/^\s+/, '');
    }
  }

  if ('undefined' == typeof String.prototype.rtrim) {
    String.prototype.rtrim = function() {
      return this.replace(/\s+$/, '');
    }
  }

  if ('undefined' == typeof String.prototype.trim) {
    String.prototype.trim = function() {
      return this.replace(/^\s+/, '').replace(/\s+$/, '');
    }
  }
  
  function confirm(message, callback) {
	  $('#basic-modal-content').modal({		  
		  //overlayId:'simplemodal-overlay',
		  //containerId:'simplemodal-container', 
		  onShow: function (dialog) {
			  $('.text_popup', dialog.data[0]).append(message);
		    $('.submit', dialog.data[0]).click(function () {
			    if ($.isFunction(callback)) {
            callback.apply();
          }
			    $.modal.close();
		    });			  
	    }
	  });
  }

  function CheckFeedBack(){
    
    form = document.feedback;

    if (form.name.value.trim() == "Ваше имя:") {      
      confirm("Введите, пожалуйста, Ваше имя.", function(){form.name.focus();});             
      return false;
    }
  
    if (form.phone.value.trim() == "Контактный телефон:") {
      confirm("Введите, пожалуйста, контактный телефон, например: +7 (4232) 12-34-56.", function(){form.phone.focus();});
      return false;
    }
  
    if (form.email.value.trim() == "Ваш e-mail:") {
      confirm("Введите, пожалуйста, Ваш e-mail.", function(){form.email.focus();});
      return false;
    }
    
    if((form.email.value.indexOf("@")<1) && (form.email.value.indexOf(".")<1)){
      confirm("Неверно введен е-mail. Введите e-mail в виде something@server.com", function(){form.email.focus();});
      return false;
    }

    if (form.message.value == "Сообщение:") {
      confirm("Введите, пожалуйста, сообщение.", function(){form.message.focus();});
      return false;
    }
    
    if (form.securecode.value == "") {
      confirm("Введите, пожалуйста, секретный код.", function(){form.securecode.focus();});
      return false;
    }

    if (hex_md5(form.securecode.value) != form.securecode_hash.value) {
      confirm("Неправильный секретный код.", function(){form.securecode.focus();});    
      return false;
    }
    return true;
  }
  

