﻿function boolParse(str) {
	if (!str || typeof str != 'string')
	{ return null; }

	if (!str||str.toLowerCase() == "false"||str=="0")
		return false;
		
	return true;
}
function trim(str) {
	if (!str || typeof str != 'string')
	{ return null; }

	return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}

function setAdContent(position, pagegroup, maxitems, updateElementId) {
	$.ajax({
		type: "GET",
		url: pls_appName + "Advertisement.aspx?position=" + position + "&pagegroup=" + pagegroup + "&maximumitemstodisplay=" + maxitems,
		contentType: "application/json; charset=utf-8",
		cache: false,
		success: function(msg) {
			if (msg == null || trim(msg) == "" || msg=="error") {
				$("#" + updateElementId).toggle(false);
			}
			else {
				$("#" + updateElementId).html(msg);
			}
		}
	/*	error: function (XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest+textStatus+errorThrown);
		}*/
	});
}
