todaysDate = "XXtodayXX"; firstDate = "XXfirstXX"; function headline (hcid,title,content,displaydate,image) { this.hcid = hcid; this.title = title; this.content = content; this.displaydate = displaydate; this.image = image; } function replaceSubstring(inputString, fromString, toString) { var temp = inputString; if (toString.indexOf(fromString) == -1) { while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } else { var midStrings = new Array("~", "`", "_", "^", "#"); var midStringLen = 1; var midString = ""; while (midString == "") { for (var i=0; i < midStrings.length; i++) { var tempMidString = ""; for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; } if (fromString.indexOf(tempMidString) == -1) { midString = tempMidString; i = midStrings.length + 1; } } } while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + midString + toTheRight; } while (temp.indexOf(midString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(midString)); var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } return temp; } tempCode = startCode; tempCode = replaceSubstring(tempCode,"@@todaysDate@@",todaysDate); tempCode = replaceSubstring(tempCode,"@@firstDate@@",firstDate); document.writeln(tempCode); for(x=1;x<=currentCount;x++) { tempItemCode = itemCode; tempItemCode = replaceSubstring(tempItemCode,"@@hcid@@",headline[x].hcid); tempItemCode = replaceSubstring(tempItemCode,"@@title@@",headline[x].title); tempItemCode = replaceSubstring(tempItemCode,"@@content@@",headline[x].content); tempItemCode = replaceSubstring(tempItemCode,"@@displaydate@@",headline[x].displaydate); tempItemCode = replaceSubstring(tempItemCode,"@@image@@",headline[x].image); document.writeln(tempItemCode); if (x != currentCount) { document.writeln(midCode); } } tempCode = endCode; tempCode = replaceSubstring(tempCode,"@@todaysDate@@",todaysDate); tempCode = replaceSubstring(tempCode,"@@firstDate@@",firstDate); document.writeln(tempCode);