
 function isValidEmail(strEmail){
   validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
   
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
      return false;
    } 
    return true; 
}
 
  function sendComment(sType, oCaller, sSysLang) {
  
        if(sSysLang == "bg") {
             if(sType == "predlozenie") {
                 sTypeLabel = 'Предложение';
             }
             else if(sType == "pohvala") {
                 sTypeLabel = 'Похвала';
             }
             else if(sType == "kritika")  {
                sTypeLabel = "Критика";
             }
        }
        else if(sSysLang == "en") {
           if(sType == "predlozenie") {
               sTypeLabel = "Suggestion";
           }
          else if(sType == "pohvala") {
              sTypeLabel = "Comment";
          }
          else if(sType == "kritika" ) {
             sTypeLabel = "Criticism";
          }
        }
  
        var aPosition = oCaller.position();
        $("#type").attr('value', sType);
        $("#cType").empty().html(sTypeLabel);
        $("#comments").css({ left: (aPosition.left+100), top: (aPosition.top-180)  }).show();
  }
  
  function submitComments(sName, sEmail, sComment, sType) {
  
      if(sName == '') {
          $("#comments_error").empty().html('Моля, въведете име.');
      }
  
      else if(!isValidEmail(sEmail)) {
          $("#comments_error").empty().html('Моля въведете валиден емайл.');
      }
      
      else if(sComment == '' ) {
         $("#comments_error").empty().html('Моля, въведете коментар.');
      }
      
      else{
         $.post("/includes/ajax_scripts/saveComment.php",( {  comment_name: sName, comment_email: sEmail, comment_text: sComment, type: sType   }  ), 
         function(databack) {
              $("#comments").hide();
         }); 
      }
  
  }