function setFontSize(newSize) {
	if(e = document.getElementsByTagName("body")[0]) {
		e.style.fontSize=newSize;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popup(URL,width,height) {
	if (!width) {
		width = 500;
	}
	if (!height) {
		height = 500;
	}
	MM_openBrWindow(URL,'','scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+((screen.width-width) / 2)+',top='+((screen.height-height) / 2)+',width=' + width + ',height=' + height);
	return false;
}



//---------------------------------------------------------------------------
// JS Dialog - drop in logic
//---------------------------------------------------------------------------
function loadJSDialogContent($container, action, method, arrParams) {
	$container = $($container);
	if ($container.length != 1) return false;
	
	method = typeof(method) !== 'undefined' ? $.trim(method).toLowerCase() : 'get';
	arrParams = typeof(arrParams) !== 'undefined' ? arrParams : null;
	
	method = $.trim(method).toLowerCase();
	if (method == 'get') {
		$.get(action, arrParams, function(data) {
			initializeJSDialog($container, data);
		});
	} else {
		$.post(action, arrParams, function(data) {
			initializeJSDialog($container, data);
		});
	}
}

function initializeJSDialog($container, data) {
	$container = $($container);
	if ($container.length != 1) return false;
	
	//$('.js-dialog').dialog('destroy');
	hideAndRemoveJSDialogs();
	
	$container.html(data);
	
	$container.find('.jsd-link').click(function() {
		loadJSDialogContent($container, $(this).attr('href'));
		return false;
	});
	
	$container.find('form').submit(function() {
		loadJSDialogContent($container, $(this).attr('action'), $(this).attr('method'), $(this).serializeArray());
		return false;
	});
	
	$container.find('.js-dialog').dialog({
		width: 500,
		bgiframe: true,
		/*autoOpen: false,*/
		modal: true,
		close: function() {
			$('#js-dialog-container').empty();
		}
	});
}

function hideAndRemoveJSDialogs() {
	$('.js-dialog').dialog('destroy').remove();
}
