<!-- // Main Javascript source
iLoadFlag = 0;
SessionKey = "";
iSessionFlag = 0;
remote = 0;
var loc = "";
var dd, mm, yy;
var isNav, isIE;
var coll = "";
var styleObj = "";
var bar_margin = 4;

var pPop = 0;
if (window.location.href.indexOf("win=pop", 0) < 1) {pPop = 1;}

var ptest = 't';
if (window.location.href.indexOf("test", 0) < 1) {ptest = '';}

if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true;
		bar_margin = 20;
	} else {
		isIE = true;
		coll = "all.";
		styleObj = ".style";
	}
}

var oven_selects = [];


// Title: Tigra Calendar
// URL: http://www.softcomplex.com/products/tigra_calendar/
// Version: 3.4 (European date format)
// Date: 07/12/2007
// Note: Permission given to use this script in ANY kind of applications if
//    header lines are left unchanged.
// Note: Script consists of two files: calendar?.js and calendar.html

// if two digit year input dates after this year considered 20 century.
var NUM_CENTYEAR = 30;
// is time input control required by default
var BUL_TIMECOMPONENT = false;
// are year scrolling buttons required by default
var BUL_YEARSCROLL = true;

var calendars = [];
var RE_NUM = /^\-?\d+$/;

function calendar1(obj_target) {

	// assigning methods
	this.gen_date = cal_gen_date1;
	this.gen_time = cal_gen_time1;
	this.gen_tsmp = cal_gen_tsmp1;
	this.prs_date = cal_prs_date1;
	this.prs_time = cal_prs_time1;
	this.prs_tsmp = cal_prs_tsmp1;
	this.popup    = cal_popup1;

	// validate input parameters
	if (!obj_target)
		return cal_error("Error calling the calendar: no target control specified");
	if (obj_target.value == null)
		return cal_error("Error calling the calendar: parameter specified is not valid target control");
	this.target = obj_target;
	this.time_comp = BUL_TIMECOMPONENT;
	this.year_scroll = BUL_YEARSCROLL;
	
	// register in global collections
	this.id = calendars.length;
	calendars[this.id] = this;
}

function cal_popup1 (str_datetime) {
	if (str_datetime)
		this.dt_current = this.prs_tsmp(str_datetime);
	else 
		this.dt_selected = this.dt_current = this.prs_tsmp(this.target.value);

	if (!this.dt_current) return;

	var obj_calwindow = window.open(
		'../pages/calendar.html?id=' + this.id + '&s=' + this.dt_selected.valueOf() + '&c=' + this.dt_current.valueOf(),
		'Calendar', 'width=200,height=' + (this.time_comp ? 215 : 190) +
		',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
	);
	obj_calwindow.opener = window;
	obj_calwindow.focus();
}

// timestamp generating function
function cal_gen_tsmp1 (dt_datetime) {
	return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
}

// date generating function
function cal_gen_date1 (dt_datetime) {
	return (
		(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/"
		+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "/"
		+ dt_datetime.getFullYear()
	);
}
// time generating function
function cal_gen_time1 (dt_datetime) {
	return (
		(dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
		+ (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
		+ (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
	);
}

// timestamp parsing function
function cal_prs_tsmp1 (str_datetime) {
	// if no parameter specified return current timestamp
	if (!str_datetime)
		return (new Date());

	// if positive integer treat as milliseconds from epoch
	if (RE_NUM.exec(str_datetime))
		return new Date(str_datetime);
		
	// else treat as date in string format
	var arr_datetime = str_datetime.split(' ');
	return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
}

// date parsing function
function cal_prs_date1 (str_date) {

	var arr_date = str_date.split('/');

	if (arr_date.length != 3) return cal_error ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
	if (!arr_date[0]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
	if (!RE_NUM.exec(arr_date[0])) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[1]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
	if (!RE_NUM.exec(arr_date[1])) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[2]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
	if (!RE_NUM.exec(arr_date[2])) return cal_error ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

	var dt_date = new Date();
	dt_date.setDate(1);

	if (arr_date[1] < 1 || arr_date[1] > 12) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
	dt_date.setMonth(arr_date[1]-1);
	 
	if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
	dt_date.setFullYear(arr_date[2]);

	var dt_numdays = new Date(arr_date[2], arr_date[1], 0);
	dt_date.setDate(arr_date[0]);
	if (dt_date.getMonth() != (arr_date[1]-1)) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

	return (dt_date)
}

// time parsing function
function cal_prs_time1 (str_time, dt_date) {

	if (!dt_date) return null;
	var arr_time = String(str_time ? str_time : '').split(':');

	if (!arr_time[0]) dt_date.setHours(0);
	else if (RE_NUM.exec(arr_time[0]))
		if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
		else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
	else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
	
	if (!arr_time[1]) dt_date.setMinutes(0);
	else if (RE_NUM.exec(arr_time[1]))
		if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
		else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");

	if (!arr_time[2]) dt_date.setSeconds(0);
	else if (RE_NUM.exec(arr_time[2]))
		if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
		else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");

	dt_date.setMilliseconds(0);
	return dt_date;
}

function cal_error (str_message) {
	alert (str_message);
	return null;
}





function oven_select(obj_target) {

	// assigning methods
	this.popup    = OS_popup;

	// validate input parameters
	if (!obj_target)
		return OS_error("Error calling the calendar: no target control specified");
	if (obj_target.value == null)
		return OS_error("Error calling the calendar: parameter specified is not valid target control");
	this.target = obj_target;
	
	// register in global collections
	this.id = oven_selects.length;
	oven_selects[this.id] = this;
}

function OS_popup (p_left, p_top) {

	var obj_oswindow = window.open(
		'f2f_oven_select.pl?id=' + this.id,
		'OvenSelect', 'width=330,height=500,status=no,resizable=no,top=' + p_top + ',left=' + p_left + ',dependent=yes,alwaysRaised=yes'
	);
	obj_oswindow.opener = window;
	obj_oswindow.focus();
}

function OS_error (str_message) {
	alert (str_message);
	return null;
}

function WO(pURL, pName) {
	remote = window.open(pURL, pName,'scrollbars=yes,toolbar=no,menubar=no,location=no');
	remote.focus();
}


//	Display page header #A9A81A
function PageHeader() {
	document.write("<DIV style='position:absolute; top:0; left:0; width:" + (document.body.clientWidth - bar_margin) + "; background-color: #ffffff; height: 155;'><DIV style='position:absolute; top:0; left:2'><IMG src = '../../graphics/bg" + ptest + ".jpg' width='" + (document.body.clientWidth - bar_margin) + "' height ='155'></DIV><DIV style='position:absolute; top:43; left:" + parseInt((document.body.clientWidth - 751) / 2) + "'><IMG src = '../../graphics/header_bg.jpg'></DIV>"); 
	document.write("<DIV style='position:absolute; top:156; left:" + parseInt((document.body.clientWidth - 751) / 2) + "; width:751; >"); 
}


//	Initial page header
function HeaderOpen(pRoute) {
var pwidth = document.body.clientWidth;

	document.write("<DIV style='position:absolute; top:0; left:0; width:" + (pwidth - 34) + "; '>\n<DIV class='header' style='position:absolute; top:5; left:5; width:" + (pwidth - 10) + "; height: 102;'><DIV style='position:absolute; top:5; left:4; border:0;'><IMG src = '" + pRoute + "graphics/logo1.gif' alt='Ovenfeast Logo'></DIV></DIV><DIV style='position:absolute; top:0; left:4; width:" + (pwidth -  40) + ";'>");
}

//		Display page footer
function Footer(pDate, pTop)
{
	document.write("<BR><BR><center><SPAN style='Font-size:75%; font-style:italic; font-weight:300; text-decoration: none;'>");

	if (pTop != "N") document.write ("<A HREF='#Top'><B>Top</B></A>&nbsp;&nbsp;")

		document.write ("<font size='-1'>Published by Ovenfeast, Ireland -" + pDate + " - Implemented by <A HREF='http://www.tree-of-life.co.uk'>Tree of Life<\/A> Computers.</font>");

	if (pTop != "N") document.write ("&nbsp;&nbsp;<A HREF='#Top'><B>Top</B><\/A>");

	document.close();
}


//	Display Standard header
function StdHeader(pTitle, pColHeader) {

	if (navigator.appName == "Microsoft Internet Explorer") {isIE = true;}
	headPlace = (isIE ? 94 : 80);
	document.write("<DIV style='position:absolute; top:2; left:20'><DIV style='position:absolute; top:0; left:0;  width:" + (document.body.clientWidth - 40) + "; background-color: #A9A81A; height: 116;'><DIV style='position:absolute; top:2; left:2'><IMG src = '../../graphics/bg" + ptest + ".jpg' width='" + (document.body.clientWidth - 44) + "' height ='112'></DIV><DIV style='position:absolute; top:5; left:4'><IMG src = '../../graphics/logo1-83.gif'></DIV>"); 
	document.write("<DIV style='position:absolute; top:20; left:120; height:30; width:" + (document.body.clientWidth - 154) + "; padding:0; text-decoration: none; text-align:top; text-align: center; line-height:110%; font-size: 30px; font-weight: 700; '>" + pTitle + "</DIV><DIV style='position:absolute; top:" + headPlace + "; left:4; height:20; width:" + (document.body.clientWidth - 30) + "; text-align:top; font-size: 15px; font-weight: 700;'><pre>" + pColHeader + "</pre></DIV></DIV>\n"); 
	document.write("<DIV style='position:absolute; top:130; left:0; padding:5; width:" + (document.body.clientWidth - 45) + "; background-color: #ffffff;'>"); 
}
// border: solid #9cccfd 20px;


//	End child window
function EndChild (pKey)
{
	SetReloader(pKey);
	window.close();
}


//**************************
//	Set the Session Expiry.
function ExpirySet (pSessionKey, pKey, pTimeout)
{	
	var TimeoutPeriod = pTimeout * 60000
	if (pSessionKey != "") {
		ExpiryCheck ("S", pSessionKey, pKey, TimeoutPeriod)
	}
}



//**************************
//	Manage the Session Expiry.
function ExpiryCheck (pAction, pSessionKey, pKey, pTimeout)
{
  if (pSessionKey == "") {
	top.window.close();
  } else {
	var own_url;
	var TimeOut = pTimeout
	var Flag = 0
	var Expiry = 1
	var cookieData = GetCookie ("expire");
	var ctext = ""
	var NewCookieData = ""
	var clen = cookieData.length
	var i = 0
	var j = 0
	var CurrentDate = new Date()
	var TimeInMS = CurrentDate.getTime()
	var ExpiryTime = 0;
	while (i < clen) {
		j = cookieData.indexOf("*", i)
		if (j > i) {
			ctext = cookieData.substring(i,j+1)
			if ((i + 40) < j) {
				ExpiryTime = parseInt(ctext.substring(40,j-i))
				if (ctext.substring(0,40) == pSessionKey) {
					Flag = 1
					if (pAction == "S") {
						ctext = ctext.substring(0,40) + (TimeInMS + pTimeout) + "*"
						Expiry = 0
					} else {
						if (ExpiryTime > TimeInMS) {
							TimeOut = ExpiryTime - TimeInMS
							Expiry = 0
						} else {
							ctext = ""
						}
					}
				} else {
					if (ExpiryTime < TimeInMS) {
						ctext = ""
					}
				}
			} else {
				ctext = ""
			}
			i = j + 1;
		} else {
			i = clen
		}
		NewCookieData += ctext
	}
	if (Flag == 0 && pAction == "S") {
		Expiry = 0
		TimeInMS += pTimeout
		ctext = "" + TimeInMS
		ctext = pSessionKey + ctext + "*"
		NewCookieData += ctext
	}													// Insert new session.
	document.cookie = "expire=" + NewCookieData			// Set cookie

	if (Expiry == 1) {
		iSessionFlag = 0;
		if (pKey == "P") {
			top.window.location = "login.pl?choice=;"
		} else {
			top.window.close()
		}
	} else {
		ctext = "ExpiryCheck('C', '" + pSessionKey + "', '" + pKey + "', '" + pTimeout + "')"
		setTimeout(ctext, TimeOut);
	}
  }
}



//*********************************************
//	Command the reloading of page.
//*********************************************
function SetReloader (pKey)
{
	var klen = pKey.length;
	var TimeOutPeriod = 3000
	var Flag = 0
	var cookieData = GetCookie ("reload");
	var ctext = ""
	var NewCookieData = ""
	var clen = cookieData.length;
	var i = 0
	var j = 0
	var CurrentDate = new Date()
	var TimeInMS = CurrentDate.getTime()
	var ExpiryTime = 0;
	while (i < clen) {
		j = cookieData.indexOf("*", i)
		if (j > i) {
			ctext = cookieData.substring(i,j+1)
			if ((i + klen) < j) {
				ExpiryTime = parseInt(ctext.substring(klen,j-i))
				if (ctext.substring(0,klen) == pKey) {
					Flag = 1
					ctext = ctext.substring(0,klen) + (TimeInMS + TimeOutPeriod) + "*"
				} else {
					if (ExpiryTime < TimeInMS) {
						ctext = ""
					}
				}
			} else {
				ctext = ""
			}
			i = j + 1;
		} else {
			i = clen
		}
		NewCookieData += ctext
	}
	if (Flag == 0) {
		TimeInMS += TimeOutPeriod
		ctext = "" + TimeInMS
		ctext = pKey + ctext + "*"
		NewCookieData += ctext
	}													// Insert new reload.
//alert ('New cookie = ' + NewCookieData);
	document.cookie = "reload=" + NewCookieData;			// Set reload cookie
}


//*********************************************
//	Checking for need to reload a page.
//*********************************************
function CheckReload (pKey)
{
//alert ('Check Reload key = ' + pKey);
	var klen = pKey.length;
	var Flag = 0;
	var cookieData = GetCookie ("reload");
	var ctext = "";
	var NewCookieData = "";
	var clen = cookieData.length;
	var i = 0;
	var j = 0;
	while (i < clen) {
		j = cookieData.indexOf("*", i)
		if (j > i) {
			ctext = cookieData.substring(i,j+1)
			if (ctext.substring(0,klen) == pKey) {
				Flag = 1
				ctext = "";
			}
			i = j + 1;
		} else {
			i = clen
		}
		NewCookieData += ctext;
	}
//if (clen > 0) {
//alert ('key = ' + pKey + ' - ' + NewCookieData);
//}
	document.cookie = "reload=" + NewCookieData			// Set reload cookie
	if (Flag == 1) {
		location.reload(true);	
	}												// instruct reload.
	ctext = "CheckReload('" + pKey + "')";
	setTimeout(ctext, 2000);
}


//////////////////////////////
//	Test for null and empty
/////////////////////////////
function isEmpty(pStr) {
	if (pStr == null || pStr == "") {
		return true;
	}
	return false;
}


//********************
//	Convert to upper case
function ToU(pField) {
	pField.value = pField.value.toUpperCase();
}


//********************
//	Convert spaces to colons
function removeSpace(pField) {
	var re = / /g;
	var str = pField.value;
	pField.value = str.replace(re, ":");
}


//********************
//	Convert to standard DATE
function StdDate(pField) {
	var pDate = pField.value;
	if (pDate != '') {
		if (isDate(pField.value)) {
			pDate = (yy + 1000) + ".";
			pDate = dd + "/" + mm + "/" + pDate.substring(2,4);
			pField.value = pDate;
		} else {
			alert("Field is not a valid date.");
			pField
		}
	}
}



//********************
//	Validate input as DATE
function isDate(pStr) {
var today = new Date()
	dd = 0;
	mm = 0;
	yy = today.getYear()
var inputStr = pStr

	if (inputStr == "") { return true ;}

	// convert hyphen delimiters to slashes
	while (inputStr.indexOf("-") != -1) {
		inputStr = replaceString(inputStr,"-","/")
	}
	// convert space delimiters to slashes
	while (inputStr.indexOf(" ") != -1) {
		inputStr = replaceString(inputStr," ","/")
	}
	// convert . delimiters to slashes
	while (inputStr.indexOf(".") != -1) {
		inputStr = replaceString(inputStr,".","/")
	}
	var delim1 = inputStr.indexOf("/")
	var delim2 = inputStr.lastIndexOf("/")
	if (delim1 == -1) {
		dd = parseInt(inputStr.substring(0,2),10)
		if (inputStr.length < 3) {
			mm = today.getMonth() + 1
		} else {
			if (inputStr.length > 4) {
				mm = parseInt(inputStr.substring(2,4),10)
				yy = parseInt(inputStr.substring(4,6),10)
			} else {
				mm = parseInt(inputStr.substring(2,4),10)
			}
		}
	} else {
		dd = parseInt(inputStr.substring(0,delim1),10)
		if (delim1 == delim2) {
			mmm = inputStr.substring(delim2 + 1, inputStr.length)
		} else {
			mmm = inputStr.substring(delim1 + 1,delim2);
			yy = parseInt(inputStr.substring(delim2 + 1, inputStr.length),10);
		}
		mm = parseInt(mmm, 10);
		if (isNaN(mm)) {
			mmm = "z" + mmm.substring(0, 3);
			var mon = "zjanzfebzmarzaprzmayzjunzjulzaugzsepzoctznovzdec".indexOf( mmm)
			if (mon > -1) {
				mm = mon / 4 + 1;
			} 
//alert(mm);
		}
	}
	if (isNaN(mm) || isNaN(dd) || isNaN(yy) || mm < 1 || mm > 12 || dd < 1 || dd > 31) {
		return false
	}
	if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30) {
		return false
	}
	if (mm == 2 && (dd > 29 || (yy % 4 != 0 && dd > 28))) {
		return false
	}
	return true;
}


///////////////////////////////
//	Test for Positive Integer
//////////////////////////////
function isPosInteger(pStr) {
	inputStr = pStr.toString();
	if (inputStr != "") {
		for (var i = 0; i < inputStr.length; i++) {
			var oneChar = inputStr.charAt(i);
			if (oneChar < "0" || oneChar > "9") {
				return false;
			}
		}
		return true;
	}
	return false;
}


//********************
//	Convert to two decimal places
function toNumFormat(pField) {
	var pStr = pField.value;
	if (isNumber(pStr)) {
			var res = parseFloat(pStr) * 100. + 0.5;
			var res1 = parseInt(res);
			var res2 = res1.toString(10);
			while (res2.length < 3) {
				res2 = '0' + res2;
			}
			var len = res2.length;
			var res3 = res2.substring (0, len - 2) + '.' + res2.substring (len -2, len);
			pField.value = res3;
	} else {
		pField.value = '';
	}
}


//********************
//	Convert to positive integer
function toNumericalDigits(pField) {
	var pStr = pField.value;
	var res = "";
	if (pStr != "") {
		for (var i = 0; i < pStr.length; i++) {
			var oneChar = pStr.charAt(i);
			if (oneChar >= "0" && oneChar <= "9") {
				res = res + oneChar;
			}
		}
		pField.value = res;
	}
}


///////////////////////////////
//	Test for Integer
//////////////////////////////
function isInteger(pStr) {
	inputStr = pStr.toString();
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if (i == 0 && (oneChar == "-" || oneChar == "+")) {
			continue
		}
		if (oneChar < "0" || oneChar > "9") {
			return false;
		}
	}
	return (!isEmpty(inputStr));
}



///////////////////////////////
//	Test if number
//////////////////////////////
function isNumber(pStr) {
	oneDecimal = false;
	inputStr = pStr.toString();
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if (i == 0 && (oneChar == "-" || oneChar == "+")) {
			continue
		}
		if (oneChar == "." && !oneDecimal) {
			oneDecimal = true;
			continue;
		}
		if (oneChar < "0" || oneChar > "9") {
			return false;
		}
	}
	return (!isEmpty(inputStr));
}


///////////////////////////////
//	Test if e-mail address
//////////////////////////////
function isEmail(pStr) {
	var re = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/					// Features not in e-mail address
	var re1 = /^.+\@(\[?)([a-zA-Z0-9\-\.]+)\.([a-zA-Z0-9]+)(\]?)$/		// Valid pattern of address.
	return (!re.test(pStr) && re1.test(pStr))
}



////////////////////////////////////////////////
//		Get Cookie Data
////////////////////////////////////////////////
function GetCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape (document.cookie.substring (offset, endstr));
}



//////////////////////////////////////////
//		Get Cookie by name
///////////////////////////////////////////
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j = 0;
	while (i < clen) {
		j = i + alen;
		if (document.cookie.substring (i, j) == arg)
							return GetCookieVal (j);
		i = document.cookie.indexOf (" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}




//************************
// extract front part of string prior to searchString
function getFront(mainStr,searchStr){
        foundOffset = mainStr.indexOf(searchStr)
        if (foundOffset == -1) {
                return null
        }
        return mainStr.substring(0,foundOffset)
}


//************************
// extract back end of string after searchString
function getEnd(mainStr,searchStr) {
        foundOffset = mainStr.indexOf(searchStr)
        if (foundOffset == -1) {
                return null
        }
        return mainStr.substring(foundOffset+searchStr.length,mainStr.length)
}



//************************
// insert insertString immediately before searchString
function insertString(mainStr,searchStr,insertStr) {
        var front = getFront(mainStr,searchStr)
        var end = getEnd(mainStr,searchStr)
        if (front != null && end != null) {
                return front + insertStr + searchStr + end
        }
        return null
}



//************************
// remove deleteString
function deleteString(mainStr,deleteStr) {
        return replaceString(mainStr,deleteStr,"")
}



//************************
// replace searchString with replaceString
function replaceString(mainStr,searchStr,replaceStr) {
        var front = getFront(mainStr,searchStr)
        var end = getEnd(mainStr,searchStr)
        if (front != null && end != null) {
                return front + replaceStr + end
        }
        return null
}




//********************************************
// Pad front of string.
/////////////////////////////////////////////////
function padString(pad_str,pad_char,pad_len) {
	var str = pad_str
	while (str.length < pad_len) {
        str = pad_char + str
    }
    return str
}



//**************************
// checks for single-letter Y, N, or U
function isNYU(pStr) {
	var inputStr = pStr
	if (inputStr.length != 1 || "NYU".indexOf(inputStr) == -1) {
		return false	
	}
	return true
}


// -->


