      
      
			function resetPallette()
			{
 	      var i;
 	      
        //alert('line 7');
				pallette_table = document.getElementById("t_plt");
        //alert('line 9');

				for (i in pallette_table.cells )
				{
          //alert('i = ' + i);
          //alert('before: pallette_table.cells[' + i + '].className = ' + pallette_table.cells[i].className);
					pallette_table.cells[i].className = "plt";	
          //alert('after: pallette_table.cells[' + i + '].className = ' + pallette_table.cells[i].className);
				}
			}

      function closePallette()
      {
        var pElement;
      
        //alert('line 261');
        pElement = document.getElementById('palletteP');
        //pElement.windowNum = 'alerts';
        if (pElement.windowNum == 'alerts')
        {
          //alert('line 29 top.frames[5] = ' + top.frames[5]);
          //alert('line 30 top.frames[5].document.getElementById("palletteDiv") = ' + top.frames[5].document.getElementById('palletteDiv'));
          //top.frames[5].document.getElementById('palletteDiv').style.display = 'none';
          //top.frames[5].document.getElementById('palletteDiv').className = 'hideDiv';
          //top.frames[5].document.getElementById('selectColor').selectedIndex = 0;
          top.frames['alertDialogbox'].document.getElementById('palletteDiv').className = 'hideDiv';
          top.frames['alertDialogbox'].document.getElementById('selectColor').selectedIndex = 0;
          return; 
        }
        top.popUp(event,'palletteDiv', top);
        pElement.color = '';
		    resetPallette();
      }
      
      function closeFontDialog()
      {
        top.popUp(event, 'fontSettingsDiv', top);
        top.frames['fontSettings'].document.getElementById('selectFontFamily').selectedIndex = 0;
        top.frames['fontSettings'].document.getElementById('selectFontSize').selectedIndex = 0;
        top.expressionsIndex = -1;
      }
      
      function getColor()
      {
        //alert('line 28');
				// de-select a cell that may have been selected
				//plt_selected();
        resetPallette();
        
        var pElement;
        
        //alert('line 36');
		    pElement = document.getElementById('palletteP');
        pElement.color = event.srcElement.style.color;
				// indicate in pallette that item has been selected
				event.srcElement.className="plt_selected";
				//alert('line 39 event.srcElement.currentStyle.border-style = ' + event.srcElement.currentStyle.borderStyle );
				//alert('line 40 event.srcElement.id = ' + event.srcElement.id );
				//alert('line 41 event.srcElement.className = ' + event.srcElement.className );
      }
       
      function setColor()
      {
        var pElement;
         
        //alert('line 54');
		    pElement = document.getElementById('palletteP');
		    if(!pElement.color)
		    {
		      alert('Please Select a Color');
		      return;
		    }
		    //alert('line 81 pElement.innerHTML = ' + pElement.innerHTML);
		    //alert('line 82 pElement.windowNum = ' + pElement.windowNum);
		    //alert('line 83 pElement.color = ' + pElement.color);
		    if(pElement.innerHTML == 'Select Foreground Color')
		    {
          setForegroundColor(pElement.color, pElement.windowNum);
        }
        else
        {
          //alert('line 90');
          setBackgroundColor(pElement.color, pElement.windowNum);
        }  
				// after color has been set, restore default values for next time pallette appears 
				pElement.color = '';
				resetPallette();
        //alert('line 96');
      }
      
      function setForegroundColor(color, id)
      {
        var i;
        var sheets;
        var ruleslist;
        //var hdlElement;
        var tableElement;
        var source;
        var blankPos;
        var numOfRuleFound = -1;
        var txtbox;
        var reqId;
        
        //alert('line 380 color = ' + color);
        if(!color)return;
        //alert("line 89 color = " + color);
        //alert("line 90 reqId = " + reqId);
        //alert("line 46  document.getElementById('table_' + reqId).style.color = " +  document.getElementById('table_' + reqId).style.color );
        //alert("line 47  document.getElementById('table_' + reqId).style.color = " +  document.getElementById('table_' + reqId).currentStyle.color );
        if (id == 'alerts')
        {
          //txtbox = top.frames[5].document.getElementById('displayColor');
          txtbox = top.frames['alertDialogbox'].document.getElementById('displayColor1');
          txtbox.style.color = color;
          //top.frames[5].document.getElementById('palletteDiv').className = 'hideDiv';
          //top.frames[5].document.getElementById('selectColor').selectedIndex = 0;
          top.frames['alertDialogbox'].document.getElementById('palletteDiv').className = 'hideDiv';
          top.frames['alertDialogbox'].document.getElementById('selectColor').selectedIndex = 0;
          //          if (arguments.length == 2)
//          {
//            top.popUp(event, 'palletteDiv', top);
//          }
          return;
        }
        reqId = id;
        tableElement = top.document.getElementById('table_' + reqId);
        //alert("line 135 tableElement.currentStyle.color = " + tableElement.currentStyle.color);
        tableElement.style.color = color;
        //alert("line 137  tableElement.style.color = " +  tableElement.style.color );
				sheets =  top.document.styleSheets[0];
				ruleslist = sheets.rules;
				//alert("line 52 ruleslist.length = " + ruleslist.length);
				if(ruleslist)
				{
				  //alert("line 55 ");
					for(i = 0; i < ruleslist.length; i++)
					{ 
					  //alert("line 58 i = " + i);	
					  //alert("line 60 ruleslist[i].selectorText = " + ruleslist[i].selectorText);
					  if(ruleslist[i].selectorText.toLowerCase() == '#' + tableElement.id.toLowerCase() + ' tr td' )
					  {
					    //alert("line 61 ");
					    //if (ruleslist[i].style.color || numOfRuleFound > -1) //ie adds its own rule when first table row is created, therefore it's possible that there are two rules for tr td and it seems that the one created by the program has priority and it is necessary to add to that rule
					    //{
					      ruleslist[i].style.color = color;
//					      alert("line 154 i = " + i);
//					      alert("line 155 ruleslist[i].style.cssText = " + ruleslist[i].style.cssText);
////					      alert("line 156 ruleslist[0].selectorText = " + ruleslist[0].selectorText);
//					      alert("line 157 ruleslist[0].style.cssText = " + ruleslist[0].style.cssText);
//					      alert("line 158 ruleslist[1].selectorText = " + ruleslist[1].selectorText);
//					      alert("line 159 ruleslist[1].style.cssText = " + ruleslist[1].style.cssText);
//					      alert("line 160 ruleslist[2].selectorText = " + ruleslist[2].selectorText);
//					      alert("line 161 ruleslist[2].style.cssText = " + ruleslist[2].style.cssText);
//					      alert("line 162 ruleslist[3].selectorText = " + ruleslist[3].selectorText);
					      //alert("line 163 ruleslist[3].style.cssText = " + ruleslist[3].style.cssText);
					    //}
					    if (numOfRuleFound > -1)
					    {
					      //break;
					    }
					    else 
					    {
					      numOfRuleFound = i;
					      //alert("line 160 numOfRuleFound = " + numOfRuleFound);
					    }
					    //alert("line 63 ");
					    //alert("line 64 ruleslist[i].style.color = " + ruleslist[i].style.color);
					    //if (numOfRuleFound != i) break;
					  }
					}
				}
				//alert("line 176 i = " + i);
				//if (i == ruleslist.length || !ruleslist)
				if (numOfRuleFound == -1 || !ruleslist)
				{
					//alert("line 67 ");
					sheets.addRule('#' + tableElement.id + ' tr td','margin:0px;',0);
				  ruleslist[0].style.color = color;
//					alert("line 172 ruleslist[0].selectorText = " + ruleslist[0].selectorText);
//					alert("line 173 ruleslist[0].style.cssText = " + ruleslist[0].style.cssText);
			}
				if(arguments.length == 2)
				{
				  top.popUp(event, 'palletteDiv', top);
				}
				top.expressions[reqId][top.foregroundColorIndex] = color; 
 			  //alert('line 82');
      }
      
      function setBackgroundColor(color, id)
      {
        var sheets;
        var ruleslist;
        //var hdlElement;
        var tableElement;
        var i;
        var j;
        var arg1;
        var arg2;
        var txtbox;
        var reqId;

        //alert('line 211 id = ' + id);
        //alert('line 212 color = ' + color);
        if (!color) return;
        //alert('line 213');
        //alert("line 25  color = "  + color + " reqId = " + reqId);
        //hdlElement =  document.getElementById('alert ' + reqId);
        //hdlElement.style.backgroundColor = color;
        if (id == 'alerts')
        {
          //alert('line 219');
          //txtbox = top.frames[5].document.getElementById('displayColor');
          txtbox = top.frames['alertDialogbox'].document.getElementById('displayColor1');
          txtbox.style.backgroundColor = color;
          //top.frames[5].document.getElementById('palletteDiv').className = 'hideDiv';
          //top.frames[5].document.getElementById('selectColor').selectedIndex = 0;
          //alert('line 225');
          top.frames['alertDialogbox'].document.getElementById('palletteDiv').className = 'hideDiv';
          top.frames['alertDialogbox'].document.getElementById('selectColor').selectedIndex = 0;
          //alert('line 227');
          return;
        }
        else
        {
          reqId = id;
          tableElement = top.document.getElementById('table_' + reqId);
          //alert('line 192 reqId = ' + reqId);
          //alert('line 193 color = ' + color);
          //alert('line 194 tableElement = ' + tableElement);
          tableElement.style.backgroundColor = color;
        }  
        //alert('line 150 tableElement.style.backgroundColor = ' + tableElement.style.backgroundColor);
				if(arguments.length==2)
				{
				  top.popUp(event, 'palletteDiv', top);
 			  }
 			  top.expressions[reqId][top.backgroundColorIndex] = color;
 			  /*sheets =  document.styleSheets[0];
 			  arg1 = '#' + hdlElement.id + ' tr td';
 			  arg2 = 'background-color:' + color + ';';
 			  alert("line 56 arg1 = " + arg1);
 			  alert("line 57  arg2 = " + arg2);
 			  sheets.addRule(arg1,arg2);*/
        /*for(i = 0; i < document.styleSheets.length; i++)
        {
					sheets = document.styleSheets[i];
					ruleslist = sheets.rules;
					if(ruleslist)
					{
						for(j = 0; j < ruleslist.length; j++)
						{
						  if(ruleslist[j].selectorText.toLowerCase() == '.vendor_code' )
						  {
						    ruleslist[j].style.color = 'red';
						    alert("line 27 ruleslist[j].style.color = " + ruleslist[j].style.color);
						    found = true;
						    break;
						  }
						}
					}	
			    if(found == true)break;
			  }*/			
        //alert("line 26 document.documentElement.style.backgroundColor = " + document.documentElement.style.backgroundColor);
      }     
 
      function setFont()
      {
        var i;
        var sheets;
        var ruleslist;
        var hdlElement;
        var tableElement;
        var reqId;
        var fontFamilySelect;
        var fontSizeSelect;
        var fontSize;
        var numOfRuleFound = -1;
        //alert("line 287 " );
        //alert("line 30 document.documentElement.style.fontFamily = " + document.documentElement.style.fontFamily);
        //alert("line 31 document.getElementById('setFont').value = " + document.getElementById("setFont").value);
        // document.documentElement.style.fontFamily = document.getElementById("setFont").value;
        //alert("line 33 document.documentElement.style.fontFamily = " + document.documentElement.style.fontFamily);
        if(!arguments.length)
        {
          //alert("line 214 ");
          if (top.expressionsIndex < 0) return;
          //alert("line 273 top.expressionsIndex = " + top.expressionsIndex);
          fontFamilySelect = top.frames['fontSettings'].document.getElementById('selectFontFamily');
					fontSizeSelect = top.frames['fontSettings'].document.getElementById('selectFontSize');
					if(fontFamilySelect.selectedIndex == 0 && fontSizeSelect.selectedIndex == 0) return;
					reqId =  top.expressionsIndex;
			  }
			  else
			  {
			    //alert("line 224 ");
			    reqId = arguments[1];
			  }
			  //alert("line 276 reqId = " + reqId);	
        tableElement =  top.document.getElementById('table_' + reqId)
        //alert("line 278 tableElement = " + tableElement);	
        sheets = top.document.styleSheets[0];
				ruleslist = sheets.rules;
				//alert("line 230 ruleslist.length = " + ruleslist.length);
				if(ruleslist)
				{
				  //alert("line 233 ");
					for(i = 0; i < ruleslist.length; i++)
					{ 
					  //alert("line 295 i = " + i);	
					  /*alert("line 296 ruleslist[i].selectorText = " + ruleslist[i].selectorText);	
					  alert("line 297 ruleslist[i].cssText = " + ruleslist[i].style.cssText);	
					  alert("line 298 '#' + tableElement.id.toLowerCase() + ' tr td' = " + '#' + tableElement.id.toLowerCase() + ' tr td');
					  alert("line 299 ruleslist[i].selectorText.toLowerCase() = " + ruleslist[i].selectorText.toLowerCase());*/
						if(ruleslist[i].selectorText.toLowerCase() == '#' + tableElement.id.toLowerCase() + ' tr td' )
						{
						  //alert("line 241 i = " + i);
						  if (!arguments.length)
							{
							  if(fontFamilySelect.selectedIndex > 0)
							  {
							    //alert('line 248');
							    //if (ruleslist[i].style.fontFamily || numOfRuleFound > -1) //ie adds its own rule when first table row is created, therefore it's possible that there are two rules for tr td and it seems that the one created by the program has priority and it is necessary to add to that rule
							    //{
							      ruleslist[i].style.fontFamily = '"' + fontFamilySelect.options[fontFamilySelect.selectedIndex].value + '"';
							    //}
							    //else 
							    //{
							      numOfRuleFound = i;       
							    //}
							  }
							  //alert('line 317 fontSizeSelect.selectedIndex = ' + fontSizeSelect.selectedIndex);
							  //alert('line 318 numOfRuleFound = ' + numOfRuleFound);
							  //alert('line 319 ruleslist[i].style.fontSize = ' + ruleslist[i].style.fontSize);
							  //alert('line 321 fontSizeSelect.selectedIndex = ' + fontSizeSelect.selectedIndex);
							  //if (ruleslist[i].style.fontSize || (numOfRuleFound > -1 && numOfRuleFound != i))
							  //{
							    switch(fontSizeSelect.selectedIndex)
							    {
							      case 0:
							        //alert('line 323');
							        break;
							      case 1:
							        //alert('line 257');
							        ruleslist[i].style.fontSize = '24px';
							        break;
							      case 2:
							        //alert('line 261');
							        ruleslist[i].style.fontSize = '20px';
							        break;
							      case 3:
							        //alert('line 265');
							        ruleslist[i].style.fontSize = '16px';
							        break;
							      case 4:
							        //alert('line 269');
							        ruleslist[i].style.fontSize = '12px';
							        break;
							      case 5:
							        //alert('line 273');
							        ruleslist[i].style.fontSize = '8px';
							        break;
							    }  
                //}
              }
              else
              {
                //alert('line 376 arguments[0].fontFamily = ' + arguments[0].fontFamily);
                if (arguments[0].fontFamily)
								{
								  ruleslist[i].style.fontFamily = arguments[0].fontFamily;
								  //alert("line 280  ruleslist[i].style.fontFamily = " + ruleslist[i].style.fontFamily);
								}
								//alert('line 382 arguments[0].fontSize = ' + arguments[0].fontSize);
								//alert("line 383  ruleslist[i].style.fontSize = " + ruleslist[i].style.fontSize);
								//alert("line 384  i = " + i);
								if (arguments[0].fontSize)
								{
								  ruleslist[i].style.fontSize = arguments[0].fontSize;
								}  
					      //alert("line 285 ruleslist[i].style.cssText = " + ruleslist[i].style.cssText);
						  }
						  //if (numOfRuleFound > -1 && numOfRuleFound != i) break;
					  }
					}
				}
				//alert("line 162 i = " + i);

//				if (i == ruleslist.length && numOfRuleFound > -1) 
//				{
//				  ruleslist[numOfRuleFound].style.fontFamily = '"' + fontFamilySelect.options[fontFamilySelect.selectedIndex].value + '"';
//				}
				//else if (i == ruleslist.length || !ruleslist)
				//if (i == ruleslist.length || !ruleslist)
				if (numOfRuleFound == -1 || !ruleslist)
				{
				  //alert("line 272 ");
					sheets.addRule('#' + tableElement.id + ' tr td','margin:0px;',0);
					//alert("line 298 ruleslist[0].selectorText = " + ruleslist[0].selectorText);
					//alert("line 299 ruleslist[0].style.cssText = " + ruleslist[0].style.cssText);
					if (!arguments.length) {
					  if (fontFamilySelect.selectedIndex > 0) 
					  {
					    ruleslist[0].style.fontFamily = '"' + fontFamilySelect.options[fontFamilySelect.selectedIndex].value + '"';
					  }
					  //alert('line 388 fontSizeSelect.selectedIndex = ' + fontSizeSelect.selectedIndex);
					  switch (fontSizeSelect.selectedIndex) 
					  {
					    case 0:
					      break; 
					    case 1:
					      //alert('line 280');
					      ruleslist[0].style.fontSize = '24px';
					      break; 
					    case 2:
					      ruleslist[0].style.fontSize = '20px';
					      break; 
					    case 3:
					      ruleslist[0].style.fontSize = '16px';
					      break; 
					    case 4:
					      ruleslist[0].style.fontSize = '12px';
					      break; 
					    case 5:
					      ruleslist[0].style.fontSize = '8px';
					      break; 
					  }
					}
					else 
					{
					  //alert('line 409');
					  //alert('line 354 arguments[0].fontFamily = ' + arguments[0].fontFamily);
					  if (arguments[0].fontFamily) 
					  {
					    ruleslist[0].style.fontFamily = arguments[0].fontFamily;
					    //alert("line 329  ruleslist[0].style.fontFamily = " + ruleslist[0].style.fontFamily);
					  }
					  //alert("line 446  arguments[0].fontSize = " + arguments[0].fontSize);
					  if (arguments[0].fontSize) 
					  {
					    ruleslist[0].style.fontSize = arguments[0].fontSize;
					  }

					}  
				}
			  /*alert("line 340 ruleslist[0].selectorText = " + ruleslist[0].selectorText);
			  alert("line 341 ruleslist[0].style.cssText = " + ruleslist[0].style.cssText);
			  alert("line 342 ruleslist[1].selectorText = " + ruleslist[1].selectorText);
			  alert("line 343 ruleslist[1].style.cssText = " + ruleslist[1].style.cssText);
			  alert("line 344 ruleslist[2].selectorText = " + ruleslist[2].selectorText);
			  alert("line 345 ruleslist[2].style.cssText = " + ruleslist[2].style.cssText);
			  alert("line 346 ruleslist[3].selectorText = " + ruleslist[3].selectorText);
			  alert("line 347 ruleslist[3].style.cssText = " + ruleslist[3].style.cssText);
			  alert("line 348 ruleslist[4].selectorText = " + ruleslist[4].selectorText);
			  alert("line 349 ruleslist[4].style.cssText = " + ruleslist[4].style.cssText);
			  alert("line 350 ruleslist[5].selectorText = " + ruleslist[5].selectorText);
			  alert("line 351 ruleslist[5].style.cssText = " + ruleslist[5].style.cssText);*/
			  if (!arguments.length)
			  {
			    //alert('line 380 fontSizeSelect.selectedIndex = ' + fontSizeSelect.selectedIndex);
				  if (fontFamilySelect.selectedIndex > 0)
				  {
				    top.expressions[reqId][top.fontFamilyIndex] = fontFamilySelect.options[fontFamilySelect.selectedIndex].value;
				  }
				  if (fontSizeSelect.selectedIndex > 0)
				  {
				    //alert('line 452');
				    switch (fontSizeSelect.selectedIndex)
				    {
				      case 1:
				        //alert('line 257');
				        fontSize = '24px';
				        break;
				      case 2:
				        //alert('line 261');
				        fontSize = '20px';
				        break;
				      case 3:
				        //alert('line 265');
				        fontSize = '16px';
				        break;
				      case 4:
				        //alert('line 269');
				        fontSize = '12px';
				        break;
				      case 5:
				        //alert('line 273');
				        fontSize = '8px';
				        break;
				    }
				    top.expressions[reqId][top.fontSizeIndex] = fontSize;
				    //alert('line 479 top.expressions[reqId][top.fontSizeIndex] = ' + top.expressions[reqId][top.fontSizeIndex]);
				  }
				  top.popUp(event, 'fontSettingsDiv', top);
				  top.frames['fontSettings'].document.getElementById('selectFontFamily').selectedIndex = 0;
				  top.frames['fontSettings'].document.getElementById('selectFontSize').selectedIndex = 0;
				  top.expressionsIndex = -1;
				}
				else
				{
				  if (arguments[0].fontFamily)
				  {
				    top.expressions[reqId][top.fontFamilyIndex] = arguments[0].fontFamily;
				    top.expressions[reqId][top.fontSizeIndex] = fontSize;
				  }
				  if (arguments[0].fontSize)
				  {
				    top.expressions[reqId][top.fontSizeIndex] = arguments[0].fontSize;
				  }
				  //alert('line 493 top.expressions[reqId][fontSizeIndex] = ' + top.expressions[reqId][fontSizeIndex]);
				}
				//alert('line 495 reqId = ' + reqId); 
      }
		         

