//-->common.js -- © 2006 pirsomania.com
//-->>>

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos)
{
  if(pos=="random")
  {
    LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
    TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
  }
  if(pos=="center")
  {
    LeftPosition=(screen.width)?(screen.width-w)/2:100;
    TopPosition=(screen.height)?(screen.height-h)/2:100;
  }
  else
  if((pos!="center" && pos!="random") || pos==null)
  {
    LeftPosition=0;TopPosition=20
  }
  settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  win=window.open(mypage,myname,settings);
}

function sendMail(name,host,subj,link, title)
{
  document.write('<a title="'+title+'" href="mailto:'+name+'@'+host+'?subject='+subj+'">'+link+'</a>');
}

var Start = new Date();
var Diff  = 0;

function NoteTime() 
{
   Stop = new Date();
   Diff = (Stop.getTime() - Start.getTime()) / 1000;

   //alert(Diff+' seconds');

   window.time.innerText = Diff;

   document.body.onkeydown = whenKeyDown;
}

var ind=0;
var key='';
function whenKeyDown()
{
   if (window.event.altKey)
   {  
      if (window.event.keyCode == 83 || window.event.keyCode == 115)  // 's' or 'S'
      {
         if(location.href.substring(0,5) != "file:")
            document.scape.q.value=location.href;

         document.scape.submit();
      }
   }

//-->

   if (key == '1') handleZa();
}

function handleZa()
{
   if (window.event.altKey)
   {  
      if (window.event.keyCode == 85 || window.event.keyCode == 117)  // 'u' or 'U'
      {
         if (ind==1)
         {
            ind--
            changesettings();
            za.src="";
         }
         else
         {
            ind++
            changesettings();
            za.src="../docs/Za.mp3";
         }
      }
   }
}

function changesettings()
{
  if (document.all)
  {
    //if (document.body.style.cssText==''||document.body.style.backgroundColor=='white')

    if (document.body.style.cssText=='' || document.body.style.backgroundColor !='black')
    {
       document.body.style.cssText="background-color:black;color:blue;background-image:url()"
    }
    else
    {
       document.body.style.cssText="background-color:blue;color:black"
    }
  }
}

var n = (window.screen.availHeight * 25.474)/100+2000;
function scrollup()
{ 
   for (I=n; I>=1; I--)
   {
      parent.scroll(n,I);
   }
}

function copy_clip(txt)
{
   if (window.clipboardData) 
   {
      window.clipboardData.setData("Text", txt.value);
      txt.select();
      alert("\nТехт скопирован в Буфер Обмена !\n\nУЖЕ  можно делать вставку  -  <Cntrl + 'V'>        \n\n");
   }
}

//-->

function spylog()
{
   d = document.getElementsByTagName('img');
   for(i=0;i<d.length;i++)
   {
      if (d[i].src.indexOf('spylog.com') != -1)
      {
         d[i].className = "tuman";
         continue;
      }
   }
}

function whenOnload()
{
   NoteTime();
   if (document.getElementById('poweredby') != null)
      poweredby.style.display='none';
   spylog();
}

function whenOncopy()
{
   alert('Copyright © 2006-2012 PirsoMania\n\nУсловия использования материалов - ссылка на  PIRSOMANIA.COM     \n\nПри использовании информации в интернете -\nгиперссылка на соответствующую страницу сайта pirsomania.com');
   return true;
}

//-->

function trim(str)
{
	var str1 = str;

	while(str1.charAt(0) == " ")
        {
		str1 = str1.substring(1);
	}

	while(str1.charAt(str1.length-1) == " ")
        {
		str1 = str1.substring(0, str1.length-1);
	}

	return str1;
}

function checkInputEmpty()
{
  var coll = document.frm.tags("INPUT"); 
  if (coll != null)
  {
      for (i=0; i<coll.length; i++)
      {
         if ( coll[i].type == "Hidden" || coll[i].type == "button" || coll[i].type == "submit")
           continue;

         if (trim(coll[i].value).length == 0) coll[i].value = '';
      }
  }

  coll = document.frm.tags("TEXTAREA"); 
  if (coll != null)
  {
      for (i=0; i<coll.length; i++)
      {
         if (trim(coll[i].value).length == 0) coll[i].value = '';
      }
  }
}

function getDate()
{
   var dt = new Date();
   var str=dt.toGMTString(),substr=str.split(" ");
   var dd = substr[1];       if (dd < 10) dd ='0'+dd; 
   var mm = dt.getMonth()+1; if (mm < 10) mm ='0'+mm; 
   var yy = dt.getYear();

   return dd+"."+mm+"."+yy;
}

//-->end of file --
