function setFrmVal(f_id, f_val)
{
  document.getElementById(f_id).value = f_val;
}

function snd(act)
{
  setFrmVal('act', act);
  document.forms.frm.submit();
}

function sndm(act)
{
  if (confirm ('Are you sure?'))
  {
    setFrmVal('act', act);
    document.forms.frm.submit();
  }
}

function popUp(url, w, h)
{
  wn = window.open(url, 'wnd', 'width='+w+', height='+h+', scrollbars=yes');
}

function refr_sm(act, l)
{
  setFrmVal('act', act);
  document.forms.frm.submit();
  if (l != -1)
  {
    window.opener.location = l;
  }
  else
  {
    window.opener.location.reload();
  }
  window.close();
}

function refr_url(url, l)
{
  window.location = url;
  if (l != -1)
  {
    window.opener.location = l;
  }
  else
  {
    window.opener.location.reload();
  }
  window.close();
}

function checkReg(fm)
{
  if (fm.nick.value.length == 0 || fm.nick.value.length > 50)
  {
    fm.nick.focus();
    alert("Nick неверно!");
    return false;
  }

  if (fm.pass.value.length == 0 || fm.pass.value.length > 30 || fm.pass.value != fm.pass1.value)
  {
    fm.pass.focus();
    alert("Password неверно!");
    return false;
  }

  if (fm.email.value.length == 0 || fm.email.value.length > 100)
  {
    fm.email.focus();
    alert("Email неверно!");
    return false;
  }

  /*
  if (fm.pinfo.value.length == 0)
  {
    fm.pinfo.focus();
    alert("Payment info неверно!");
    return false;
  } */

  if (!fm.trm.checked)
  {
    fm.trm.focus();
    alert("Вам следует согласиться с условиями!");
    return false;
  }

  return true;
}

function checkEdit(fm)
{
  if (fm.nick.value.length == 0 || fm.nick.value.length > 50)
  {
    fm.nick.focus();
    alert("Nick неверен!");
    return false;
  }

  if (fm.pass.value != fm.pass1.value)
  {
    fm.pass.focus();
    alert("Password неверен!");
    return false;
  }

  if (fm.email.value.length == 0 || fm.email.value.length > 100)
  {
    fm.email.focus();
    alert("Email неверен!");
    return false;
  }

  if (fm.pinfo.value.length == 0)
  {
    fm.pinfo.focus();
    alert("Payment info неверно!");
    return false;
  }

  return true;
}

function showW(w_id)
{
  document.getElementById(w_id).style.display = 'block';
}

function hideW(w_id)
{
  document.getElementById(w_id).style.display = 'none';
}

function backH()
{
  window.history.back();
}

function getLink(url)
{
  popUp('/info.php?url='+url, 500, 50);
  //copyToClipboard(url);
  //alert (url);
}

function copyToClipboard(content) {
    if (window.clipboardData && window.clipboardData.setData) {
        window.clipboardData.setData("Text", content);
        return true;
    }
    else {
        try { 
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
        } 
        catch (e) { 
            return false;
        }
 
        var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(); 
        if (clipboard) { 
            clipboard = clipboard.QueryInterface(Components.interfaces.nsIClipboard); 
        } 
 
        var transferable = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(); 
        if (transferable) { 
            transferable = transferable.QueryInterface(Components.interfaces.nsITransferable); 
        }
 
        if (clipboard && transferable) {
            var textObj = new Object(); 
            var textObj = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
            if (textObj) { 
                textObj.data = content; 
                transferable.setTransferData("text/unicode", textObj, content.length*2); 
                var clipid=Components.interfaces.nsIClipboard; 
                clipboard.setData(transferable,null,clipid.kGlobalClipboard); 
 
                return true;
            } 
        }
 
        return false;
    }
}

function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function payInfo(obj)
{
  if (obj.value=="wu")
  {
    document.getElementById('pi0').style.display = 'none';
    document.getElementById('pi1').style.display = 'block';
    document.getElementById('pi2').style.display = 'none';
  }
  else if (obj.value=="wt")
  {
    document.getElementById('pi0').style.display = 'none';
    document.getElementById('pi1').style.display = 'none';
    document.getElementById('pi2').style.display = 'block';
  }
  else
  {
    document.getElementById('pi0').style.display = 'block';
    document.getElementById('pi1').style.display = 'none';
    document.getElementById('pi2').style.display = 'none';
  }
}
