function changePressDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["newsDate"];
	sDate = xmlDate.substring(8,10);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sYear = xmlDate.substring(0,4);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate"] = readableDate;
	}
}

function changeListingDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["listing_date"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate"] = readableDate;
	}
}
function changeDelistingDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["delisting_date"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate"] = readableDate;
	}
}
function changePublicationDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["publication_date"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	sTime = xmlDate.substring(11,19);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear+" - "+sTime;
	row["strippedDate"] = readableDate;
	}
}
function changeLastUpdateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["time_of_last_update"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	sTime = xmlDate.substring(11,19);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear+" - "+sTime;
	row["strippedDate"] = readableDate;
	}
}
function changeLastUpdateDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["time_of_last_update"];
	if (xmlDate == null) return;
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	sTime = xmlDate.substring(11,19);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate"] = readableDate;
	}
}

function changeAcademyDateFrom(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["Academy_Course_CourseDateFrom"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate_From"] = readableDate;
	}
}
function changeAcademyDateTo(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["Academy_Course_CourseDateTo"];
	sYear = xmlDate.substring(0,4);
	sMonth=xmlDate.substring(5,7);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(8,10);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate_To"] = readableDate;
	}
}
function changeNoticesDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["noticeDate"];
	sYear = xmlDate.substring(6,10);
	sMonth=xmlDate.substring(0,2);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(3,5);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["strippedDate"] = readableDate;
	}
}

function changeDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
	// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
	function stripZeroInMonth(originalMonth)
		{
			if(originalMonth.substring(0,1)==0)
			{
				return(originalMonth.substring(1,2));
			}
			return (originalMonth);	
	}

	var row = rows[ i ];
	var xmlDate = row["publishDate"];
	sYear = xmlDate.substring(6,10);
	sMonth=xmlDate.substring(0,2);
	sStrippedMonth = stripZeroInMonth(sMonth);
	sDate = xmlDate.substring(3,5);
	var readableMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	readableDate = sDate+" "+readableMonth[sStrippedMonth -1]+" "+sYear;
	row["formattedDate"] = readableDate;
	}
}

// AJAX Form submission
// Callback function that will update the response_form1 div with the response that comes from the server
function updateResponseDiv(req) 
{
	Spry.Utils.setInnerHTML('response_form1', req.xhRequest.responseText);
}


//print page function
function printpage() {
window.print();  
}
 
/*function fileLinks() {
    var fileLink;
    if (document.getElementsByTagName('a')) {
        for (var i = 0; (fileLink = document.getElementsByTagName('a')[i]); i++) {
            if (fileLink.href.indexOf('.pdf') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pdfLink';
            }
            if (fileLink.href.indexOf('.doc') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'docLink';
            }
            if (fileLink.href.indexOf('.zip') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'zipLink';
            }
        }
    }
}
window.onload = function() {
    fileLinks();
}
*/
function changeAcademyDateStart(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
		// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
		var row = rows[ i ];
		var xmlDate = row["start_date"];
		var t1 = (Date.parse(xmlDate)).toString('MMMM dS, yyyy');
		var readableDate = t1.toString('MMMM dS, yyyy');
		row["f_start_date"] = readableDate;
	}
}

function changeAcademyDateEnd(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
		// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
		var row = rows[ i ];
		var xmlDate = row["end_date"];
		var t1 = (Date.parse(xmlDate)).toString('MMMM dS, yyyy');
		var readableDate = t1.toString('MMMM dS, yyyy');
		row["f_end_date"] = readableDate;
	}
}

function displayCourseRegistration(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.

	for (var i = 0; i < numRows; i++)
	{
		// Check the length of the entity decoded version of the desc column, because we don't want to factor in the length of entity encodedcharacter names in our length check.
		var row = rows[ i ];
		//var regDate = row["registration_date"];
		//var regEndDate = row["registration_end_date"];
		var past = new Date.parse(row["registration_date"]).add(-1).days();
		var future = new Date.parse(row["registration_end_date"]);
		row["regStatus"] = Date.today().between(past, future);

	}
}

function addCommas(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.
	var commaValues = notifier.formatValues;
	
	for (var i = 0; i < numRows; i++)
	{
		var row = rows[ i ];
		
		for (var j = 0; j < commaValues.length; j++)
		{
			var nStr = row[commaValues[j]];
			if (nStr == undefined)
			{
				continue;
			}
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			var formattedNum =  x1; //+ x2
			row[commaValues[j]] = formattedNum;
			}
	}
}

function addCommasCurrency(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.
	var currencyValues = notifier.formatCurrency;
	
	for (var i = 0; i < numRows; i++)
	{
		var row = rows[ i ];
		
		for (var j = 0; j < currencyValues.length; j++)
		{
			var nStr = row[currencyValues[j]];
			if (nStr == undefined)
			{
				continue;
			}
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			var formattedNum =  x1 + x2;
			row[currencyValues[j]] = formattedNum;
			}
	}
}

function changeXMLDateFormat(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length; 

	// Now loop over every row generate a teaser column.
	var dateValues = notifier.formatDate;
	for (var i = 0; i < numRows; i++)
	{
		var row = rows[ i ];
		
		for (var j = 0; j < dateValues.length; j++)
		{
			var xmlDate = row[dateValues[j]];
			var t1 = (Date.parse(xmlDate)).toString('MMMM dS, yyyy');
			row[dateValues[j]] = t1;
		}
	}

}

function changeXMLDateFormatWithTime(notificationType, notifier, data)
{
	if (notificationType != "onPostLoad")
	return;

	// Get the unfiltered set of rows from the data set.

	var rows = notifier.getData(true);
	var numRows = rows.length;

	// Now loop over every row generate a teaser column.
	var dateValues = notifier.formatDate;
	for (var i = 0; i < numRows; i++)
	{
		var row = rows[ i ];
		
		for (var j = 0; j < dateValues.length; j++)
		{
			var xmlDate = row[dateValues[j]];
			var t1 = (Date.parse(xmlDate)).toString('MMMM dS, yyyy - hh:mm tt');
			row[dateValues[j]] = t1;
		}
	}

}

//random value to get rid of xml cache
// make a random value to append with the dataset inorder not to cache the xml
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var randomC = month + "_" +  day  + "_" + year + "_" + hours + "_" + minutes + "_" + seconds;
