var arrMonths =      ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var arrShortMonths=  ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
var arrNumericMonths=["01","02","03","04","05","06","07","08","09","10","11","12"]
var arrDays   =      [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
var strAlpha  =	     "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var strNumbers=	     "0123456789";
var strDateDisplayMask= "dd/mm/yyyy"

//Allow account number input (DBS at present)
function validateAccountNumber(objGen)
{
            if(objGen.value.length == 0)
            {
                if(window.event.keyCode > 96 && window.event.keyCode < 123)
                {
                    window.event.keyCode = (window.event.keyCode - 32);
                }

                if(window.event.keyCode < 48)
                {
                    window.event.keyCode = 0;
                }
                else
                {
                    if(window.event.keyCode > 57)
                    {
                        if(window.event.keyCode < 65 || window.event.keyCode > 90)
                        {
                            window.event.keyCode = 0;
                        }
                    }
                }
            }
            else
            {
                if(window.event.keyCode < 48 || window.event.keyCode > 57)
                {
                    window.event.keyCode = 0;
                }
            }
}

//Requires reimplementation for each card or account type (DBS)
function CheckDigit(strAccountNo)
{
    var total = 0;
    var remainder = 0;
    var check_digit = 0;
    var i;
    var nolength;
    var tempchar;
    var newstring;

    // Valid Number 114534006
    i = 0;
    newstring = "";
    nolength = strAccountNo.length;
    if(nolength == 0)
    {
        return(true);
    }

    if(strAccountNo.length == 8)
    {
        strAccountNo = "0" + strAccountNo;
    }

    if(nolength == 9)
    {
        tempchar = strAccountNo.charCodeAt(0);
        if((tempchar > 63) && (tempchar < 91))
        {
            newstring = strAccountNo.charAt(0) + "0" + strAccountNo.substring(1, 9);
            strAccountNo = newstring;
        }
    }

    nolength = strAccountNo.length;
    if(nolength == 10)
    {
        i = 1;
    }

    if(strAccountNo.length < 9)
    {
        return(false);
    }

    if(strAccountNo.length > 10)
    {
        return(false);
    }

    total = ((strAccountNo.charCodeAt(i) - 48) * 8) + ((strAccountNo.charCodeAt(i + 1) - 48) * 5) +
        ((strAccountNo.charCodeAt(i + 2) - 48) * 2) + ((strAccountNo.charCodeAt(i + 3) - 48) * 8) +
            ((strAccountNo.charCodeAt(i + 4) - 48) * 5) + ((strAccountNo.charCodeAt(i + 5) - 48) * 7) +
                ((strAccountNo.charCodeAt(i + 6) - 48) * 2);
    remainder = 11 - (total % 11);
    switch(remainder)
    {
        case 10:
            if(strAccountNo.substring(7, 9) == "10")
            {
                return(true);
            }
            else
            {
                return(false);
            }
            break;
        case 11:
            check_digit = 0;
            break;
        default:
            check_digit = remainder;
            break;
    }

    total = 0;
    total = (strAccountNo.charCodeAt(i + 7) - 48) + (strAccountNo.charCodeAt(i + 8) - 48);
    if(total == check_digit)
    {
        return(true);
    }
    else
    {
        return(false);
    }
}

//Suppress Alpha's and non-currency chars
function validateCurrency(objGen)
{
    // Only numerics and signs
    if(window.event.keyCode < 43 || window.event.keyCode > 57)
    {
	window.event.keyCode = 0;
    }

    // Ignore commas
    if(window.event.keyCode == 44)
    {
	window.event.keyCode = 0;
    }

    // Only allow sign as first entry
    if(objGen.value.length > 0 && (window.event.keyCode == 43 || window.event.keyCode == 45))
    {
	window.event.keyCode = 0;
    }

    // Only allow one decimal point
    var blnDecimal = false;
    for(i = 0; i < objGen.value.length; i++)
    {
	if(objGen.value.charAt(i) == '.')
	{
	    blnDecimal = true;
	    break;
	}
    }
    if((blnDecimal == true || objGen.NoDecimals == true) && window.event.keyCode == 46)
    {
	window.event.keyCode = 0;
    }

    // Only allow two decimal places
    if(objGen.value.length > 2)
    {
	// Check to see if overwriting
	// If before point OK else if after point and no decimal selected don't allow
	if((objGen.value.charAt(objGen.value.length - 3) == '.'))
	{
		/*if (objGen.createTextRange) 
		{
			objGen.caretPos = document.selection.createRange().duplicate();
			var caretPos = objGen.caretPos;
			if (caretPos > ((objGen.value.length - 3)) )
				window.event.keyCode = 0;
		}
		*/
	}
    }
}

//Format display of amounts
function FormatCurrency(strMoney, strCurrencySymbol)
{
    var holder = UnformatCurrency(strMoney);
    if(strCurrencySymbol != null)
    {
        return(FormatCurrencyEx(holder, strCurrencySymbol, false));
    }
    else
    {
        alert("Currency symbol not optional.");
    }
}


//Format currency and decimals (round up)
function FormatCurrencyEx(strMoney, strCurrencySymbol, blnNoDecimals)
{
    var strFormat = "";
    var strTemp = "";
    var numMoney = 0;
    var Decimals = 0;
    var holder = UnformatCurrency(strMoney);
    strFormat = "" + strCurrencySymbol;
    if(holder.length > 0)
    {
        numMoney = parseFloat(holder);
        if(isNaN(numMoney) == true)
        {
            return(strFormat.concat("0.00"));
        }   //if
        else
        {
            Decimals = Math.round((numMoney % 1) * 100);
            if(Decimals < 0)
            {
                Decimals = Decimals * -1;
            }

            numMoney = numMoney - (numMoney % 1);
            holder = "" + numMoney;
            if(holder.substring(0, 1) == "-")
            {
                strFormat = "-" + strCurrencySymbol;
                strTemp = holder.substring(1, holder.length);
            }   //if
            else
            {
                strTemp = "" + numMoney;
            }

            var numThousands = Math.round(strTemp.length / 3 - 0.5);
            var remainder = Math.round(strTemp.length % 3);
            if(remainder > 0)
            {
                if(strTemp.substring(0, remainder) == "0" || numThousands == 0)
                {
                    strFormat = strFormat + strTemp.substring(0, remainder);
                }
                else
                {
                    strFormat = strFormat + strTemp.substring(0, remainder) + ",";
                }
            }   //if

            for(var i = 0; i < numThousands - 1; i++)
            {
                strFormat = strFormat + strTemp.substring(remainder + i * 3, remainder + i * 3 + 3) + ",";
            }   //for

            strFormat = strFormat + strTemp.substring(remainder + i * 3, remainder + i * 3 + 3);
            if(blnNoDecimals)
            {
                return(strFormat);
            }
            else
            {
                if(Decimals < 10)
                {
                    return(strFormat.concat(".0" + Decimals));
                }
                else
                {
                    return(strFormat.concat("." + Decimals));
                }
            }   //else
        }   //else
    }   //if
    else
    {
        if(blnNoDecimals)
        {
            return(strFormat.concat("0"));
        }
        else
        {
            return(strFormat.concat("0.00"));
        }
    }   //else
}

//un-format currency, mainly to allow easier input
function UnformatCurrency(strFormat)
{
    var strMoney = "";
    var i;
    if(strFormat == "£0.00" || strFormat == "£0" || strFormat == null)
    {
        return("");
    }

    for(i = 0; i < strFormat.length; i++)
    {
        switch(strFormat.charAt(i))
        {
            case '-':
            case '+':
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
            case '.':
                strMoney = strMoney.concat(strFormat.charAt(i));
                break;
        }
    }

    return(strMoney);
}

//if checkbox is displayed for euro amount then set curreny symbol
function chkEuro_OnClick(chk, objGen)
{
    if(chk.checked == true)
    {
        objGen.CurrencySymbol = "€";
    }
    else
    {
        objGen.CurrencySymbol = "£";
    }

    objGen.value = FormatCurrency(UnformatCurrency(objGen.value), objGen.CurrencySymbol);
}

//validate postcode input, suppresses partial or incorrect postcode entry
function formatPostcode(value)
{
    var intChar=0;
    var strMask="";
    var ch;
    var strPostcode;
    
    strPostcode = replaceCharString(value," ","");
    strPostcode = strPostcode.toUpperCase();
    for (intChar=0;intChar<strPostcode.length;intChar++)
    {
        ch = strPostcode.charAt(intChar);
        
        if (allowInString(ch, strAlpha))
		strMask = strMask + "A";
	else if (allowInString(ch, strNumbers))
		strMask = strMask + "N";
	else 
		strMask = strMask + "@";
    }
    
    switch (strMask)
    {
	    case "ANNA", "ANNAA":
		strPostcode = strPostcode.substring(0,2) + " " + strPostcode.substring(2,strPostcode.length);
		break;
	    case "ANNN", "ANNNA", "ANNNAA", "AANNA", "AANNAA", "ANANA", "ANANAA", "AANNAA":
		strPostcode = strPostcode.substring(0,3) + " " + strPostcode.substring(3,strPostcode.length);
		break;
	    case "AANNN", "AANNNA", "AANNNAA", "AANAN", "AANANA", "AANANAA", "AANNNAA":
		strPostcode = strPostcode.substring(0,4) + " " + strPostcode.substring(4,strPostcode.length);
		break;
	    default:
	    	strPostcode = "";
    }
    return (strPostcode);
}

//wrapper around formatPostcode, use for checking without overrighting input value when invalid
function checkPostcode(fld)
{
    if(fld.value.length > 0)
    {
        var formattedPostcode = formatPostcode(fld.value);
        if(formattedPostcode.length > 0)
        {
            fld.value = formattedPostcode;
            return(true);
        }
        else
        {
            alert("Invalid Postcode !");
            return(false);
        }
    }
    else
    {
        return(true);
    }
}

//upper case first letter of each word
function toTitleCase(strText)
{
    var strTitleCase;
    var i;
    strTitleCase = strText.substring(0, 1).toUpperCase();
    for(i = 1; i <= strText.length; i++)
    {
        if(strText.substring(i - 1, i) == " ")
        {
            strTitleCase = strTitleCase + strText.substring(i, i + 1).toUpperCase();
        }
        else
        {
            strTitleCase = strTitleCase + strText.substring(i, i + 1).toLowerCase();
        }
    }

    return(strTitleCase);
}


//ALL DATE FUNCTIONS FROM HERE ON

//returns the number of the day representing the first day (01) of the month (0..6)
function getFirstDayOfMonthStartSunday(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	dtDate.setDate(1);
	return (dtDate.getDay());
}

//returns the number of the day representing the first day (01) of the month (0..6) then offset
//so that the first day of the week is Monday and not as normal Sunday.
function getFirstDayOfMonth(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	dtDate.setDate(1);
	var intFirstDay = dtDate.getDay()-1;
	if (intFirstDay==-1)
		intFirstDay = 6;
	return (intFirstDay);
}

//returns amount of days in month
function getLastDayOfMonth(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	var intDays = arrDays[dtDate.getMonth()];
	if (intDays==28)
	{	
		if(LeapYear(dtDate.getFullYear()))
			intDays=29;
	}
	return (intDays);
}

//validates date input and returns a date object for use by calling function
function setupDate(strDateInput)
{
	var strDate;
	var dtDate=new Date();
	var intStartSlash=0;
	var intEndSlash=2;

	if (strDateInput=="")
		strDateInput=dtDate.getDate() + "/" + (dtDate.getMonth()+1) + "/" + dtDate.getFullYear();
	
	strDate=unformatDate(strDateInput);

	intEndSlash=strDate.indexOf("/");
	var strDays = strDate.substring(intStartSlash,intEndSlash);

	intStartSlash=intEndSlash+1;
	intEndSlash=strDate.indexOf("/", intStartSlash);
	var strMonths= strDate.substring(intStartSlash,intEndSlash);

	intStartSlash=intEndSlash+1;
	var strYears = strDate.substring(intStartSlash,strDate.length);

	dtDate.setYear(strYears);
	dtDate.setMonth(strMonths);
	dtDate.setMonth(dtDate.getMonth()-1);
	dtDate.setDate(strDays);

	return dtDate;
}

//sets the day of the month and updates input field
function setDay(objDateInput, strDay)
{
	var dtDate=setupDate(objDateInput.value);
	dtDate.setDate(strDay);
	objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
}

//set date input to todays date and format
function getDate(objDateInput)
{
	if (!isValidDate(objDateInput) || !objDateInput.value)
	{
		var dtDate=new Date();
		objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
	}
}

//get textual description of month
function getMonthDesc(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	return arrMonths[dtDate.getMonth()];
}

//set date to 1st of next month and get textual description of next month
function nextMonth(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	//set day to 01 to aviod date verification issues.
	dtDate.setDate(1);
	if (dtDate.getMonth() > 10)
	{
		dtDate.setMonth(0);
		dtDate.setYear(dtDate.getYear()+1);
	}
	else
		dtDate.setMonth(dtDate.getMonth()+1);
	objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
	return arrMonths[dtDate.getMonth()];
}

//set date to 1st of last month and get textual description of last month
function prevMonth(objDateInput)
{
	
	var dtDate=setupDate(objDateInput.value);
	//set day to 01 to aviod date verification issues.
	dtDate.setDate(1);
	if (dtDate.getMonth() < 1)
	{
		dtDate.setMonth(11);
		dtDate.setYear(dtDate.getYear()-1);
	}
	else
		dtDate.setMonth(dtDate.getMonth()-1);

	objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
	return arrMonths[dtDate.getMonth()];
}

//set date to 1st of next year and get 4-digit representation of next month
function nextYear(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	//set day to 01 to aviod leap year stuff
	dtDate.setDate(1);
	dtDate.setYear(dtDate.getFullYear()+1);
	objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
	return dtDate.getFullYear();

}

//set date to 1st of last year and get 4-digit representation of last month
function prevYear(objDateInput)
{
	var dtDate=setupDate(objDateInput.value);
	//set day to 01 to aviod leap year stuff
	dtDate.setDate(1);
	dtDate.setYear(dtDate.getYear()-1);
	objDateInput.value = formatDate(dtDate.getDate() + "/"+ (dtDate.getMonth()+1) + "/" + dtDate.getFullYear());
	return dtDate.getFullYear();
}

//check date and inform if incorrect
function checkDate(objDateInput)
{
	if (!isValidDate(objDateInput))
	{
		//alert("Date is invalid, use calendar control to rectify.");
		return false;
	}
	else
		return true;
}

//validate date and check for leap years and stuff, also format date output
function isValidDate(date_field) 
{

        var in_date;
        var date_is_bad;
        var date_pieces = new Array();
        var d = new Date();
        var theday;
        var themonth;
        var theyear;
        var datestring = "";

        date_is_bad = 0;

        if (!date_field.value)
		return true;		


	in_date = unformatDate(date_field.value);


        if (!allowInString(in_date,"/" + strNumbers))
        	date_is_bad = 1; // invalid characters in date

        if (!date_is_bad) 
	{
		date_pieces = in_date.split("/");
		if (date_pieces.length == 1)
		{
			if(in_date.length>5)
			{
				in_date=in_date.substring(0,2) + "/" + in_date.substring(2,4) + "/" + in_date.substring(4,in_date.length);
				date_pieces = in_date.split("/");		
			}
			else
			{
				date_is_bad = 2;
			}
		}
		if (date_pieces.length == 2) 
		{
			//add year if not supplied
			in_date = in_date + "/" + get_full_year(d);
			date_pieces = in_date.split("/");
		}
		if (date_pieces.length != 3 || parseInt(date_pieces[0],10) < 1 || parseInt(date_pieces[0],10) > 31
			|| parseInt(date_pieces[1],10) < 1 || parseInt(date_pieces[1],10) > 12
			|| (date_pieces[2].length != 2 && date_pieces[2].length != 4)) 
		{
            		date_is_bad = 2; // date is not in format of d[d]/m[m]/yy[yy]
		}
	}

	if (!date_is_bad) 
	{
		theyear = parseInt(date_pieces[2],10);
		themonth = parseInt(date_pieces[1],10);
		theday = parseInt(date_pieces[0],10);

		if (date_pieces[2].length == 2) 
		{
			if ( theyear < 30) 
			{
				theyear = theyear + 2000;
			}
			else 
			{
				theyear = theyear + 1900;
			}
			date_pieces[2] = theyear;
		}
	}

	if (!date_is_bad)
	{
		if (theyear < 1901 || theyear > 9999) 
		{
			date_is_bad = 3;	// invalid date - year out of range
		}
	}

	if (!date_is_bad) 
	{
		if ((themonth == 4 || themonth == 6 || themonth == 9 || themonth == 11) && (theday > 30 ))
			date_is_bad = 3;	// invalid date - day too large for month
	}
	if (!date_is_bad) 
	{
		if (themonth == 2) 
		{
			if (LeapYear(theyear) == true) 
			{
				if (theday > 29) 
				{
					date_is_bad = 3;	// invalid date - day too large for month
				}
			}
			else
			{
				if (theday > 28) 
				{
					date_is_bad = 3;	//invalid date - day too large for month
				}
			}
		}
	}

	if (!date_is_bad) 
	{
		theday = theday.toString();
		if (theday.length == 1)
			theday = "0" + theday;
		themonth = themonth.toString();
		if (themonth.length == 1)
			themonth = "0" + themonth;
		theyear = theyear.toString();
		datestring = theday + "/" + themonth + "/" + theyear;
		date_field.value = formatDate(datestring);
		return true;
	}
	else
	{
       		return false;
       	}
}

//get 4-digit representation of year
function get_full_year(d) 
{
	var y = ""
	if (d.getFullYear() != null)
	{
		y = d.getFullYear();
		if (y < 1970) 
			y+= 100;
	}
	else
	{
		y = d.getYear();
		if (y > 69  && y < 100)
			y += 1900;
		if (y < 1000)
			y += 2000;
	}
        return y;
}

//remove chracters or substrings from a string
function stripCharString (InString, CharString)  
{
	var outstring="";
        var count1;
      	var count2;
      	var tempchar;
	var strip;
   	var stripitem;

	for (count1=0; count1 < InString.length; count1++)  
	{
	      	tempchar=InString.substring (count1, count1+1);
      		strip = false;
      		for (count2 = 0; count2 < CharString.length; count2++) 
		{
        		stripitem = CharString.substring(count2, count2+1)
         		if (tempchar == stripitem) 
			{
		                strip = true;
	        		break;
         		}
      		}	
		if (!strip)
		outstring=outstring+tempchar;
	}
        return (outstring);
}

//replace a substring within a string with another string, got it!
function replaceCharString (InString, findString, replaceString)  
{
	var outstring="";
        var count1;
      	var count2;
      	var tempchar;
	var replace;
   	var replaceItem;

	for (count1=0; count1 < InString.length; count1++)  
	{
	      	tempchar=InString.substring (count1, count1+1);
      		replace = false;
      		for (count2 = 0; count2 < findString.length; count2++) 
		{
        		replaceItem = findString.substring(count2, count2+1)
         		if (tempchar == replaceItem) 
			{
		                replace = true;
	        		break;
         		}
      		}	
		if (!replace)
			outstring=outstring+tempchar;
		else
			outstring=outstring+replaceString;
	}
        return (outstring);
}

//return whether the given string(InString) is contained within the reference string (RefString)
function allowInString (InString, RefString)  
{
	var count;
	var tempchar;

        if(InString.length==0) return (false);

        for (count=0; count < InString.length; count++)  
	{
        	tempchar= InString.substring (count, count+1);
      		if (RefString.indexOf (tempchar, 0)==-1)
      			return (false);
   	}
	return (true);
}

//return true if the year supplied is a leap year
function LeapYear(theyear) 
{
	var blnLeap=false;
	if (theyear % 100 == 0) 
	{
		if (theyear % 400 == 0) 
			blnLeap=true;
	}
	else
	{
		if ((theyear % 4) == 0)
			blnLeap=true;
	}
	return blnLeap;
}

//take away output formatting, done before calculations in order that date is always of a given format
//before changing.
function unformatDate(strDate)
{
	if (strDate!=""  && strDate!=null)
	{
		strDate=strDate.toUpperCase();
		for (var i=0; i < arrShortMonths.length; i++)
		{
			var intMonthPos=strDate.indexOf(arrShortMonths[i].toUpperCase());
			if (intMonthPos!=-1)
				strDate = strDate.substring(0, intMonthPos) + arrNumericMonths[i] + strDate.substring(intMonthPos+3, strDate.length);
		}
	        strDate= replaceCharString(strDate," ", "/");	
	        strDate= replaceCharString(strDate,"-", "/");	
	        strDate= replaceCharString(strDate,".", "/");
	}
	return strDate;
}

//format date for output
function formatDate(strDate)
{
	
	var dtDate = setupDate(strDate);
	var strRet = strDateDisplayMask;

	var intDay=dtDate.getDate();
	var strDay="";
	
	if (intDay<10)
		strDay="0" + intDay;
	else
		strDay="" + intDay;

	var pos=strRet.indexOf("dd");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + strDay + strRet.substring(pos+2, strRet.length)
	}

	pos=strRet.indexOf("mmm");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + arrShortMonths[dtDate.getMonth()] + strRet.substring(pos+3, strRet.length)
	}

	pos=strRet.indexOf("mm");
	if (pos!=-1)
	{
		var strMonth = dtDate.getMonth()+1;
		if (strMonth<10)
			strMonth="0" + strMonth;
		
		strRet=strRet.substring(0,pos) + strMonth + strRet.substring(pos+2, strRet.length)
	}

	pos=strRet.indexOf("yyyy");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + dtDate.getFullYear() + strRet.substring(pos+4, strRet.length)
	}

	pos=strRet.indexOf("yy");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + dtDate.getFullYear() + strRet.substring(pos+2, strRet.length)
	}
	

	return strRet;
}

function adhocFormatDate(strDate, strDisplayMask)
{
	
	var dtDate = setupDate(strDate);
	var strRet = strDisplayMask;

	var intDay=dtDate.getDate();
	var strDay="";
	
	if (intDay<10)
		strDay="0" + intDay;
	else
		strDay="" + intDay;

	var pos=strRet.indexOf("dd");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + strDay + strRet.substring(pos+2, strRet.length)
	}

	pos=strRet.indexOf("mmm");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + arrShortMonths[dtDate.getMonth()] + strRet.substring(pos+3, strRet.length)
	}

	pos=strRet.indexOf("mm");
	if (pos!=-1)
	{
		var strMonth = dtDate.getMonth()+1;
		if (strMonth<10)
			strMonth="0" + strMonth;
		
		strRet=strRet.substring(0,pos) + strMonth + strRet.substring(pos+2, strRet.length)
	}

	pos=strRet.indexOf("yyyy");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + dtDate.getFullYear() + strRet.substring(pos+4, strRet.length)
	}

	pos=strRet.indexOf("yy");
	if (pos!=-1)
	{
		strRet=strRet.substring(0,pos) + dtDate.getFullYear() + strRet.substring(pos+2, strRet.length)
	}
	

	return strRet;
}

//format date for output
function xxx(strDate)
{
	var dtDate = setupDate(strDate);
	var strRet = "";
	var intDay=dtDate.getDate();
	if (intDay<10)
		strRet="0" + intDay;
	else
		strRet="" + intDay;
	strRet += " " + arrShortMonths[dtDate.getMonth()] + " " + dtDate.getFullYear();
	return strRet;
}
