//general purpose scripts

function findMetaVar( theMetaName, theDoc ) {
	var jj, theMetas, theMetasLength
	var theIndex = -1
	theMetaName = theMetaName.toLowerCase()
	theMetas = theDoc.getElementsByTagName( "meta" )
	theMetasLength = theMetas.length
	if( 0 < theMetasLength ) {
		for ( jj=0; jj<theMetasLength; jj++ ) {
			if( theMetas[jj].name.toLowerCase() == theMetaName ) {
				theIndex = jj
				break
				}
			}
		} 
	return theIndex
	}

function findMetaVarFast( theMetaName, theMetas ) {
	var jj, theMetasLength
	var theIndex = -1
	theMetaName = theMetaName.toLowerCase()
	theMetasLength = theMetas.length
	if( 0 < theMetasLength ) {
		for ( jj = 0; jj < theMetasLength; jj++ ) {
			if( theMetas[jj].name.toLowerCase() == theMetaName ) {
				theIndex = jj
				break
				}
			}
		} 
	return theIndex
	}

function setCopyRightString() {
	var thisDoc, ourMetas, copyRightMetaIdx
	var copyRightElmt
	var copyRightElID = "copyRight"
	var copyRightMetaName = "copyRightStr"
	var copyRightStr = ""
	var undefined

	thisDoc = self.document

	// first find a copyRight element
	copyRightElmt = thisDoc.getElementById( copyRightElID )
	if( undefined != copyRightElmt ) {
		// there is a copyright element to perhaps modify, if we can find a string
		ourMetas = thisDoc.getElementsByTagName( "meta" )
		if( 0 < ourMetas.length ) {
			// try to find a copyright in this document
			copyRightMetaIdx = findMetaVarFast( copyRightMetaName, ourMetas )
			if( -1 != copyRightMetaIdx ) {
				// get the copyright string
				copyRightStr = ourMetas[copyRightMetaIdx].content	
				}
			}
		if( 0 == copyRightStr.length ) {
			// didn't find a copyRight string here, look in top document
			var topDoc
			var topMeta
			if( top != self ) {
				topDoc = self.top.document
				topMeta = findMetaVar( copyRightMetaName, topDoc )
				copyRightStr = topMeta.content
				}
			}
		if( 0 < copyRightStr.length ) {
			// write in the copyright string we found
			copyRightElmt.firstChild.data = copyRightStr
			}
		}
	}

function setModDateString() {
	var thisDoc, ourMetas, modDateIdx
	var modDateElmt
	var modDateElID = "lastModDate"
	var modDateMetaName = "lastModDateStr"
	var modDateStr = ""
	var undefined

	thisDoc = self.document

	// first find the modDate element
	modDateElmt = thisDoc.getElementById( modDateElID )
	if( undefined != modDateElmt ) {
		// there is a modification date element to perhaps modify, if we can find a string
		ourMetas = thisDoc.getElementsByTagName( "meta" )
		if( 0 < ourMetas.length ) {
			// try to find a mod date meta in this document
			modDateIdx = findMetaVarFast( modDateMetaName, ourMetas )
			if( -1 != modDateIdx ) {
				// get the modification date string
				modDateStr = ourMetas[modDateIdx].content	
				}
			}
		if( 0 < modDateStr.length ) {
			// write in the modification date string we found
			modDateElmt.firstChild.data = modDateStr
			}
		}
	}

function setDynText() {
	setModDateString()
	setCopyRightString()
	}