
function FormValContact(theForm)
{

  if (theForm.nom_name.value.length < 4)
      {
      alert("Моля, въведете име по-дълго от 3 символа!");
      theForm.nom_name.focus();
      return (false);
      }
      if (theForm.nom_msg.value == "")
      {
      alert("Въведи съобщение !");
      theForm.nom_msg.focus();
      return (false);
      }
   if (theForm.nom_email.value == "")
      {
      alert("Моля въведете E-mail адрес !");
      theForm.nom_email.focus();
      return (false);
	}
	if (theForm.nom_email.value.length < 7)
      {
      alert("Вашият E-mail адрес трябва да бъде по-дълъг от 6 символа !");
      theForm.nom_email.focus();
      return (false);
      }
	
  var checkStr = theForm.nom_email.value;

  if (checkStr.search(/@/)<0)
  {
    alert("Моля въведете валиден E-mail адрес !");
    theForm.nom_email.focus();
    return (false);
  }	
 
return (true);
}

function FormValLP(theForm)
{

  if (theForm.nom_name.value == "")
      {
      alert("Моля въведете потребителко име !");
      theForm.nom_name.focus();
      return (false);
      }
   if (theForm.nom_email.value == "")
      {
      alert("Моля въведете E-mail адрес !");
      theForm.nom_email.focus();
      return (false);
	}
	if (theForm.nom_email.value.length < 7)
      {
      alert("Вашият E-mail адрес трябва да бъде по-дълъг от 6 символа !");
      theForm.nom_email.focus();
      return (false);
      }
	
  var checkStr = theForm.nom_email.value;

  if (checkStr.search(/@/)<0)
  {
    alert("Моля въведете валиден E-mail адрес !");
    theForm.nom_email.focus();
    return (false);
  }	
 
return (true);
}

function FormValMail(theForm)
{
	if (theForm.nom_email.value == "")
      {
      alert("Моля въведете E-mail адрес !");
      theForm.nom_email.focus();
      return (false);
	}
	if (theForm.nom_email.value.length < 7)
      {
      alert("Вашият E-mail адрес трябва да бъде по-дълъг от 6 символа !");
      theForm.nom_email.focus();
      return (false);
      }
	
  var checkStr = theForm.nom_email.value;

  if (checkStr.search(/@/)<0)
  {
    alert("Моля въведете валиден E-mail адрес !");
    theForm.nom_email.focus();
    return (false);
  }	
}

function FormValB(theForm)
{

  if (theForm.nom_name.value == "")
      {
      alert("Моля въведете заглавие !");
      theForm.nom_name.focus();
      return (false);
      }
   if (theForm.nom_opis.value == "")
      {
      alert("Моля въведете описание !");
      theForm.nom_opis.focus();
      return (false);
      }
   if (theForm.nom_fee.value == "")
      {
      alert("Моля въведете миза !");
      theForm.nom_fee.focus();
      return (false);
	}
	
  var checkOK = "1234567890\t\r\n\f";
  var checkStr = theForm.nom_fee.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Моля използвайте само цифри !");
    theForm.nom_fee.focus();
    return (false);
  }
	if ((theForm.group_id.value == "#") || (theForm.group_id.value == ""))
      {
      alert("Моля изберете категория !");
      theForm.group_id.focus();
      return (false);
	}
	if (theForm.nom_date2.value == "")
      {
      alert("Моля въведете дата на приключване ДД-ММ-ГГГГ !");
      theForm.nom_date2.focus();
      return (false);
	}
	
	var curDate=new Date();
	var myDay=theForm.nom_date2.value.substring(0,2);
	var myMonth=theForm.nom_date2.value.substring(3,5);
	var myYear=theForm.nom_date2.value.substring(6,10);
	var myHour=theForm.nom_date2.value.substring(11,13);
	var myMin=theForm.nom_date2.value.substring(14,16);
	var mySec=theForm.nom_date2.value.substring(17,19);
	var nomDate=new Date(myYear,parseInt(myMonth,10)-1,myDay,myHour,myMin,mySec);
	curDate.setDate(curDate.getDate()+2); 
	if (curDate>=nomDate)       {
      alert("Датата не е валидна !");
      return (false);
	}
	
	if (theForm.opt_ii.value < 3)
      {
      alert("Моля въведете най-малко 2 отговора !");
      theForm.opt_name.focus();
      return (false);
	}
	
	var rad_val = 0;
	for (var i=0; i < theForm.my_ans.length; i++)
   {
   if (theForm.my_ans[i].checked)
      {
      var rad_val = theForm.my_ans[i].value;
      }
   }

	if (rad_val == 0 )
      {
      alert("Моля изберете вашия отговор !");
      return (false);
	}
	
	var type_val = 0;
	for (var i=0; i < theForm.nom_btype.length; i++)
   {
   if (theForm.nom_btype[i].checked)
      {
      var type_val = theForm.nom_btype[i].value;
      }
   }
   
	if (type_val == 0 )
      {
      alert("Моля въведете вид на облога !");
      return (false);
	}
	 
return confirm('Сигурен ли сте ?');
}

function FormValRR(theForm)
{

  if (theForm.nom_name.value == "")
      {
      alert("Моля въведете вашето име !");
      theForm.nom_name.focus();
      return (false);
      }
   if (theForm.nom_email.value == "")
      {
      alert("Моля въведете E-mail адрес !");
      theForm.nom_email.focus();
      return (false);
	}
    if (theForm.nom_email.value.length < 7)
      {
      alert("Вашият E-mail адрес трябва да бъде най-малко 6 символа !");
      theForm.nom_email.focus();
      return (false);
      }
      var checkStr = theForm.nom_email.value;

  if (checkStr.search(/@/)<0)
  {
    alert("Моля въведете валиден E-mail адрес !");
    theForm.nom_email.focus();
    return (false);
  }
     if (theForm.nom_password.value == "")
      {
      alert("Моля въведете парола !");
      theForm.nom_password.focus();
      return (false);
      }
      if (theForm.nom_password.value != theForm.nom_password2.value)
      {
      alert("Моля потвърдете паролата !");
      theForm.nom_password2.focus();
      return (false);
      }
  
return (true);
}

function FormValR(theForm)
{

  if (theForm.nom_name.value == "")
      {
      alert("Моля, въведете име !");
      theForm.nom_name.focus();
      return (false);
      }
   if (theForm.nom_email.value == "")
      {
      alert("Моля, въведете E-mail адрес !");
      theForm.nom_email.focus();
      return (false);
	}
    if (theForm.nom_email.value.length < 7)
      {
      alert("Вашият E-mail адрес трябва да бъде най-малко 6 символа !");
      theForm.nom_email.focus();
      return (false);
      }
	
  var checkStr = theForm.nom_email.value;

  if (checkStr.search(/@/)<0)
  {
    alert("Моля, въведете валиден E-mail адрес !");
    theForm.nom_email.focus();
    return (false);
  }
     if (theForm.nom_username.value.length < 4)
      {
      alert("Моля, въведете потребителско име по-дълго от 3 символа !");
      theForm.nom_username.focus();
      return (false);
      }
   if (theForm.nom_username.value.indexOf(' ') > -1)
      {
      alert("Потребителското име не трябва да съдържа празни полета !");
      theForm.nom_username.focus();
      return (false);
      }
  
  var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\t\r\n\f";
  var checkStr = theForm.nom_username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Потребителското име трябва да съдържа цифри от 0 до 9 и букви от A до Z !");
    theForm.nom_username.focus();
    return (false);
  }
     if (theForm.nom_password.value == "")
      {
      alert("Моля въведете парола !");
      theForm.nom_password.focus();
      return (false);
      }
      if (theForm.nom_password.value.indexOf(' ') > -1)
      {
      alert("Паролата не трябва да съдържа празни полета !");
      theForm.nom_password.focus();
      return (false);
      }
  
  var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\t\r\n\f";
  var checkStr = theForm.nom_password.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Паролата трябва да съдържа цифри от 0 до 9 и букви от A до Z !");
    theForm.nom_password.focus();
    return (false);
  }
      if (theForm.nom_password.value != theForm.nom_password2.value)
      {
      alert("Моля потвърдете паролата !");
      theForm.nom_password2.focus();
      return (false);
      }
	if (theForm.nom_agree.checked == false)
      {
      alert("Приемам общите условия за ползване и политиката на поверителност !");
      theForm.nom_agree.focus();
      return (false);
      }
  
return (true);
}

function getChecked(tip) {
  var theForm = document.nom_form;
  for (i=0; i<theForm.elements.length; i++) {
    if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].name!='nom_agree') {if (tip==0 ) theForm.elements[i].checked=true;if (tip==1) theForm.elements[i].checked=false;}
  }
}

function getMChecked(tip) {
  var theForm = document.msg_in_form;
  for (i=0; i<theForm.elements.length; i++) {
    if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].name!='nom_agree') {if (tip==0 ) theForm.elements[i].checked=true;if (tip==1) theForm.elements[i].checked=false;}
  }
}

function getM1Checked(tip) {
  var theForm = document.msg_out_form;
  for (i=0; i<theForm.elements.length; i++) {
    if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].name!='nom_agree') {if (tip==0 ) theForm.elements[i].checked=true;if (tip==1) theForm.elements[i].checked=false;}
  }
}

var xmlHttp

function vote(str,str1)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Броузърът ви не поддържа AJAX!");
  return;
  } 
var url="reg_vote.php";
url=url+"?opt="+str+"&bid="+str1;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function showHint(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Броузърът ви не поддържа AJAX!");
  return;
  } 
var url="getuser.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function show_optpic(cc)
{
	cont = "images_opt"+cc;
if (document.getElementById(cont).style.visibility=='visible') document.getElementById(cont).style.visibility = 'hidden'; else document.getElementById(cont).style.visibility = 'visible';
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}

function add_opt(str,ii)
{
dop_text = "<input type=hidden id=opt["+ii+"] name=opt["+ii+"] value=''><input type=hidden id=picopt"+ii+" name=picopt["+ii+"] value=''>";
dop_text = dop_text+"<input id='radiobutton_1' type='radio' name='my_ans' value='"+ii+"'> <label class='radioitem' for='radiobutton_1'>"+ii+". "+str+" - <a href='javascript: show_optpic("+ii+")'>Добави снимка</a></label>";
dop_text = dop_text+"<div class='img_opt' id='images_opt"+ii+"' align=center><div align=right><span class='date'>[x]</span> <a href='javascript: show_optpic("+ii+")' id='SmallLink'>Затвори</a></div><img id=opt_img"+ii+" src='images/space.gif' border=0><br><div id='iframe_container'><iframe class='myiframe1' name=optframe"+ii+" scrolling=no src='upload.php?c=images_opt"+ii+"&n=picopt"+ii+"&n1=opt_img"+ii+"' frameborder=0></iframe></div>";
document.getElementById("opt_container").innerHTML=document.getElementById("opt_container").innerHTML+dop_text;
document.getElementById("opt_ii").value = parseInt(document.getElementById("opt_ii").value) + 1;
document.getElementById("opt_name").value = "";
document.getElementById("opt["+ii+"]").value = addslashes(str);
}

function del_opt()
{ 
document.getElementById("opt_container").innerHTML="";
document.getElementById("opt_ii").value = 1;
document.getElementById("opt_name").value = "";
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("bet_opt").innerHTML=xmlHttp.responseText;
}
}

function stateChanged1() 
{ 
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=""; 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
if (document.getElementById('is_one')!=null) {document.getElementById('to_id').value = document.getElementById('is_one').value;document.getElementById('nom_user').value=document.getElementById('is_one_name').value;}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}



