var ajaxcallInterval,PhotoSliderInterval,iIdPhotoSlideShow=0,iIdPictureBookSlideShow=0,cScopeValueSlideShow="",cScopeSlideShow="",iIdPictureBookToShow=0,iIdPhotoToShow=0,lPreviewBusy=false,iQtySlides=0,pauseSlide,startSlide;function hidepreview(){hidelayer()}function showpreview(a,c){if(a===null)return true;if(iIdPhotoToShow===0)return true;var b=$(a).offset();layer=$("#layer1");iTop=b.top-100;iLeft=b.left+30+$(a).width();if(iLeft>670)iLeft=b.left-300;if(iTop<$(window).scrollTop())iTop=$(window).scrollTop();if(iLeft<0)iLeft=20;layer.css({top:iTop,left:iLeft});layer.html(c);layer.show();return true}function callphotopreview(a,b,c){if(iIdPhotoToShow===0)return;if(lPreviewBusy===true)return;lPreviewBusy=true;var d=$(a).offset();layer=$("#layer1");layer.css({top:d.top+($(a).height()+10),left:d.left+$(a).width()/2});layer.html('<div class="loadingajax" >Loading preview...</div>');layer.show();$.ajax({type:"GET",url:cDomain+"/ajax/ajaxphotopreview.p",data:{idpicturebook:b,idphoto:c},dataType:"text",success:function(d){lPreviewBusy=false;if(b==iIdPictureBookToShow&&c==iIdPhotoToShow)showpreview(a,d);else layer.hide()},error:function(b){messagebox("Oeps "+b.statusText,"Status: "+b.statusText);lPreviewBusy=false;hidepreview(a)}})}function callpreview(c){var d=$(c).attr("id").substring(6),e=d.indexOf("_"),a="",b="";if(e>0){a=d.substring(0,e);b=d.substring(e+1)}else{hidepreview(c);return}iIdPhotoToShow=b;iIdPictureBookToShow=a;clearInterval(ajaxcallInterval);ajaxcallInterval=setTimeout(function(){callphotopreview(c,a,b)},600)}function callcommentpreview(a,b,c){if(iIdPhotoToShow===0)return;if(lPreviewBusy===true)return;lPreviewBusy=true;var d=$(a).offset();layer=$("#layer1");layer.css({top:d.top+($(a).height()+10),left:d.left+$(a).width()/2});layer.html('<div class="loadingajax" >Loading preview...</div>');layer.show();$.ajax({type:"GET",url:cDomain+"/ajax/ajaxmessagepreview.p",data:{idpicturebook:b,idphoto:c,scope:"picturephoto"},dataType:"text",success:function(d){lPreviewBusy=false;b==iIdPictureBookToShow&&c==iIdPhotoToShow&&showpreview(a,d)},error:function(b){messagebox("Oeps "+b.statusText,"Status: "+b.statusText);lPreviewBusy=false;hidepreview(a)}})}function showcomment(c){var d=$(c).attr("id").substring(8),e=d.indexOf("_"),a="",b="";if(e>0){a=d.substring(0,e);b=d.substring(e+1)}else{hidepreview(c);return}iIdPhotoToShow=b;iIdPictureBookToShow=a;clearInterval(ajaxcallInterval);callcommentpreview(c,a,b)}function doPhotoSlide(b){var a="";iQtySlides++;$("#screenshot").remove();$.ajax({type:"GET",url:cDomain+"/ajax/ajaxphotoslide.p",data:{action:b,idpicturebook:iIdPictureBookSlideShow,idphoto:iIdPhotoSlideShow,scope:cScopeSlideShow,scopevalue:cScopeValueSlideShow},dataType:"xml",success:function(b){$(b).find("result").each(function(){var d="title",c="#photoslideshowcontainer",b="slide",e=this,h=$(b,e).text();$(c).html(h);if(iQtySlides>300){showmessage(document.getElementById("photoslideshowcontainer"),"info","Slideshow paused",true);pauseSlide()}iIdPictureBookSlideShow=$(b,e).attr("idpicturebook");iIdPhotoSlideShow=$(b,e).attr("idphoto");a=$(b,e).attr(d);$(c).dialog("option",d,a);var f=$(e).find("message");if($(f).length>0){var g=$(f).text(),i=$(f).attr("type");a=$(f).attr(d);g!=""&&showmessage(document.getElementById(c),i,g,true)}})},error:function(a){messagebox("Oeps "+a.statusText,"Status: "+a.statusText)}})}function stopPhotoSlide(){clearInterval(PhotoSliderInterval)}startSlide=function(){var a="#photoslideshowcontainer";if(cLanguage=="en")$(a).dialog("option","buttons",{Close:function(){$(this).dialog("close")},Pause:function(){pauseSlide()}});else $(a).dialog("option","buttons",{Sluit:function(){$(this).dialog("close")},Pauze:function(){pauseSlide()}});iQtySlides=0;doPhotoSlide("current");PhotoSliderInterval=setInterval("doPhotoSlide('next');",4e3)};pauseSlide=function(){var a="#photoslideshowcontainer";if(cLanguage=="en")$(a).dialog("option","buttons",{Close:function(){$(this).dialog("close")},Start:function(){startSlide()}});else $(a).dialog("option","buttons",{Sluit:function(){$(this).dialog("close")},Start:function(){startSlide()}});stopPhotoSlide()};function slideshow(g,f,c,e,d){var b="option",a="#photoslideshowcontainer";$(a).dialog(b,"position","center");$(a).dialog(b,"height",450);$(a).dialog(b,"width",550);$(a).dialog(b,"title","Slideshow");$(a).dialog("open");iIdPhotoSlideShow=e;iIdPictureBookSlideShow=c;cScopeValueSlideShow=d;cScopeSlideShow=f;hidepreview();startSlide();return false}function doArtistSearch(h){var b="",d="",c="",f=$("#djsearchartistname").val(),e=$("#idpicturebook").val(),g=$("#idphoto").val(),a;$.ajax({type:"GET",url:cDomain+"/ajax/ajaxphotodjsearch.p",data:{IdPictureBook:e,idphoto:g,search:f},dataType:"xml",success:function(e){$(e).find("result").each(function(){var f="option",e="#dialogcontainer";a=$(this).find("message");if($(a).length>0){b=$(a).text();d=$(a).attr("type");c=$(a).attr("title");if(d=="alert"){$(e).dialog(f,"position","center");$(e).dialog(f,"width",700);if(c=="")c=cLanguage=="en"?"Competitions":"Winacties";$(e).dialog(f,"title",c);$(e).html(b);$(e).dialog(f,"buttons",{Ok:function(){$(this).dialog("close")}});$(e).dialog("open")}else b!=""&&showmessage(h,d,b,true)}chtmlDJsearch=$("htmldjsearch",this).text();$("#containerphotodjsearch").html(chtmlDJsearch)})},error:function(a){messagebox("Oeps "+a.statusText,"Status: "+a.statusText)}});return false}function callphotoconnect(j,k,m,h,a,g,l){var c="memberpic",d="",f="",e="",i,b;if(g==c&&a!=""){i=$("."+a);i.attr({src:cStaticPathSite+"/image/formulier/loading.gif"})}$.ajax({type:"GET",url:cDomain+"/ajax/ajaxphotoconnection.p",data:{IdPictureBook:k,idphoto:m,action:h,typeconnection:g,idconnect:l},dataType:"xml",success:function(k){$(k).find("result").each(function(){var l="option",k="#dialogcontainer";b=$(this).find("message");if($(b).length>0){d=$(b).text();f=$(b).attr("type");e=$(b).attr("title");if(f=="alert"){$(k).dialog(l,"position","center");$(k).dialog(l,"width",700);if(e=="")e=cLanguage=="en"?"Competitions":"Winacties";$(k).dialog(l,"title",e);$(k).html(d);$(k).dialog(l,"buttons",{Ok:function(){$(this).dialog("close")}});$(k).dialog("open")}else d!=""&&showmessage(j,f,d,true)}switch(g){case "member":cPhotoWho=$("htmlphotowho",this).text();$("#containerphotowho").html(cPhotoWho);break;case "dj":cPhotoWho=$("htmlphotowhodj",this).text();$("#containerphotowhodj").html(cPhotoWho);break;case "personalphotobook":if(h=="delete"&&f!="error")!goprevpage(j)&&window.location.reload(true);break;case c:a!=""&&i.attr({src:cStaticPathSite+"/image/icons/silk/page_white_camera.png"})}$(j).is("input")&&a!=""&&$("."+a).attr("checked",h=="add")})},error:function(a){messagebox("Oeps "+a.statusText,"Status: "+a.statusText)}})}function djconnect(g){var a=0,c=0,e=0,h=0,f=0,d;d=$(g);var i=d.attr("checked")?"add":"remove",b=d.attr("class");a=b.indexOf("gal")+3;c=b.indexOf("_",a);e=b.substr(a,c-a);a=c+1;c=b.indexOf("_",a);f=b.substr(a,c-a);a=a=b.indexOf("_dj")+3;h=b.substr(a);callphotoconnect(g,e,f,i,b,"dj",h)}$(document).ready(function(){var b=":checkbox",c="mouseleave",d="mouseenter",a=true;$("#photoslideshowcontainer").dialog({autoOpen:false,modal:a,closeOnEscape:a,resizable:a,draggable:a,zIndex:8,overlay:{opacity:.5,background:"black"},close:function(){startTimers();stopPhotoSlide()},open:function(){stopTimers()}});$(".thumb").bind(d,function(){callpreview(this)}).mouseleave(function(){hidepreview(this)});$(".showcomment").bind(d,function(){showcomment(this)}).mouseleave(function(){hidepreview(this)}).attr("title",cLanguage=="en"?"Show last comment":"Toon laatste bericht");$("#gallery_thumbs").bind(c,function(){iIdPictureBookToShow=0;iIdPhotoToShow=0;hidepreview(this)});$("#gallery_photo").bind(c,function(){iIdPictureBookToShow=0;iIdPhotoToShow=0;hidepreview(this)});$("#thumbs").bind(c,function(){iIdPictureBookToShow=0;iIdPhotoToShow=0;hidepreview(this)});$("#containerpageselect").click(function(b){var a=$(b.target);if(a.is("div"))if(a.hasClass("pageselect")){urlToOpen=a.find("a").attr("href");if(urlToOpen!==undefined)window.location.href=urlToOpen}});$("#djkoppelen").click(function(a){var c=$(a.target);c.is(b)&&djconnect(a.target)});$("#containerphotodjsearch").click(function(c){var a=$(c.target);a.is(b)&&djconnect(c.target);a.attr("class")=="ui-button-text"&&a.closest("div").attr("id")=="btnzoekartiest"&&doArtistSearch(c.target)})});function creatememberpic(c,a,b){callphotoconnect(c,a,b,"create","page_white_camera","memberpic",0)}function makebackground(d,e,f,g){var c="background-image",a="body",b="";callphotoconnect(d,e,f,"background","","backgroundmember",0);if($(d).is(":checked")){b="url("+cStaticPathSite+g+")";$(a).css(c,b);$(a).attr("class","backgroundright")}else{b="";$(a).css(c,b);$(a).attr("class","backgroundbody")}}function memberconnect(a,b,c){var d=$(a).attr("checked")?"add":"remove";callphotoconnect(a,b,c,d,"","member",0)}function inpersonalphotobook(a,b,c){var d=$(a).attr("checked")?"add":"remove";callphotoconnect(a,b,c,d,"","personalphotobook",0)}function deletephoto(g,e,f){var d="personalphotobook",b="close",c="option",a="#dialogcontainer";$(a).dialog(c,"position","center");$(a).dialog(c,"width","auto");$(a).dialog(c,"height","auto");if(cLanguage=="en"){$(a).dialog(c,"title","Delete photo");$(a).html("Photo will be permanently deleted and cannot be recovered. Are you sure?<br/>");$(a).dialog(c,"buttons",{No:function(){$(this).dialog(b)},Yes:function(){callphotoconnect(g,e,f,"delete","",d,0);$(this).dialog(b)}})}else{$(a).dialog(c,"title","Verwijder foto");$(a).html("Foto zal definitief worden verwijderd, weet je het zeker?<br/>");$(a).dialog(c,"buttons",{Nee:function(){$(this).dialog(b)},Ja:function(){callphotoconnect(g,e,f,"delete","",d,0);$(this).dialog(b)}})}$("#currentphoto").clone().appendTo("div#dialogcontainer");$(a).dialog("open")}function rotate(a,g,h){var e="",f="",b="",d="",c;if($(a).hasClass("rotate_right"))e="right";if($(a).hasClass("rotate_left"))e="left";f=$(a).attr("src");$(a).attr({src:cStaticPathSite+"/image/formulier/loading.gif"});$.ajax({type:"GET",url:cDomain+"/ajax/ajaxrotateimage.p",data:{IdPictureBook:g,IdPhoto:h,Rotate:e},dataType:"xml",success:function(e){$(e).find("result").each(function(){c=$(this).find("message");if($(c).length>0){b=$(c).text();d=$(c).attr("type");if(d=="succes"){b=b+"<br/>Reloading page";showmessage(a,d,b,true)&&window.location.reload(true)}else showmessage(a,d,b,true)}});$(a).attr({src:f})},error:function(b){messagebox("Oeps "+b.statusText,"Status: "+b.statusText);$(a).attr({src:f})}})}function openFormUploadPhoto(d){var b="option",a="#dialogcontainer",c=getUrlVars().iduserprofile;if(c===undefined)showmessage(d,"error",cLanguage=="en"?"Unknown member account":"Onbekend member account",true);else{$(a).dialog(b,"title",cLanguage=="en"?"Upload an image into your photobook":"Upload een foto naar je fotoboek");$(a).dialog(b,"height",300);$(a).dialog(b,"width",520);$.get(cDomain+"/ajax/ajaxmemberpicupload.p",{act:"showform",iduserprofile:c,language:cLanguage},function(b){if(b===undefined){alert("no data");return}$(a).html(b);$(a).dialog("open");$('#dialogcontainer input[value=""]:first').focus()})}return false};
