
// ----- WARNING ----- \\
// COPYRIGHTED CONTENT \\
//  COPYRIGHT © NERVA  \\
//   nerva@nerva.ee    \\
// All rights reserved \\
// ------------------- \\

function loadPhoto(photoid) {
	var mb = mb_findByContentid("v3photos_" + photoid);
	if (mb !== false) {
		unhide(mb, true);
		return true;
	  }
	last_mbindex++;
	var mbindex = last_mbindex;
	unhideByName("loadingphoto_" + photoid);
	loadcontent(root + "content/direct.php?&call=content/photo/photo|loadphoto&langid=" + langid + "&photoid=" + photoid + "&mbindex=" + mbindex, callbackLoadPhoto);
  }

function callbackLoadPhoto(content) {
	var i = content.indexOf(":");
	var j = content.indexOf("=");
	if ((i > 0) && (j > i)) {
		var photoid = content.substr(0, i);
		var src = content.substr(i + 1, j - i - 1);
		addhtml(content.substr(j + 1));
		var o = document.getElementById("v3photos_" + photoid);
		if (o != null) {
			loadimage(o, src, "callbackLoadPhotoComplete(" + photoid + ")");
		  }
		else {
			hideByName("loadingphoto_" + photoid);
		  }
	  }
  }

function callbackLoadPhotoComplete(photoid) {
	hideByName("loadingphoto_" + photoid);
	show_new_overlays();
  }

function showgallery(path, title) {
	loadcontent(root + "content/direct.php?&call=independent/galleryshow/galleryshow|getgalleryshow&path=" + escape(path) + ((title != null) ? "&title=" + encodeURIComponent(title) : "") + ((galleryshow1 != null) ? "&listonly=1" : ""), galleryshow_callback);
  }

function uploadphoto(name) {
	edit_content("v3photos_0_child", "&init_title_" + langid + "=" + name);
//	alert("Upload " + name);
  }

function galleryshow_callback(content) {
  if (content == "") return false;
	if (content.substr(0, 6) == 'ERROR:') {
		alert(content);
		return false;
	  }
  var i = content.indexOf("<script");
	var script = "";
	if (i >= 0) {
		var j = content.indexOf("</script>", i);
		if (j > i) {
			var k = content.indexOf(">", i) + 1;
			script = content.substr(k, j - k);
			content = ((i > 0) ? content.substr(0, i) : "") + content.substr(j + 9);
		  }
	  }
	addhtml(content);
	if (script != "") eval(script);
	galleryshow1.expand();
  }
