var nWinExist=0; // признак открытия доп.окна
var nWinBExist=0; // признак открытия большого доп.окна
var nWinExistXY=0; // признак открытия доп.окна с координатами
var name_field;
var nHasFlash=0;
var nFlashVer=5;
var pid='';
 
function ShowHide(pid1)
{
  pid=pid1;
  var container = document.getElementById("tr_" + pid1);		
  if (container!=null)
  {
    if (container.style.display != "none")
      container.style.display = 'none';
    else
      container.style.display = 'block';
  }
}

function playHome()
{
  document.all.sound.src = "./images/moto.wav";
}

function checkFlash(v) {
var f = 'Shockwave Flash';
with (navigator) {
  if (plugins && plugins[f]) {
    nHasFlash = v<=parseInt(plugins[f].description.substring(16)) 
  } 
  else {
    if (document.all && !window.opera) {
      execScript('on error resume next: nHasFlash = IsObject(CreateObject("' + (f + '.' + f + '.').replace(/ /g, '')+v+'"))','VBScript')
    }
  }
}	
return nHasFlash;
}

function winop(cPage) {
 if (nWinExist==1) {
   windop.close();
   nWinExist=0;
 }
 windop = window.open(cPage,"mywin","toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=700,left=100,top=30");
 nWinExist=1;
} 

function winopxy(cPage,nHeight,nWidth) {
// height +30 width +20 
 if (nWinExistXY==1) {
   windopxy.close();
   nWinExistXY=0;
 }
 windopxy = window.open(cPage,"mywin","toolbar=no,scrollbars=no,height="+nHeight+",width="+nWidth+",left=100,top=30");
 nWinExistXY=1;
}

function winopxysc(cPage,nHeight,nWidth) {
// height +30 width +20 
 if (nWinExistXY==1) {
   windopxy.close();
   nWinExistXY=0;
 }
 windopxy = window.open(cPage,"mywin","toolbar=no,scrollbars=yes,resizable=yes,height="+nHeight+",width="+nWidth+",left=100,top=30");
 nWinExistXY=1;
}

function winbop(cPage) {
 if (nWinBExist==1) {
   winbdop.close();
   nWinBExist=0;
 }
 winbdop = window.open(cPage,"mywinb","");
 nWinBExist=1;
}

function fconfirm(inForm)
{
  var cError="Форма не заполнена:";
  if (inForm.name=='login_form')
  {
    if (inForm.username.value=='')
      cError=cError+"\n- Нет выражения для поиска";
  }
  if (inForm.name=='poisk_form')
  {
    if (inForm.poisk.value=='')
      cError=cError+"\n- Нет выражения для поиска";
  }
  if (inForm.name=='coment_form')
  {
    if (inForm.author.value=='')
      cError=cError+"\n- Вы не представились";
    if (inForm.useremail.value=='')
      cError=cError+"\n- Не введен E-mail";
    if (inForm.contcoment.value=='')
      cError=cError+"\n- Нет комментария";
  }  
  if (inForm.name=='new_blog_form')
  {
    if (inForm.content.value==0)
      cError=cError+"\n- Не выбрана категория";
    if (inForm.mainrazd.value==0)
      cError=cError+"\n- Не выбрана подкатегория";
    if (inForm.statusblog.value==0)
      cError=cError+"\n- Не выбран статус блога";
    if (inForm.nameblog.value=='')
      cError=cError+"\n- Нет названия блога";
    if (inForm.keywords.value=='')
      cError=cError+"\n- Нет ключевых слов";
    if (inForm.contblog.value=='')
      cError=cError+"\n- Нет текста блога";
    if (inForm.useremail.value=='')
      cError=cError+"\n- Не введен E-mail";
  }  
  if (cError!="Форма не заполнена:")
    alert (cError);
  else
  {
    if (confirm("Подтверждаете выполнение операции ?"))
      inForm.submit();
  }
}


var hotkey=13;
var inFormObj;
if (document.layers)
  document.captureEvents(Event.KEYPRESS);

function confirmobj(inForm,inFormOb)
{
  if (confirm("Подтверждаете выполнение операции ?"))
  {
    inFormObj=inFormOb;
    inFormObj.value=true;
    inForm.submit();
  }
}  

function pressonoff(onoff,inFormOb)
{
  inFormObj=inFormOb;
  if (inFormObj==null)
  {
    document.onkeypress=null;
    return;
  }
  if (onoff==1)
    document.onkeypress=mypress;
  else
    document.onkeypress=null;
}

function mypress(key)
{
 if (document.layers)
 {
   if (key.which==hotkey)
     inFormObj.value=inFormObj.value+"<BR>";
 }
 else if (!document.all)
 {
   if (key.which==hotkey)
     inFormObj.value=inFormObj.value+"<BR>";
 }

 if (document.all)
 {
   if (event.keyCode==hotkey)
     inFormObj.value=inFormObj.value+"<BR>";
 }
}


function fnWrapWithTags(txt, sTag, sClass){
    var sHTML = "[" + sTag;
    sHTML += (sClass) ? " class=\"" + sClass + "\"" : "";
    sHTML += ("]" +txt + "[/" + sTag + "]");
    return sHTML;
}

function fnAddHtml(){
    var txt = this.toString();
    var sTag = Teg;
    return fnWrapWithTags(txt, sTag, "");
}

String.prototype.i = fnAddHtml;
String.prototype.b = fnAddHtml;
String.prototype.u = fnAddHtml;
String.prototype.s = fnAddHtml;
String.prototype.left = fnAddHtml;
String.prototype.center = fnAddHtml;
String.prototype.right = fnAddHtml;
String.prototype.justify = fnAddHtml;
String.prototype.hr = fnAddHtml;

function fnCode(){
    var txt = this.toString();
    var sTag = "code";
    return fnWrapWithTags(txt, sTag, "");
}

String.prototype.code = fnCode;

var Teg = 'b';
function fnApplyTag(sTag){
    Teg = sTag;
    if (!document.all && !document.all.item) return;
    var oSelTxt = document.selection.createRange();
    var sSelTxt = oSelTxt.text;
    if (sSelTxt) 
     oSelTxt.text = eval("sSelTxt."+sTag+"()");
    else {
     document.selection.createRange();
     document.selection.value += 'ffffffff';
    }
     
}

function pastesmile(text)
{
  if (document.new_post_form) 
  {
    if (document.selection) 
    { 
      if (name_field=='title') 
  	    document.new_post_form.ftitle.focus();
  	  else
	    document.new_post_form.message.focus();

  	  document.new_post_form.document.selection.createRange().text = text;
    } 
    else
    { 
      if (name_field=='title') 
        document.new_post_form.ftitle.value += text;
  	  else
        document.new_post_form.message.value += text;
    }
  }
}

// - End of JavaScript - -->

