function checkForm(name_form)
{
	var Form = document.getElementsByName(name_form);
	if (Form != null)
	{
		var tElement = document.body.getElementsByTagName("input");
		for (var i=0; i<tElement.length; i++)
		{
			if ((tElement[i].getAttribute('required') != null) && (tElement[i].getAttribute('required') != '') && (tElement[i].value == ''))
			{
				alert(tElement[i].getAttribute('required'));
				tElement[i].focus();
				return false;
			}
			if ((tElement[i].getAttribute('equal') != null) && (tElement[i].getAttribute('equal') != ''))
			{
				var t = tElement[i].getAttribute('equal');
				eval("var tt = document.forms." + name_form+ "." + t);
				if ((tt != null) && (tt.value != tElement[i].value))
				{
					alert(tElement[i].getAttribute('equaltext'));
					tt.focus();
					return false;
				}
			}
			if ((tElement[i].getAttribute('minlength') != null) && (tElement[i].getAttribute('minlength') != '') && (tElement[i].value.length < tElement[i].getAttribute('minlength')))
			{
				alert(tElement[i].getAttribute('mintext'));
				tElement[i].focus();
				return false;
			}

			if ((tElement[i].getAttribute('name') == 'email') && (tElement[i].value != ''))
			{
				if (!echeck(tElement[i].value)) {
					tElement[i].focus();
					alert("Enter Correct Email!!");
					return false;
					}
			}

		}

		updateRTEs();
		return true;
	}
	else
	{
		return fasle;
	}
}

function confirmDelete(question, where)
{
	temp = window.confirm(question);
	if (temp) //delete
	{
		window.location=where;
	}
}

function open_window(link,w,h) //opens new window
{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
	wishWin = window.open(link,'wishWin',win);
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true;					
}

function startSearch(){
      searchString = document.searchForm.searchText.value; 
      searchString = escape(searchString); 

      if(searchString != "")
      {
        var finalSearchString = document.searchForm.whichEngine.options[document.searchForm.whichEngine.selectedIndex].value + searchString;
		window.open(finalSearchString, "_blank");
      }
	  else
	  {
		alert('Ââåäèòå ñòðîêó ïîèñêà!');
	  }
      return false;
}