function dbug(sString) { alert(sString); } function fnRandomColourName() { var iRandom; var sReturn; var aaColourNames = new Array ("blue", "green", "orange", "red", "lightgreen", "lightblue"); iRandom = Math.round(Math.random() * 5); return aaColourNames[iRandom]; } // fnRandomColourName //** FUNCTION: //** fnColourDiamond(...) //** DATE: //** March 2002 //** DESCRIPTION: //** creates a coloured diamond shape using the //** background colour attribute of an html table cell (). //** STATUS: dev //** LOCATION: //** http://www.geocities.com/matth3wbishop/eg/javascript/ function fnColourDiamond(iSize, sBgColour, iRepeat, iSpacing) { var bCellIsColoured = new Boolean(true); var iMiddleRowOffset; var iCenterColumn; //-- 'middle' column var iCenterRow; //-- the 'middle' row of the diamond var iFirstColourCell; //-- The column number of the first cell which is //-- 'within' the diamond, i.e. is coloured var iLastColourCell; //-- The column number of the last cell which is //-- 'within' the diamond, i.e. is coloured var sReturn = ""; //-- parameter defaults if (sBgColour == null) { sBgColour = "white"; } if (iSize == null) { iSize = 5; } if (iRepeat == null) { iRepeat = 1; } //-- prevent even numbered sizes (for now) if (iSize < 3) { iSize = 5; } if ((iSize % 2) == 0) { iSize = iSize - 1; } if (iSpacing == null) { iSpacing = iSize; } //-- The columns use a 1-based numbering system but //-- the rows use a zero-based numbering. (?) iCenterColumn = ((iSize - 1)/ 2) + 1; iCenterRow = ((iSize - 1)/ 2); //dbug(iCenterColumn); sReturn += " \n"; for (var jj = 0; jj < iRepeat; jj++) { sReturn += " \n"; if (iSpacing != 0) { sReturn += " \n"; } // if iSpacing not 0 } // for iRepeat sReturn += ""; sReturn += "
"; sReturn += " \n"; for (var iCurrentRow = 0; iCurrentRow < iSize; iCurrentRow++) { iMiddleRowOffset = iCenterRow - Math.abs(iCenterRow - iCurrentRow) iFirstColourCell = iCenterColumn - iMiddleRowOffset; iLastColourCell = iCenterColumn + iMiddleRowOffset; //alert(iMiddleRowOffset); sReturn += " \n"; for (var iCurrentColumn = 1; iCurrentColumn < iSize+1; iCurrentColumn++) { if ((iCurrentColumn >= iFirstColourCell) && (iCurrentColumn <= iLastColourCell)) { bCellIsColoured = true; } else { bCellIsColoured = false; } if (bCellIsColoured) { sReturn += " \n"; } else { sReturn += " \n"; } /* if, else */ } /* for each col */ sReturn += " \n"; } /* for each row */ sReturn += "
  
\n"; sReturn += "
\n" + " \n"; for (var kk = 0; kk < iSize; kk++) { sReturn += " \n"; for (var nn = 0; nn < iSpacing; nn++) { sReturn += " \n"; } // for sReturn += " \n"; } // for each spacer row sReturn += "
 
\n" + "
"; //alert(sReturn); return sReturn; } // fnColourDiamond()