var varnames=new Array("oldtext","bold","decor","italic","continue","align","velkost");
var userkey;

function init(pocetpoli)
{
  for(i=0;i<pocetpoli;i++)
    typechange('typetext',i)
  typeObj=MM_findObj("nahlad");
  typeObj.focus();
}
function setuserkey(key)
{
  userkey=key;
}
function getuserkey()
{
  return userkey;
}
function texttool_navod()
{
//alert("Zatiaľ nie je k dispozícii.");
pom="window.open(\"help.php?user="+getuserkey()+"\",\"Help\",\"toolbar=no, scrollbars=yes,resizable\")";
eval(pom);
}

function texttool_gomenu()
{
obj=MM_findObj("puttext");
obj.action="editor.php";
obj.user.value=getuserkey();
obj.submit();
}
function texttool_obnov()
{
obj=MM_findObj("puttext");
obj.action="edititemcont.php";
obj.user.value=getuserkey();
obj.submit();
}

function texttool_insertbefore(i)
{
hod=i;
obj=MM_findObj("puttext");
obj.action="edititemcont.php?insert="+hod;
obj.user.value=getuserkey();
obj.submit();
}

function texttool_insertbehind(i)
{
hod=i+1;
obj=MM_findObj("puttext");
obj.action="edititemcont.php?insert="+hod;
obj.user.value=getuserkey();
obj.submit();
}
function texttool_move_item(por,dir)
{
  typeObj=MM_findObj("user");
  typeObj.value=getuserkey();
  typeObj=MM_findObj("puttext");
  typeObj.action="edititemrefresh.php?por="+por+"&dir="+dir;
  typeObj.submit();
}

function texttool_vymaz(i,vloz)
{
if(vloz)
{
  alert("Text môže byť vymazaný iba keď nie je aktivované vkladanie textu. Aktualizuj text tlačidlom 'Aktualizuj' alebo obnov pôvodný text tlačidlom 'Obnov'");
  return;
}
if(confirm("Skutočne chceš odstrániť tútú časť textu? Text bude vymazaný nie len v tomto náhľade, ale aj v databáze!")==false)
  return;
obj=MM_findObj("zmaztext");
obj.user.value=getuserkey();
obj.subid.value=i;
obj.submit();
}

function texttool_editview(pocetpoli)
{
typeObj=MM_findObj("p");
typeObj.value=pocetpoli;
for(i=0;i<pocetpoli;i++)
{
  for(j=0;j<=9;j++)
  {
    typeObj=MM_findObj("param-"+j+"-"+i);
    if(typeObj.style.display=='inline')
    {
      if(j!=0 && j!=4 && j!=5 && j!=10)
        val=parseInt(typeObj.options[typeObj.selectedIndex].value);
      else
        val=typeObj.value;
      typeObj=MM_findObj("param-"+i);
      typeObj.value=val;
    }
  }
  j++;
  for(;j<=13;j++)
  {
    typeObj=MM_findObj("param-"+j+"-"+i);
    if(typeObj.style.display=='inline')
    {
      if(j!=0 && j!=4 && j!=5 && j!=10)
        val=parseInt(typeObj.options[typeObj.selectedIndex].value);
      else
        val=typeObj.value;
      typeObj=MM_findObj("param1-"+i);
      typeObj.value=val;
      break;
    }
  }
}
typeObj=MM_findObj("user");
typeObj.value=getuserkey();
typeObj=MM_findObj("puttext");
typeObj.action="edititemview.php";
typeObj.submit();
}

function texttool_aktualizuj(pocetpoli)
{
typeObj=MM_findObj("p");
typeObj.value=pocetpoli;
for(i=0;i<pocetpoli;i++)
{
  for(j=0;j<=13;j++)
  {
    typeObj=MM_findObj("param-"+j+"-"+i);
    if(typeObj.style.display=='inline')
    {
      if(j!=0 && j!=4 && j!=5 && j!=10)
        val=parseInt(typeObj.options[typeObj.selectedIndex].value);
      else
        val=typeObj.value;
      typeObj=MM_findObj("param-"+i);
      typeObj.value=val;
      break;
    }
  }
  j++;
  for(;j<=13;j++)
  {
    typeObj=MM_findObj("param-"+j+"-"+i);
    if(typeObj.style.display=='inline')
    {
      if(j!=0 && j!=4 && j!=5 && j!=10)
        val=parseInt(typeObj.options[typeObj.selectedIndex].value);
      else
        val=typeObj.value;
     if(j==12||j==11)
     {
       typeObj=MM_findObj("param-"+i);
       typeObj.value=val;
       continue;
     }
      typeObj=MM_findObj("param1-"+i);
      typeObj.value=val;
      break;
    }
  }
}
typeObj=MM_findObj("user");
typeObj.value=getuserkey();
typeObj=MM_findObj("puttext");
typeObj.action="edititemrefresh.php";
typeObj.submit();
}

function typechange(name,i)
{
  typeObj=MM_findObj(name+i);
  type=parseInt(typeObj.options[typeObj.selectedIndex].value);
      typeObj=MM_findObj("param-0-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-1-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-2-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-3-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-4-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-5-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-6-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-7-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-8-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-9-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-10-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-11-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-12-"+i);
      typeObj.style.display='none';
      typeObj=MM_findObj("param-13-"+i);
      typeObj.style.display='none';
  switch(type)
  {
    case 0:
      break;
    case 1:
      typeObj=MM_findObj("param-1-"+i);
      typeObj.style.display='inline';
      break;
    case 2://paragraphs
      typeObj=MM_findObj("param-0-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-7-"+i);
      typeObj.style.display='inline';
      break;
    case 3://box
      typeObj=MM_findObj("param-5-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-10-"+i);
      typeObj.style.display='inline';
      break;
    case 4:
      typeObj=MM_findObj("param-0-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-8-"+i);
      typeObj.style.display='inline';
      break;
    case 5://link
      typeObj=MM_findObj("param-0-"+i);
      typeObj.style.display='inline';
      break;
    case 6:case 7://ul
      typeObj=MM_findObj("param-3-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-4-"+i);
      typeObj.style.display='inline';
      break;
    case 8:case 9://ol
      typeObj=MM_findObj("param-2-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-4-"+i);
      typeObj.style.display='inline';
      break;
    case 10://obr1
      typeObj=MM_findObj("param-5-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-10-"+i);
      typeObj.style.display='inline';
      break;
    case 11://obr2-link
      typeObj=MM_findObj("param-5-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-10-"+i);
      typeObj.style.display='inline';
      break;
    case 12://tab
      typeObj=MM_findObj("param-5-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-9-"+i);
      typeObj.style.display='inline';
      break;
    case 13://objekt
      typeObj=MM_findObj("param-12-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-13-"+i);
      typeObj.style.display='inline';
      break;
    case 14: //graph
      break;
    case 15://special
      typeObj=MM_findObj("param-11-"+i);
      typeObj.style.display='inline';
      typeObj=MM_findObj("param-10-"+i);
      typeObj.style.display='inline';
      break;
    default:
      break;
  }
}
//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

//6 items [0]:id;[1]:function;[2]:marqueewidth;[3]:marqueeheight;[4]:marqueespeed;[5]:pauseit;
function texttool_runScript()
{ 
  texttool_scriptarray=texttool_scriptcontent;
  for(i=0;i<texttool_scriptarray.length;i++)
  { 
    switch(texttool_scriptarray[i][1])
    {
      case 'hmarque':
        lefttime=setInterval("texttool_scrollmarquee()",10);
        break;
      default:
        break;
    }
  }
}
////NO NEED TO EDIT BELOW THIS LINE////////////
function texttool_scrollmarquee()
{ 
  texttool_scriptarray=texttool_scriptcontent;
  for(i=0;i<texttool_scriptarray.length;i++)
  {
    id=texttool_scriptarray[i][0];
//    cross_marquee=document.getElementById(id.slice(1));
    cross_marquee=MM_findObj(id.slice(1));
    cross_marquee1=MM_findObj(id.slice(1)+"_marquee");
    if(!cross_marquee)continue;
    if (parseInt(cross_marquee.style.left)>(cross_marquee1.offsetWidth*(-1)))
      cross_marquee.style.left=parseInt(cross_marquee.style.left)-texttool_scriptarray[i][4]+"px";
    else
    {
      wrapperdiv=MM_findObj('middlebody');
//      alert(cross_marquee1.offsetWidth);
      cross_marquee.style.left=parseInt(wrapperdiv.offsetLeft+wrapperdiv.offsetWidth)+"px";
    }
  }
} 
