﻿/* SCREEN SIZE */
function screen_left(width) {
	return (screen.width / 2) - (width / 2);
}

function screen_top(height) {
	return (screen.height / 2) - (height / 2);
}

/* EXTERNAL LINKS */
function externalLinks() {
  if (!document.getElementsByTagName) { return; }
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i ++) {
	  var anchor = anchors[i];
	  if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.target = "_blank"; }
	}
}


/* NEW LINE TO BR */
function nl2br(text) {
	text = escape(text);
	if(text.indexOf('%0D%0A') > -1) {
		re_nlchar = /%0D%0A/g ;
	}
	else if(text.indexOf('%0A') > -1) {
		re_nlchar = /%0A/g;
	}
	else if(text.indexOf('%0D') > -1) {
		re_nlchar = /%0D/g;
	}
	return unescape(text.replace(re_nlchar,'<br />'));
}

/* DIALOGS */
function dialog(url,width,height) {
	if (!width) { width = 600; }
	if (!height) { height = 400; }
  window.open(''+url+'','_blank','location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,width='+width+',height='+height+',left='+screen_left(width)+',top='+screen_top(height)+'');
}

