﻿    var min=8;
    var max=18;
    var posX, posY;
    var colorPalette = 0;

    function increaseFontSize() {
        var p = document.getElementsByTagName('p');
        for(i=0;i<p.length;i++) {
            if(p[i].style.fontSize) {
                var s = parseInt(p[i].style.fontSize.replace("px",""));
            } else {
                var s = 12;
            }
            if(s!=max) {
                s += 1;
            }
            p[i].style.fontSize = s+"px"
        }
    }
    function decreaseFontSize() {
        var p = document.getElementsByTagName('p');
        for(i=0;i<p.length;i++) {
            if(p[i].style.fontSize) {
            var s = parseInt(p[i].style.fontSize.replace("px",""));
        } else {
            var s = 12;
        }
        if(s!=min) {
            s -= 1;
        }
        p[i].style.fontSize = s+"px"
        }
    }
    
    var colors = "FFFFFF||FFCCCC||FFCC99||FFFF99||FFFFCC||99FF99||99FFFF||CCFFFF||CCCCFF||FFCCFF||CCCCCC||FF6666||FF9966||FFFF66||FFFF33||66FF99||33FFFF||66FFFF||9999FF||FF99FF||C0C0C0||FF0000||FF9900||FFCC66||FFFF00||33FF33||66CCCC||33CCFF||6666CC||CC66CC||999999||CC0000||FF6600||FFCC33||FFCC00||33CC00||00CCCC||3366FF||6633FF||CC33CC||666666||990000||CC6600||CC9933||999900||009900||339999||3333FF||6600CC||993399||333333||660000||993300||996633||666600||006600||336666||000099||333399||663366||000000||330000||663300||663333||333300||003300||003333||000066||330099||330033";

    function CreateColorPallette() {
        if (colorPalette == 0)
        {
            var oTbl = document.createElement("Table");
            oTbl.style.backgroundColor = "gray";
            var clr = colors.split("||");
            var k = 0;
            for (i=0;i<7;i++) {
                var oRow = oTbl.insertRow(i);
                for(j=0;j<10;j++) {
                    var oCell = oRow.insertCell(j);
                    oCell.style.backgroundColor = clr[k];
                    oCell.style.width = 8;
                    oCell.style.height = 8;
                    var sCall = "javascript:updateColor('#" + clr[k] + "')";
                    oCell.innerHTML = "<a href =" + sCall + ">" + "<img src='empty.bmp' width = '8' height='8' border='0'></br></a>";
                    k = k + 1;
                }
            }
            document.getElementById("colorPallette").appendChild(oTbl);
            HideColorPallette();
            colorPalette = 1;
        }
    }

    function updateColor(sColor) {
        var p = document.getElementsByTagName('p');
        for(i=0;i<p.length;i++) {
	        p[i].style.color = sColor;
        }
        HideColorPallette();
    }

    function ShowColorPallette() {
        CreateColorPallette();
        if (document.getElementById("colorPallette").style.visibility == "visible") {
            document.getElementById("colorPallette").style.visibility = "hidden";
        } else {
            document.getElementById("colorPallette").style.visibility = "visible";
        }
    }

    function HideColorPallette() {
        document.getElementById("colorPallette").style.visibility = "hidden";
    }
    
    function GetMousePosition() {
    }
    
    function allowNumberOnly()
    {
	    if( event.keyCode >= 48  && event.keyCode <= 58 || event.keyCode == 46 )
		    return true;
	    return false;
    }

    var strUserAgent = navigator.userAgent.toLowerCase(); 
    var isIE = strUserAgent.indexOf("msie") > -1; 
    function maskChange(objEvent) 
    {
  	    var objInput;
      	
  	    if (isIE) 
  	    {
    	    objInput = objEvent.srcElement; 
  	    }
        else 
	    {
	   	    objInput = objEvent.target;
	    }
	    if (!isValid(objInput.value)) 
	    {
	  	    alert("Please enter a numeric value");
		    objInput.value = objInput.validValue || "";
		    objInput.focus();
	   	    objInput.select(); 
	    } 
	     else 
	    {
	        objInput.validValue = objInput.value;
	    }
    }

    var reValidString = /^\d*$/;
    function isValid(strValue) 
    {
	    return reValidString.test(strValue) || strValue.length == 0;			
    }


/* For Grid Start */
var TADF = null;
var TASE = null;
function rowOver(row)
{
//alert("Row over");
    if(row != null && row != TASE)
    {
        row.setAttribute(TADF, row.style.backgroundColor);
        if (row != null && row.cells != null)
        {
            for (var i= 0;i<row.cells.length;i++)
            {
                row.cells[i].style.backgroundColor = "#33FF00";
            }
        }
    }
}

function rowOut(row)
{
    if(row != TASE)
    {
        if (row != null && row.cells != null)
        {
            for (var i= 0;i<row.cells.length;i++)
            {
                row.cells[i].style.backgroundColor = row.getAttribute(TADF);
            }
        }
    }
}

function rowSelect(row)
{
    if(row != null)
    {
        if (row != null && row.cells != null)
        {
            for (var i= 0;i<row.cells.length;i++)
            {
                row.cells[i].style.backgroundColor = "#669900";
            }
        }
        if (row != TASE)
        {
            rowUnselect();
            TASE = row;
        }
    }
}

function rowUnselect()
{
    if (TASE != null)
    {
        var row = TASE;
        if (row != null && row.cells != null)
        {
            for (var i= 0;i<row.cells.length;i++)
            {
                row.cells[i].style.backgroundColor = TASE.getAttribute(TADF);
            }
            TASE = null;
        }
    }
}

/* For Grid End */

