// inserts text at the specified location
function insertext(text,area)
{
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  sel.text = text;
 }
}
//insert tags at the specified location
function insertags(tag,area,value)
{
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  if(value!="") sel.text = "["+tag+"="+value+"]"+sel.text+"[/"+tag+"]";
  else sel.text = "["+tag+"]"+sel.text+"[/"+tag+"]";
 }
}
function dosubmit(form,val)
{
 for(var i=0;i< document.forms[form].length;i++)	 
  if( document.forms[form].elements[i].value=="") {alert('Не все поля заполнены!');return;}
 document.getElementsByName("act")[0].value=val;
 document.forms[form].submit();
}
function AddKlan(area)
{
 if(!(sKlan=prompt("Введите название клана",""))) return;
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  sel.text = '[klan=' + sKlan +']';
 }
}
function AddNick(area)
{
 if(!(sNick=prompt("Введите ник",""))) return;
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  sel.text = '[char=' + sNick +']';
 }
}

function AddImage(area)
{
 if(!(sNick=prompt("Введите путь",""))) return;
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  sel.text = '[image=' + sNick +']';
 }
}

function insertlink(area)
{
 if(!(sLink=prompt("Введите ссылку",""))) return;
 if(!(sText=prompt("Введите текст",""))) return;
 document.getElementsByName(area)[0].focus(); 
 if (document.selection) 
 {
  sel = document.selection.createRange();
  sel.text = '[link=' + sLink +']'+sText+'[/link]';
 }
// document.insertext('[klan=' + sKlan +']',area); 
}
function AddHideLink(area)
{
 if(!(sLink1=prompt("Введите первый линк",""))) return;
 if(!(sLink2=prompt("Введите второй линк",""))) return;
  document.getElementsByName(area)[0].focus(); 
  if (document.selection) 
  {
   sel = document.selection.createRange();
   sel.text = '[tshow=' + sLink1 +'][thide=' + sLink2 +']'+sel.text+'[/thide]';
  }
}
function ShowDiv(id,state)
{
 document.getElementById(id).style.display=state;
}

function confGo(text,link)
{
 if(confirm(text))
	window.location=link;
}
 
