function getFormatedDate(local, theDate) {

	var sDateFormat	= "";



	var sTheMonth	= theDate.getMonth() + 1;

	sTheMonth		= ((sTheMonth) <= 9) ? "0" + sTheMonth : sTheMonth;



	var sTheDay		= theDate.getDate();

	sTheDay			= (sTheDay <= 9) ? "0" + sTheDay : sTheDay;

	var nTheYear	= theDate.getFullYear();





	if (local == "ja" || local == "zh") {

		// FORMAT: YYYY/MM/DD

		//sDateFormat = nTheYear + "/" + sTheMonth + "/" + sTheDay;
		sDateFormat = String(nTheYear).substr(2,2) + "\u5E74" + sTheMonth  + "\u6708" + sTheDay  + "\u65E5";

	} else if ((local == "es") || (local == "fr") || (local == "it")) {

		// FORMAT: DD/MM/YYYY

		sDateFormat = nTheYear  + "-" + sTheMonth + "-" + sTheDay;

	} else if (local == "de") {
        sDateFormat = nTheYear  + "-" + sTheMonth + "-" + sTheDay;   
    } else {
		// FORMAT: MM/DD/YYYY

		sDateFormat = nTheYear  + "-" + sTheMonth + "-" + sTheDay;

	}

	return sDateFormat;

}



function setDateFromString(local, theDate) {

	var theDateObject   = null;

	var theDateArray    = theDate.split("/");



	if (local == "ja" || local=="zh") {

		// FORMAT: YYYY/MM/DD
        theDateArray    = theDate.split(" ");
		//theDateObject = new Date(theDateArray[0].substr(0,4), theDateArray[1].substr(0,2)-1, theDateArray[2].substr(0,2));
		theDateObject = new Date("20"+theDate.substr(0,2), theDate.substr(3,2)-1, theDate.substr(6,2));

	} else if ((local == "es") || (local == "fr") || (local == "it")) {

		// FORMAT: DD/MM/YYYY

		theDateObject = new Date(theDateArray[2], theDateArray[1]-1, theDateArray[0]);

	} else if (local == "de") {
        theDateArray    = theDate.split(".");
        theDateObject = new Date(theDateArray[2], theDateArray[1]-1, theDateArray[0]);
    } else {

		// FORMAT: MM/DD/YYYY

		theDateObject = new Date(theDateArray[2], theDateArray[0]-1, theDateArray[1]);

	}



	//alert("theDateObject: " + theDateObject);

	if ((theDateObject == "Invalid Date") || (isNaN(theDateObject))) {

		theDateObject = null;

	}

	return theDateObject;

}



/*

This function is necessary because as of now the multiDisplayCalendar.js needs an empty form to process the curent dates

*/

function fnClearFormField(pDate) {

	if ((pDate == "MM/DD/YYYY") || (pDate == "DD/MM/AAAA") || (pDate == "JJ/MM/AAAA") ||(pDate == "GG/MM/AAAA")
        || (pDate == "TT.MM.JJJJ") || (pDate="YY\u5E74MM\u6708DD\u65E5")) {
        pDate = "";
	}
	return pDate;
}