function centerdiv(elem)
{
	sizes = window.getSize();
	scrollito = window.getScroll();
	$(elem).setStyles({
		'position': 'absolute',
		'display': 'block',
		'left': (scrollito.x + (sizes.x - $(elem).getSize().x) / 2).toInt(),
		'top': (scrollito.y + (sizes.y - $(elem).getSize().y) / 2).toInt()
	});
}

function uploadFile(elem)
{
	sizes = window.getSize();
	scrollito = window.getScroll();
	$(elem).setStyles({
		'position': 'absolute',
		'width': '500px',
		'height': '170px',
		'display': 'block',
		'left': (scrollito.x + (sizes.x - 500) / 2).toInt(),
		'top': (scrollito.y + (sizes.y - 200) / 2).toInt()
	});
}

function openURLBlank(href)
{
	window.open(href);
}

function openPicture(el)
{
	Slimbox.open($(el).value, "")
}

function DisplayWizardMenuItems()
{
	sizes = window.getSize();
	scrollito = window.getScroll();
	$('WizardMenuItems').setStyles({
		'position': 'absolute',
		'width': '500px',
		'height': '140px',
		'display': 'block',
		'left': (scrollito.x + (sizes.x - 500) / 2).toInt(),
		'top': (scrollito.y + (sizes.y - 140) / 2).toInt()
	});
}

function UndisplayWizardMenuItems()
{
	$('WizardMenuItems').setStyle('display', 'none');
}

function Mid(str, start, len)
{
// Make sure start and len are within proper bounds
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}

window.addEvent('domready', function(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = $$("a");	
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;
	};
	this.set = function(obj){
		obj.target = "_blank";
		obj.className = "external_link";
	};	
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};		
});
