/* IDENTIFY START */
var identifier = 0;

/* DOM READY */
$(function() {
	/* initialize tb language */
	if(!!tbLanguage) tb_language(tbLanguage);
	if(!!tbWindowWidth) tb_windowWidth(tbWindowWidth);
	
	/* external links */
	$('a[rel="external"]').attr('target', '_blank');
	
	/* popup links */
	$('a[rel="popup"]').click(function() {
		var name = $(this).attr('id');
		if(!name) {
			name = 'identifier_' + ++identifier;
			$(this).attr('id', name);
		}
		var width   = height = 650,
		    top     = left   = 0,
		    percent = 80;
		if(!!screen.width) {
			width = Math.ceil((screen.width / 100) * percent);
			left  = Math.ceil((screen.width - width) / 2);
		}
		if(!!screen.height) {
			height = Math.ceil((screen.height / 100) * percent); 
			top    = Math.ceil((screen.height - height) / 2);
		}
		window.open($(this).attr('href'), name, 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes');
		return false;
	});
	
	/* download links */
	$('a[rel="download"]').click(function() {
		var file = $(this).attr('href'),
		    ext  = file.split('.').pop().toLowerCase();
		if($.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) > -1) {
			window.open(file);
			return false;
		}
	});
});