// 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, element, loading, reload, data)
{
  document.getElementById(element).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(element).innerHTML = xhr.responseText;};

  xhr.open('POST', '/ajax.php?module='+module+'&group='+group+'&item='+item+'&reload='+reload, true);
  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
  xhr.send(data);
}

function abuse(element, comment, data)
{
  element.style.display = 'none';

  if(window.XMLHttpRequest)
    xhr = new XMLHttpRequest();
  else if(window.ActiveXObject)
  {
    xhr = new ActiveXObject('Msxml2.XMLHTTP');
    if(!xhr) xhr = new ActiveXObject('Microsoft.XMLHTTP');
  }

  xhr.open('POST', '/abuse.php?comment='+comment, 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 fix_png(element)
{
  if(element.tagName == 'IMG')
  {
    if(/\.png$/.test(element.src))
    {
      src = element.src;
      element.src = '/images/blank.gif';
    }
  }
  else
  {
    src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
    if(src)
    {
      src = src[1];
      element.runtimeStyle.backgroundImage = 'none';
    }
  }

  if(src)
    element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"')"; // ,sizingMethod='scale' ,sizingMethod='crop'
}

function player(file)
{
  width = 470;
  height = 70;
  skin = 'grey';
  volume = 75;
  swf = '/files/player.mp3.swf';
  path = '/files/discography/preview/';

  document.write(
    '<object width="'+width+'" height="'+height+'">'+
    '  <param name="movie" value="'+swf+'">'+
    '  <param name="wmode" value="transparent">'+
    '  <param name=FlashVars value="way='+path+file+'&swf='+swf+'&w='+width+'&h='+height+'&autoplay=0&skin='+skin+'&volume='+volume+'&comment=Предпрослушивание (моно, 8 кГц, 8 кбит/с)">'+
    '  <embed'+
    '    type="application/x-shockwave-flash"'+
    '    wmode="transparent"'+
    '    flashvars="way='+path+file+'&swf='+swf+'&w='+width+'&h='+height+'&autoplay=0&skin='+skin+'&volume='+volume+'&comment=Предпрослушивание (моно, 8 кГц, 8 кбит/с)"'+
    '    src="'+swf+'"'+
    '    width="'+width+'"'+
    '    height="'+height+'">'+
    '  </embed>'+
    '</object>');
}

function player2(file)
{
  width = '100%';
  height = 150;
  skin = 'grey';
  volume = 75;
  swf = '/files/bigwaveplayer_release9.swf';
  path = '/files/discography/preview/';

  document.write(
    '<object width="'+width+'" height="'+height+'">'+
    '  <param name="movie" value="'+swf+'">'+
    '  <param name="wmode" value="transparent">'+
    '  <param name=FlashVars value="way='+path+file+'&swf='+swf+'&w='+width+'&h='+height+'&autoplay=0&skin='+skin+'&volume='+volume+'&comment=Предпрослушивание (моно, 8 кГц, 8 кбит/с)">'+
    '  <embed'+
    '    type="application/x-shockwave-flash"'+
    '    wmode="transparent"'+
    '    flashvars="way='+path+file+'&swf='+swf+'&w='+width+'&h='+height+'&autoplay=0&skin='+skin+'&volume='+volume+'&comment=Предпрослушивание (моно, 8 кГц, 8 кбит/с)"'+
    '    src="'+swf+'"'+
    '    width="'+width+'"'+
    '    height="'+height+'">'+
    '  </embed>'+
    '</object>');
}

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: 12pt; color: #000000;',
      'IMG': 'border: 0; margin: 0 auto;',
      'A': 'color: #000000; font-size: 12pt;',
      'AHOVER': 'color: #000000; font-size: 12pt;'},
    '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()
{
  var __rt= Math.round(Math.random() * 100000);
  document.write('<scr'+'ipt language="javascript" type="text/javascript" src="http://id27021.luxup.ru/show/65801/?div=lx_65801&rt='+__rt+'&r='+escape(document.referrer)+'"><'+'/scr'+'ipt>');
  document.write('<scr'+'ipt language="javascript" type="text/javascript" src="http://id27021.luxup.ru/show/65800/?div=lx_65800&rt='+__rt+'&r='+escape(document.referrer)+'"><'+'/scr'+'ipt>');
  document.write('<scr'+'ipt language="javascript" type="text/javascript" src="http://id27021.luxup.ru/show/65805/?div=lx_65805&rt='+__rt+'&r='+escape(document.referrer)+'"><'+'/scr'+'ipt>');
}

