function loadDownloadInfo(dest) {
	try 
	{
  		 xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){
	}
	xmlhttp.onreadystatechange = triggeredDownloadInfo;
	xmlhttp.open("GET", dest);
	xmlhttp.send(null);
}

function triggeredDownloadInfo() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive

if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
    // xmlhttp.responseText object contains the response.
//	 Protoload.stopWaiting(document.getElementById("page"));
    document.getElementById("download_link").innerHTML = xmlhttp.responseText;
	 execJS(document.getElementById("download_link"));
}
}

function loadURL(dest) {
	try 
	{
   		 xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){
	}
	xmlhttp.onreadystatechange = triggeredURL;
	xmlhttp.open("GET", dest);
	xmlhttp.send(null);
}

function triggeredURL() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive

if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
    // xmlhttp.responseText object contains the response.
//	 Protoload.stopWaiting(document.getElementById("page"));
    document.getElementById("callback").innerHTML = xmlhttp.responseText;
}
}

function loadPopup(dest) {
	try 
	{
   		 xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){
	}
	Protoload.startWaiting(document.getElementById("page"));
	xmlhttp.onreadystatechange = triggeredPopup;
	xmlhttp.open("GET", dest);
	xmlhttp.send(null);
}

function triggeredPopup() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive

if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
    // xmlhttp.responseText object contains the response.
//	 Protoload.stopWaiting(document.getElementById("page"));
    document.getElementById("popup").innerHTML = xmlhttp.responseText;
	 execJS(document.getElementById("popup"));
}
}

var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
var bMoz = (navigator.appName == 'Netscape');

function execJS(node) {
  var st = node.getElementsByTagName('SCRIPT');
  var strExec;
  for(var i=0;i<st.length; i++) {     
    if (bSaf) {
      strExec = st[i].innerHTML;
    }
    else if (bOpera) {
      strExec = st[i].text;
    }
    else if (bMoz) {
      strExec = st[i].textContent;
    }
    else {
      strExec = st[i].text;
    }
    try {
      eval(strExec.split("<!--").join("").split("-->").join(""));
    } catch(e) {
      alert(e);
    }
  }
}




function validateUserForm(hideCaptcha)
{

	document.getElementById('userEnter').value = 1;

	if (!document.getElementById("username").value)
	{
	  alert("Поле Логин не может быть пустым.");
	  document.getElementById("username").focus();
	  return (false);
	}


	if (!document.getElementById("email").value)
	{
	  alert("Необходимо ввести корректный email адрес.");
	  document.getElementById("email").focus();
	  return (false);
	}

	var re_check_email = new RegExp("[A-Za-z0-9_]+([-+.][A-Za-z0-9_]+)*@[A-Za-z0-9_]+([-.][A-Za-z0-9_]+)*\\.[A-Za-z0-9_]{2,}([-.][A-Za-z0-9_]+)*");
	var ares = re_check_email.exec(document.getElementById("email").value);
	if( ares == null )
	{
	  alert("Необходимо ввести корректный email адрес.");
	  document.getElementById("email").focus();
	  return (false);
	}


	if (!document.getElementById("pass").value)
	{
	  alert("Пожалуйста, введите пароль");
	  document.getElementById("pass").focus();
	  return (false);
	}

	if (document.getElementById("pass").value.length < 4 || document.getElementById("pass").value.length > 12 || document.getElementById("pass").value.indexOf(" ") > 0 )
	{
		alert("Пароль должен иметь длину от 4 до 12 символов без пробелов.");
		theForm.user_password.focus();
		return false;
	}

	
	if (document.getElementById("pass").value != document.getElementById("pass_confirm").value)
	{
	  alert("Несовпадение пароля и его подтверждения!");
	  document.getElementById("pass_confirm").focus();
	  return (false);
	}

	if (hideCaptcha != 1)
	{
		if(document.getElementById('txtCaptcha').value == '')
		{
		  alert("Необходимо ввести код защиты от роботов.");
		  document.getElementById("txtCaptcha").focus();
		  return (false);
		}

		getParam(document.sign_up_form); 
	}else{
     document.forms.sign_up_form.submit()	;
	}
}

function generateNewCaptcha()
{
	document.getElementById('userEnter').value = '';
	getParam(document.sign_up_form); 

}


function validateCommentForm(hideCaptcha)
{

	document.getElementById('userEnter').value = 1;

	if (!document.getElementById("username").value)
	{
	  alert("Поле Имя не может быть пустым.");
	  document.getElementById("username").focus();
	  return (false);
	}


	if (document.getElementById("email").value != "")
	{

	
	var re_check_email = new RegExp("[A-Za-z0-9_]+([-+.][A-Za-z0-9_]+)*@[A-Za-z0-9_]+([-.][A-Za-z0-9_]+)*\\.[A-Za-z0-9_]{2,}([-.][A-Za-z0-9_]+)*");
	var ares = re_check_email.exec(document.getElementById("email").value);
	if( ares == null )
	{
	  alert("Необходимо ввести корректный email адрес.");
	  document.getElementById("email").focus();
	  return (false);
	}


	}

	if (hideCaptcha != 1)
	{
		if(document.getElementById('txtCaptcha').value == '')
		{
		  alert("Необходимо ввести код защиты от роботов.");
		  document.getElementById("txtCaptcha").focus();
		  return (false);
		}

		getParam(document.sign_up_form); 
	}else{
     document.forms.sign_up_form.submit()	;
	}
}
