// Pop-up window

function blank(link, width, height, scrollbars)
{
  scrollwidth = scrollbars? 16: 0;
  window.open(link, '', 'width='+(width+scrollwidth)+', height='+height+', left='+(screen.width-width-scrollwidth)/2+', top='+(screen.height-50-height)/2+', titlebar=no, menubar=no, toolbar=no, location=no, status=no, scrollbars='+(scrollbars? 'yes': 'no')+', resizable=yes');
}

// Flash

function flash(src, width, height)
{
  document.write('<embed '+
    //'name="'+id+'" '+
    'width="'+width+'" '+
    'height="'+height+'" '+
    'align="middle" '+
    'type="application/x-shockwave-flash" '+
    'pluginspage="http://macromedia.com/go/getflashplayer" '+
    ''+
    'src="'+src+'" '+
    'quality="high" '+
    'wmode="transparent" '+
    'bgcolor="transparent" '+
    'menu="false" '+
    'allowScriptAccess="sameDomain" />');
}

// Flash fix

/*function flash_fix(id)
{
  if(document.getElementById)
  {
    element = document.getElementById(id);
    element.outerHTML = element.outerHTML;
  }
}*/

// AJAX

// module  - Module name
// id      - Value ID
// element - Element ID
// loading - URL encoded string
// data    - FF fix

function ajax(module, group, item, name, loading, reload, data)
{
  document.getElementById('form_field_'+name+'_div').innerHTML = loading;

  if(window.XMLHttpRequest)
    xhr = new XMLHttpRequest();
  else if(window.ActiveXObject)
  {
    xhr = new ActiveXObject('Msxml2.XMLHTTP');
    if(!xhr) xhr = new ActiveXObject('Microsoft.XMLHTTP');
  }

  xhr.onreadystatechange = function xhr_response() {
    if(xhr.readyState == 4 && xhr.status == 200)
      document.getElementById('form_field_'+name+'_div').innerHTML = xhr.responseText;};

  xhr.open('POST', '/ajax.php?module='+module+'&group='+group+'&item='+item+'&name='+name+'&reload='+reload, true);
  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
  xhr.send(data);
}

// FORM

function field_focus(field, value, color)
{
  if(field.value == value)
  {
    field.value = '';
    field.style.color = color;
  }
}

function field_blur(field, value, color)
{
  if(!field.value)
  {
    field.value = value;
    field.style.color = color;
  }
}

function teasernet(id_1, id_2, x, y)
{
  if(typeof teasernet == 'undefined')
  {
    var teasernet = {};
    var teasernet_blockid = id_1;
  }
  else
    teasernet_blockid = id_1;

  teasernet[teasernet_blockid] = {
    'styles': {
      'TABLE': 'border: 0px solid #FFFFFF; width: 100%; background: #FFFFFF;',
      'TD': 'text-align: center; border: 0px solid #FFFFFF; background: #FFFFFF; font-size: 10pt; color: #000000;',
      'IMG': 'border: 0; margin: 0 auto;',
      'A': 'color: #000000; font-size: 10pt;',
      'AHOVER': 'color: #000000; font-size: 10pt;'},
    'padid': id_2,
    'hor': x,
    'ver': y,
    'size': 120};

  document.write('<div id="teasernet_'+teasernet_blockid+'"></div>');
}

function teasernet_show()
{
  if(typeof teasernet != 'undefined' && typeof teasernet_blocks_exists == 'undefined')
  {
    for(var blockid in teasernet)
    {
      var newScr = document.createElement('script');
      newScr.type = 'text/javascript';
      newScr.src = 'http://echo.teasernet.ru/step1.php?blockid='+blockid+'&padid='+teasernet[blockid].padid+'&count='+(teasernet[blockid].hor*teasernet[blockid].ver)+'&ref='+escape(document.referrer)+'&'+Math.round(Math.random()*100000);
      var el = document.getElementById('teasernet_'+blockid);
      if(el)
        el.appendChild(newScr);
    }
    var teasernet_blocks_exists = true;
  }
}

function adlabs_show(id)
{
  var __rt = Math.round(Math.random()*100000);
  document.write('<scr'+'ipt language="javascript" type="text/javascript" src="http://id9525.luxup.ru/show/'+id+'/?div=lx_'+id+'&rt='+__rt+'&r='+escape(document.referrer)+'"><'+'/scr'+'ipt>');
}


