/*
 * (c) 2009 Martin Edlman
 *
 * vyzaduje jQuery
 *
 * otevre okno s napovedou
 */

var popupWin = {
	'help' : null,
	'characteristics' : null,
	'picture': null
};

$(document).ready(function() {
	$('a[rel="help"]').popupWin({position: 'event', xposition: 'center', yposition: 'bottom', yoffset: 0});
	/*
	$('a[rel="help"]').click(function(event) {
		openPopup(event, this, 'help', 600, 500, 'right', 'event', 'yes');
		event.preventDefault();
	});
	$('a[rel="glossary"]').click(function(event) {
		openPopup(event, this, 'characteristics', 600, 500, 'right', 'event', 'yes');
		event.preventDefault();
	});
	// okno s obrazkem a prepinacem nahledu
	$('a.picturepopupext').click(function(event) {
		openPopup(event, this, 'picture', 770, 680, 'center', 'center', 'no');
		event.preventDefault();
	});
	// okno s obrazkem bez prepinace nahledu
	$('a.picturepopup').click(function(event) {
		openPopup(event, this, 'picture', 622, 680, 'center', 'center', 'no');
		event.preventDefault();
	});
	*/
});

function openPopup(e, a, type, width, height, xpos, ypos, scrollbars) {
	var link = $(a).attr('href');
	if(popupWin[type] != null && ! popupWin[type].closed) {
		popupWin[type].close();
	}
	//alert(type + ': ' + link)
	var left;
	var top;
	switch(xpos) {
		case 'center':
			left = (screen.width - width) / 2;
			break;
		case 'right':
			left = screen.width - width;
			break;
		case 'event':
			left = Math.min(screen.width - width, e.screenX);
			break;
		default:
			left = 0;
			break;
	}
	switch(ypos) {
		case 'center':
			top = (screen.height - height) / 2;
			break;
		case 'bottom':
			top = screen.height - height;
			break;
		case 'event':
			top = Math.min(screen.height - height, e.screenY);
			break;
		default:
			top = 0;
			break;
	}
	popupWin[type] = window.open('' + link, '' + type, 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',scrollbars=' + scrollbars);
}

