var msgWin = window.msgWin;
/* popup pro obrazky a galerie */
function popup(alink, type) {
	var retValue = false;
	switch(type) {
		case 1: // img_from_link
			prefix = "/ppu/popup_image.php?path=";
			path = prefix + alink.href.substr(alink.href.indexOf("/img/")) + "&title=" + alink.getAttribute("TITLE");
			break;
		case 2: // gal_from_link
			prefix = "/ppu/popup_gallery.php?js=true&adr=";
			ppth = alink.href.substr(alink.href.indexOf("adr=") + 4)
			path = prefix + ppth;
			break;
	}
	
	if (msgWin != null && !msgWin.closed) { 
		msgWin.location.href = path;
		msgWin.focus();
	} else {
		msgWin = window.open(path, "_gallery","height=150,menubar=0,personalbar=0,resizable=1,scrollbars=0,toolbar=0,width=150,top=100,left=100,status=0");
		if (msgWin == null || typeof(msgWin) == "undefined") {
			retValue = true; 
			}
		else { 
			alink.target = "_gallery";
			msgWin.focus(); 
		} 
	} 
	return retValue; 
}

$(document).ready(function(){
	
	lightboxes();

});

this.lightboxes = function() {
	
	// lb musi byt <a rel="lightbox-galerie"..
	
	str = '';
	$('a[rel^=lightbox]').each(function(){
		uq = $(this).attr("rel").substr(9);
		if(str.indexOf("<" + uq + ">") == -1) {
			str += "<" + uq + ">";
		}
	});
	gals = str.substr(1, str.length-2).split("><");
	for(i = 0; i < gals.length; i++) {
		$("a[rel=lightbox-" + gals[i] + "]").lightBox({
			containerResizeSpeed: 400,
			txtImage: "Obrázek / Image :",
			txtOf: "/",
			imageLoading: "/ppu/img/lb-loading.gif",
			imageBtnClose: "/ppu/img/lb-btn-close.gif",
			imageBtnPrev: "/ppu/img/lb-btn-prev.gif",
			imageBtnNext: "/ppu/img/lb-btn-next.gif"
		});
	}

}
