﻿// open links with the attribute rel="external" in a new window
$(document).ready(function() {
	$('a[rel~=external]').add('a[target=_blank]').click(function() {
		relation = $(this).attr('rel');
		
		if($(this).attr('href').match(/http:\/\/.*youtube.com\/v\//i)) {
			$.facebox('<iframe height="385" width="640" src="' + $(this).attr('href') + '"></iframe>');
			return false;
		}
		
	
		//rmausz, fix for IE with external 
		if($(this).attr('href').match(/fileadmin.*/)) {
			
			//alert($(this).attr('href'));
			return true;
		}
	
	
		if($(this).attr('href')) {
			options = '';
			
			if(relation.match(/\[([0-9]{2,4})\,([0-9]{2,4})\]/)) {
				options += '';
				
				size = relation.split('[');
				size = size[1].replace(/\]/, '');
				size = size.split(',');
				
				options += 'width=' + size[0] + ', height=' + size[1] + ',left=200,top=200';
			}
			
			//alert($(this).attr('href'));
			window.open($(this).attr('href'), '', options);
			
			return false;
		}
	});
});
