var focusTable = 'off' ;
var PreviewTable ;
var PreviewText ;
var RealText ;
var WarningText ;
var colorfontCell ;
var colortextCell ;
var ColorObject = '' ;


var Sizes = new Array(7);
Sizes[0] = '12' ;
Sizes[1] = '14' ;
Sizes[2] = '16' ;
Sizes[3] = '18' ;
Sizes[4] = '22' ;
Sizes[5] = '26' ;
Sizes[6] = '30' ;

var SizesP = new Array(7);
SizesP[0] = '4' ;
SizesP[1] = '5' ;
SizesP[2] = '6' ;
SizesP[3] = '7' ;
SizesP[4] = '8' ;
SizesP[5] = '9' ;
SizesP[6] = '10' ;


 if ( document.all ) {
  PreviewTable = document.all('aTable') ;
  PreviewText = document.all('textPrev') ;
  RealText = document.all('textReal') ;
  colorfontCell = document.all('CellColor') ;
  colortextCell = document.all('TextCellColor') ;
  WarningText = document.all('SizeWarning') ;
  }
 else if ( document.getElementById ) {
  PreviewTable = document.getElementById('aTable') ;
  PreviewText = document.getElementById('textPrev') ;
  RealText = document.getElementById('textReal') ;
  colorfontCell = document.getElementById('CellColor') ;
  colortextCell = document.getElementById('TextCellColor') ;
  WarningText = document.getElementById('SizeWarning') ;
  }
 else if (document.layers) {
  PreviewTable = document.aTable;
  PreviewText = document.textPrev ;
  RealText = document.textReal ;
  colorfontCell = document.CellColor ;
  colortextCell = document.TextCellColor ;
  WarningText = document.SizeWarning ;
  }



function chsb() {
  if ( document.adform.target == '_top' ) {
     showWait() ; 
    }
   return true;
}



function checkSize() {
if ( PreviewTable.offsetHeight > 905 ) {
  WarningText.innerHTML = "<br>Warning!<br>Flyer is bigger than paper height! Too long text.<br><br>" ;
 }
 else {
  WarningText.innerHTML = '' ;
 }
}

function changePrevText() {
 EditPreviewText(); 
 checkSize() ;
}


function EditPreviewText() {
 var str = document.adform.text.value ;
 str = str.replace(/</gm,"&lt;") ;
 str = str.replace(/>/gm,"&gt;") ;
 str = str.replace(/\n/g,"<br>") ;
 PreviewText.innerHTML = str;
 RealText.innerHTML = str;
}

function setBgColor(color,who) {
 eval ( who+'Cell.bgColor = color' ) ;
}

function SendColor(selectedColor) {
 setBgColor(selectedColor,ColorObject);
 if ( ColorObject == 'colortext' ) { changeTextColor(selectedColor); } 
 eval('document.adform.' + ColorObject + '.value = selectedColor') ;
 hideColorTable();
}

function changeTextColor(textcolor) {
 PreviewText.style.color = textcolor ; 
 document.adform.colortext.value = textcolor ; 
}

function changeTextSize() {
 RealText.style.fontSize = Sizes[document.adform.textsize.selectedIndex] ;
 PreviewText.style.fontSize = SizesP[document.adform.textsize.selectedIndex] ;
 checkSize();
}

function showColorTable(forWhat) {
 ColorObject = forWhat ;
 eval(layerRef+'selectColorTable'+styleRef+'.visibility = "visible"') ;
}

function hideColorTable() {
 eval(layerRef+'selectColorTable'+styleRef+'.visibility = "hidden"') ;
}

function mouseOverColorTable() {
 focusTable = 'on' ;
}

function mouseOutColorTable() {
 focusTable = 'off' ;
}

function prhelp() { 
 window.open("/help/print-ad.html","selecthelp","width=465,height=480,top=10,left=10,status=no,toolbar=no,menubar=no,scrollbars=no"); 
}


function fontHelp() { 
 window.open("/signs/font-help.html","fontSample","width=190,height=365,top=20,left=10,status=no,toolbar=no,menubar=no,scrollbars=no"); 
}


setBgColor( document.adform.colorfont.value, 'colorfont' ) ;
setBgColor( document.adform.colortext.value, 'colortext' ) ;
changeTextColor( document.adform.colortext.value ) ;
RealText.style.fontSize = Sizes[document.adform.textsize.selectedIndex] ;
PreviewText.style.fontSize = SizesP[document.adform.textsize.selectedIndex] ;

if ( document.adform.text.value ) {
 EditPreviewText() ;
 }
else {
 PreviewText.innerHTML = ' <br> <font size=3>Your text to appear here</font><br>' ;
 }

setTimeout("checkSize()", 1000 ); 
setTimeout("checkSize()", 3000 ); 
setTimeout("checkSize()", 5000 );

