/**
  * вспомогательные функции (голосование, проверки валидности и т.п.)
  *
  */

                                  function GetVoice(upd) 
                                  {
                                  if (upd == -1) alert("Извините, голосовать можно только один раз."); 
                                  else if (upd == 1) alert("Спасибо, Ваш голос учтен."); 
                                  else alert("Извините, произошел сбой, повторите голосование, пожалуйста");  
                                  }
                                  function checkVote() 
                                  {
                                  // проверка корректности голосования
                                  //   alert("<?php echo $_COOKIE["Voted"]?>");
                                  //   return false;
                                  var mess = "";
                                  var res = true;
                                  checked=0;
                                  for (var i=0;i<5;i++) 
                                  {
                                   if ((document.voteForm.reply[i]) && (document.voteForm.reply[i].checked))
	                                checked++;
	                          }
                                  if(checked < 1)
                                  {
                                  mess += "Выберите один из вариантов ответа!\n";
                                  res = false;
                                  }
                                  if (mess!="") {alert(mess);}
                                  return res;
                                   }

                                  function showVoteResults(voteId)
                                  {
                                  var w=Math.round(0.62*screen.width);
                                  var h=Math.round(0.35*screen.height);
                                  var left=(screen.width-w)/2;
                                  var top=(screen.height-h)/2;
                                  left=Math.round(left);
                                  top=Math.round(top);
                                  var options="width="+w+",height="+h+",left="+left+",top="+top+",resizable=1";
                                  window.open("/votes/showvote.php?id="+voteId, "Second", options);
                                  return false;
                                  }

function MyLTrim(Orig,ExeptVal)
  {
   var text=new String("");
   var startIdx=0;
   var step=new String("");
   step=Orig.substring(startIdx,startIdx+ExeptVal.length);
   while (step==ExeptVal)
    {
     startIdx=startIdx+ExeptVal.length;
     step=Orig.substring(startIdx,startIdx+ExeptVal.length);
    }
   text=Orig.substr(startIdx);
   return text;
  }

function checkSubscribesInfo() 
  {
  var userMail=MyLTrim(MyLTrim(document.getElementById("subscribes_email").value," "),"\r\n");
  if(userMail=="" || userMail=="@" || userMail.length<6)
    {
     alert("Введите корректный e-mail!");
     return false;
	}
  return true;
}



