function ro1(el1,el2)
{
  if (document.all||document.getElementById)
  el1.style.color='#224489';
  el2.style.color='#224489';
  el2.style.borderColor='#224489';
}
function ro2(el1,el2)
{
  if (document.all||document.getElementById)
    el1.style.color='#000000';
  el2.style.color='#000000';
  el2.style.borderColor='#888887';
}
function check(name) {
  if (name.checked == false) { name.checked = true }
}

var windowsObjects = new Array ();

function openSong(song)
{
  CloseOpenedWindows();
  OpenWindow (song, 'txt', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no', 350, 400, 1)
}

function OpenWindow (URL, windowName, windowFeatures, windowWidth, windowHeight, centeredWindow)
{
  if (centeredWindow)
  {
    if (parseInt(navigator.appVersion) >= 4)
    {
      leftPosition = (screen.width) ? (screen.width-windowWidth)/ 2 : 0;
      topPosition = (screen.height) ? (screen.height-windowHeight)/2 : 0;
      windowFeatures += ",top=" + topPosition + ",left=" + leftPosition + ",width=" + windowWidth + ",height=" + windowHeight;
    }
  }
  else
  {
    windowFeatures += ",width=" + windowWidth + ",height=" + windowHeight;
  }

  var windowObject = window.open (URL, windowName, windowFeatures);
  windowsObjects[windowsObjects.length] = windowObject;

  if ( window.opener != null && window.opener.OpenWindow != null )
  {
    window.opener.windowsObjects[window.opener.windowsObjects.length] = windowObject;
  }
  
  return windowObject;
}

// Function to close all opened windows.
function CloseOpenedWindows ()
{
  for (var i = 0; i < windowsObjects.length; i++ )
    if ( windowsObjects[i] != null ) windowsObjects[i].close();
}

// Close self window.
function CloseWindow ()
{
  CloseOpenedWindows ();
  if ( window.opener != null ) window.opener.focus();
  top.close ();
}

function setStyle(obj)
{
  obj.document.write('\n<STYLE type="text/css" media="all">'+"\n");
  obj.document.write("<!--\n");
  obj.document.write('@import url("images/styles.css");'+"\n");
  obj.document.write("-->\n");
  obj.document.write("</STYLE>\n");
}

function fullImage(obj)
{
  if (windowsObjects.length > 0) CloseOpenedWindows();
  
  var newImg = new Image();
  newImg.src = obj.src;
  var fi = OpenWindow ('', 'fullImg', 'toolbar=0,location=0,directories=0,status=0,statusbar=0,menubar=0,resizable=1,copyhistory=0,scrollbars=0', 100, 100, 1);
  fi.resizeTo(newImg.width+10,newImg.height+50);
  setStyle(fi);
  fi.document.write("<body>\n<img src="+newImg.src+">\n</body>");
}

function previewWin(src, elName)
{
  if (windowsObjects.length > 0) CloseOpenedWindows();
  
  var src = "images/player.swf?src=vad/prev/"+src+".mp3";

  var pw = OpenWindow ('', elName, 'location=0,menubar=0,resizable=0', 200, 60, 1);
  pw.resizeTo(210,90);
  pw.document.write("<body>\n");
  pw.document.write("<object type=\"application/x-shockwave-flash\" data=\""+src+"\" height=28 width=200>\n");
  pw.document.write("<param name=movie value='"+src+"'>\n");
  pw.document.write("<param name=bgcolor value=#00cd2b>\n");
  pw.document.write("</object>\n");
  pw.document.write("\n</body>");
  setStyle(pw);
}

function pVideo(src)
{
  if (windowsObjects.length > 0) CloseOpenedWindows();

  var src = "vad/"+src+".swf";

  var pw = OpenWindow ('', '', 'location=0,menubar=0,resizable=0', 190, 155, 1);
  pw.resizeTo(195,190);
  pw.document.write("<body>\n");
  pw.document.write("<object type=\"application/x-shockwave-flash\" data=\""+src+"\" width=190 height=155>\n");
  pw.document.write("<param name=movie value='"+src+"'>\n");
  pw.document.write("<param name=bgcolor value=#00cd2b>\n");
  pw.document.write("</object>\n");
  pw.document.write("\n</body>");
  setStyle(pw);
}

function pVideo2(src)
{
  if (windowsObjects.length > 0) CloseOpenedWindows();
  
  var width = 290;
  var height = 250;
  var vp = OpenWindow ('', 'MediaPlayer'+videoId, 'location=0,menubar=0,resizable=0', width, height, 1);
  vp.resizeTo(width+16,height+35);
  vp.document.write("<body>\n<center>\n");
  setStyle(vp);
  vp.document.write('<object id=MediaPlayer classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" type="application/x-oleobject" width=100% height=100% align=center vspace=0 hspace=0>'+"\n");
  vp.document.write("<param name=AutoStart value=1>\n");
  vp.document.write("<param name=FileName value='vad/"+src+"'>\n");
  vp.document.write("<param name=AutoSize value=1>\n");
  vp.document.write("<param name=ShowControls value=1>\n");
  vp.document.write("<param name=ShowDisplay value=0>\n");
  vp.document.write("<param name=ShowStatusBar value=0>\n");
  vp.document.write("<param name=TransparentAtStart value=1>\n");
  vp.document.write("</object>\n</center>\n</body>");
}

function wh(o)
{
  var height, width;
  if (document.all)
    height = document.body.offsetHeight, width = document.body.offsetWidth;
  else if (document.layers)
    height = window.innerHeight, width = window.innerWidth;
  if (o) return height;
  else return width;
}

function loadMess(id)
{	
  var obj = "#m" + id;
  if($(obj).css("display") != "block" && $.trim($(obj).html())=='')
  {
	$(obj).show().html('<img src=images/indicator.gif>');
	$(obj).load("forum.php?cmd=show&id="+id);
  }
  else if($(obj).css("display") != "block" && $.trim($(obj).html())!='')
  {
    $(obj).show();
  }
  else
  {
    $(obj).hide();
  }
}

function del_comment(id)
{
  var obj = "#m" + id;
  if (confirm("Âè âïåâíåí³ â ñâî¿õ ä³ÿõ?"))
  {
	$.get("forum.php?cmd=del&id="+id,function(resp){
		if (resp==1) $(obj).parent().hide(300,function(){$(obj).parent().remove()});
		else alert('Message not deleted');
    });
  }
  return false;
}

function moveFollower(){
  admY = getWindowHeight()/2 - adm.getHeight()/2 + getScrollY();
  admX = getDocumentWidth()/2 - adm.getWidth()/2;
  adm.moveTo(admX,admY)
  setTimeout("moveFollower()",1000)
}

function close_comment()
{
  LC.hide();
  adm.hide();
}

function add_comment(obj)
{
  if (obj != 0)
  {
    var new_top = replace("topic");
    var top = replace("h"+obj);
    var new_ans = replace("ans");
    new_ans.value = obj;
    new_top.value = "Re: "+top.value;
  }

  LC.setWidth(getDocumentWidth());
  LC.setHeight(getDocumentHeight());
  LC.show();

  adm.css.display = "block";
  adm.show();

  moveFollower()
}

function checkPicture() {
  if (imgL.getLoaded())
  {
    document.body.style.cursor = 'default';
    LC.style.display = 'none';
    LC.hide();
    clearTimeout(timer);
  }
  else
  {
    timer = setTimeout("checkPicture()", 200);
  }
}

function rImg(gl,img)
{
  document.body.style.cursor = 'wait';
  LC.style.display = 'block';
  LC.show();
  imgL.setSrc("images/galery/"+gl+"/"+img+".jpg");
  checkPicture()
}

var videoId = 1;
function sv(id)
{
  videoId = id;
  switch (id)
  {
    case 1:
      document.getElementById('v1').style.display='block';
      document.getElementById('v2').style.display='none';
	document.getElementById('v3').style.display='none';
      break;
    case 2:
      document.getElementById('v1').style.display='none';
      document.getElementById('v2').style.display='block';
	document.getElementById('v3').style.display='none';
      break;
    case 3:
      document.getElementById('v1').style.display='none';
      document.getElementById('v2').style.display='none';
document.getElementById('v3').style.display='block';
      break;
  }
}

function fnShowProps(obj, objName){
  var result = "";
  for (var i in obj)
      result += objName + "." + i + " = " + obj[i] + "<br \> ";
  imgC.innerHTML = result;
}
