var symbolItem = 1;
var isOn = 1;


function turnOn()
{
   isOn = 1;
}



function editSymbol(arg1) {
	document.editSymbolForm.submit();
}


function newsymbol() {
	var thm = document.getElementById('editSymbolURL');
	thm.value="";
	document.editSymbolForm.submit();
}

function clearTextRow(colind)
{
	var theTable = document.getElementById('textsizetable');
        var cols = theTable.getElementsByTagName("td");
 	for (var i=0;i<cols.length;i++){
 		if (i == colind) { 
 			cols[i].style.backgroundColor='#FF2222';
 		} else {
			cols[i].style.backgroundColor='#FFFFFF';
		}
 	}

	var theTable2 = document.getElementById('textsizetable2');
        var cols2 = theTable2.getElementsByTagName("td");
 	for (var i2=0;i2<cols2.length;i2++){
 		if (colind == (i2+cols.length)) { 
 			cols2[i2].style.backgroundColor='#FF2222';
 		} else {
			cols2[i2].style.backgroundColor='#FFFFFF';
		}
 	}
}

function chooseBig()
{
	setColorVis('visible');
	clearTextRow(0);
	scheme = document.getElementById('textstyle');
	scheme.value='big';
//	previewPress();
}

function chooseGoth()
{
	setColorVis('visible');
	clearTextRow(4);
	scheme = document.getElementById('textstyle');
	scheme.value='goth';
//	previewPress();
}

function chooseScript()
{
	setColorVis('visible');
	clearTextRow(5);
	scheme = document.getElementById('textstyle');
	scheme.value='script';
//	previewPress();
}

function chooseSmall()
{
	setColorVis('visible');
	clearTextRow(1);
	scheme = document.getElementById('textstyle');
	scheme.value='';
//	previewPress();
}

function setColorVis(vv)
{
//	var mm = document.getElementById('sampletable');
//	mm.style.visibility=vv;
	mm = document.getElementById('fillshapea');
	mm.style.visibility=vv;
	mm = document.getElementById('fillcolorb');
	mm.style.visibility=vv;
}


function chooseDoInvert()
{
       scheme = document.getElementById('inverted');
 	scheme.value='yes';

	var theTable = document.getElementById('inverttable');
        var cols = theTable.getElementsByTagName("td");
	cols[0].style.backgroundColor='#FFFFFF';
	cols[1].style.backgroundColor='#FF2222';
}

function chooseNotInvert()
{
	scheme = document.getElementById('inverted');
	scheme.value='';
	var theTable = document.getElementById('inverttable');
        var cols = theTable.getElementsByTagName("td");
	cols[0].style.backgroundColor='#FF2222';
	cols[1].style.backgroundColor='#FFFFFF';
}


function chooseGrunge()
{
	setColorVis('visible');
	clearTextRow(2);
	scheme = document.getElementById('textstyle');
	scheme.value='grunge';
//	previewPress();
}


function choosePaper()
{
	setColorVis('hidden');
	clearTextRow(3);
	scheme = document.getElementById('textstyle');
	scheme.value='paper';
//	previewPress();
}

function dohidesymbolsimple()
{
var sym = document.getElementById("symbollayersimple");
sym.style.visibility = 'hidden';
}

function pickTheme(ca, cb)
{

   document.getElementById("color1x").value = cb;
//   but = document.getElementById("colorcell");
//   but.style.backgroundColor='#'+cb;
   but = document.getElementById("ColorButton2cell");
   but.style.backgroundColor='#'+cb;

   document.getElementById("color0x").value = ca;
//   but = document.getElementById("thetext");
//   but.style.color='#'+ca;
   but = document.getElementById("ColorButtoncell");
   but.style.backgroundColor='#'+ca;
//	 previewPress();
}

function dosetcolor(sname)
{

if (colorItem==2)
{
   document.getElementById("color1x").value = sname;
//   but = document.getElementById("colorcell");
//   but.style.backgroundColor='#'+sname;
   but = document.getElementById("ColorButton2cell");
   but.style.backgroundColor='#'+sname;
}
else
{
   document.getElementById("color0x").value = sname;
//   but = document.getElementById("thetext");
//   but.style.color='#'+sname;
   but = document.getElementById("ColorButtoncell");
   but.style.backgroundColor='#'+sname;
}
sym = document.getElementById("colorlayer");
sym.style.visibility = 'hidden';
//	previewPress();

}


function doaddsymbolold(sname)
{
document.getElementById("line1").value+=('<'+sname+'>');
var sym = document.getElementById("symbollayersimple");
sym.style.visibility = 'hidden';
}

function doOnLoad(isInitials)
{
document.getElementById("line1").focus();
document.getElementById("line1").select();
if (isInitials)
	initialmode();
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (!obj)
		return [curleft,curtop];

	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}


function ICToggleSymbols(item) {
	var syms = document.getElementById("symbollayersimple");

	if  (syms.style.visibility == new String('visible')) {
		syms.style.visibility='hidden';
		return;
	}
	else
		ICShowSymbols(item);
}



function ICShowColors(item) {
	var sym = document.getElementById("colorlayer");

	if (item==1)
		but =  document.getElementById("ColorButton");
	else
		but =  document.getElementById("ColorButton2");
	var coors = findPos(but);
  var coorx = coors[0];
  var coory = coors[1]-118;
	sym.style.left = coorx + "px";
	sym.style.top = coory + "px";

	colorItem = item;
	sym.style.visibility = 'visible';
}

function initialmode()
{
   var initlay = document.getElementById("Layer1");

  var but =  document.getElementById("pickbox");
   var coors = findPos(but);
    initlay.style.left = coors[0] + "px";
    initlay.style.top = coors[1] + "px";

   var tab = document.getElementById("symbol-tab");
   tab.className='ic_tab2';
    tab = document.getElementById("initial-tab");
   tab.className='ic_tab1';

  var initi =  document.getElementById("doinitials");
  initi.value="1";

  initlay.style.visibility='visible';
}

function symbolmode()
{
   var initlay = document.getElementById("Layer1");
  initlay.style.visibility='hidden';
   var tab = document.getElementById("symbol-tab");
   tab.className='ic_tab1';
    tab = document.getElementById("initial-tab");
   tab.className='ic_tab2';
  var initi =  document.getElementById("doinitials");
  initi.value="0";
}

function ICToggleColors(item) {
	var sym = document.getElementById("colorlayer");

	if  (sym.style.visibility == new String('visible'))
		{
			sym.style.visibility='hidden';
			return;
		}
	else
	ICShowColors(item);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
