﻿// common.js

// open links with the attribute rel="external" in a new window
$(document).ready(function() {
	$('a[rel~=external]').click(function() {
		relation = $(this).attr('rel');
		
		if($(this).attr('href')) {
			options = 'scrollbars=yes,menubar=yes,status=no,location=no,';
			
			if(relation.match(/\[([0-9]{2,4})\,([0-9]{2,4})\]/)) {
				size = relation.split('[');
				size = size[1].replace(/\]/, '');
				size = size.split(',');
				
				options += 'width=' + size[0] + ', height=' + size[1] + ',left=200,top=200';
				
				window.open($(this).attr('href'), '', options);
				return false;
			}
			
			window.open($(this).attr('href'));
			return false;
		}
	});
});