//Creado con Ardora - www.webardora.net
//bajo licencia Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//para otros usos contacte con el autor
var isFull=false;var zIndex = 0;var dataJob;var dirJob="../ardoraWorkFiles/pratosTipico/img/original/";
$(document).ready(function() {$(".fg-button:not(.ui-state-disabled)").hover(function(){$(this).addClass("ui-state-hover");},function(){$(this).removeClass("ui-state-hover");})
.mousedown(function(){$(this).parents(".fg-buttonset-single:first").find(".fg-button.ui-state-active").removeClass("ui-state-active");if( $(this).is(".ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active") ){ $(this).removeClass("ui-state-active"); }
else { $(this).addClass("ui-state-active"); }}).mouseup(function(){if(! $(this).is(".fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button") ){$(this).removeClass("ui-state-active");}});
$("#modal").dialog({bgiframe: true,modal: true,autoOpen:false,buttons: {Ok: function() {$(this).dialog("close");}}});
if(location.hash.indexOf("#pic-")!=-1){$(location.hash+" a.fancybox").click();}
loadData();
 $("#ButFull").click(function (){if (isFull) {isFull=false;fullScreenCancel();}else{isFull=true;fullScreen()}})
});
function loadData() {$.ajax({type: "POST",dataType: "json",url: "ardoraPublic.php",data: {"action": "all"},
success: function(data) {var notes = "";var vLeft = 5;var vTop = 5;var rot=0;
if (data.length > 0) {dataJob=data;for (i = 0; i < data.length; i++) {
notes=notes+'<div id="pic-'+data[i]["i"]+'" class="pic" style="top:'+vTop.toString()+'px;left:'+vLeft.toString()+'px;background:url('+dirJob+data[i]["srcIma"]+') no-repeat 50% 50%; transform:rotate('+rot.toString()+'deg);">';
notes=notes+'<a id="P_'+i.toString()+'" onclick="javasrcipt:showJob('+data[i]["i"]+')" target="_blank" title="'+data[i]["com"]+'">link</a>';
notes=notes+'<span class="comment">'+data[i]["word"]+'</span>';
notes=notes+"</div>";
vLeft=vLeft+150+15;if (parseInt($(window).width())-20<vLeft+150+15){vLeft=5;vTop=vTop+150+35;}
}
$("#main").html(notes);var tmp;
$(".pic").each(function(){tmp = $(this).css("z-index");if(tmp>zIndex) zIndex = tmp;})
$(".pic").draggable({containment:"parent",start:function(e,ui){ ui.helper.css("z-index",++zIndex); },stop:function(e,ui){}})
$(".pic").hover(function() {$(this).children(".comment").stop().css("top", "0px");}, function() {$(this).children(".comment").stop().animate({"top": "400px"}, 600);});
/*$("#main").html(notes);var tmp;$(".note").each(function() {tmp = $(this).css("z-index");if (tmp > zIndex) zIndex = tmp;})*/
}}});}
function fullScreen() {
var docElement, request;docElement = document.getElementById("divFull");
request = docElement.requestFullScreen || docElement.webkitRequestFullScreen || docElement.mozRequestFullScreen || docElement.msRequestFullScreen;
if (typeof request != "undefined" && request) {request.call(docElement);}}
function fullScreenCancel() {
var docElement, request;docElement = document;
request = docElement.cancelFullScreen || docElement.webkitCancelFullScreen || docElement.mozCancelFullScreen || docElement.msCancelFullScreen || docElement.exitFullscreen;
if (typeof request != "undefined" && request) {request.call(docElement);}}
function showJob(num) {$("body").css("overflow", "hidden");$("#ardoraShowJob").css({"width": $(window).width(),"height": $(window).height()});
var txtComent=dataJob[num]["describe"].replace(/\\"/g,"");
 $("#ardoraShowJob").append("<div id='job'><div id='contenDiv'><div id='titleContenDiv'>"+dataJob[num]["word"]+
"</div><div id='comentContenDiv'><img src='"+dirJob+dataJob[num]["srcIma"]+"'/>"+txtComent+"<div id='foot'>"+dataJob[num]["author"]+" - "+dataJob[num]["date"]+"</div></div></div><div id='headerDiv'><p>"+dataJob[num]["com"]+"</p></div></div>")
$("#contenDiv").css({"margin-top":($(window).height()-350)/2-50});
$("#job").draggable();document.getElementById("ardoraShowJob").style.zIndex = 5000;document.getElementById("ardoraShowJob").style["visibility"] = "visible";$("#ardoraShowJob").css("cursor", "pointer");
$("#ardoraShowJob").click(function(e) {if (!$(e.target).is("#comentContenDiv")){$("#ardoraShowJob").html("");
document.getElementById("ardoraShowJob").style.zIndex=0;document.getElementById("ardoraShowJob").style["visibility"]="hidden";$("#ardoraShowJob").css({"width": 2,"height": 2});}});
}
