var CAlbums=new function(){this.photosInfo=[];this.selectedAlbumType=null;this.selectedAlbum=null;this.selectedProvider=null;this.picasaSelAlbumName=null;this.flickrSelAlbumName=null;this.photobucketSelAlbumName=null;this.currentEnlargePhotoPosition=0;this.viewAlbumCounter=0;this.numWebServices=0;this.isFirstCall=true;this.isFirstBottomClick=true;this.isAfterFirstSave=false;this.showTxtPickImage=null;this.showTxtPickImageTimer=null;this.originalIndices=[];this.albumStartTime=null;this.numReplacedPhotos=0;this.timeToMakeSeconds=0;this.okToLeavePage=true;this.albumNameTimer=null;this.albumModified=false;this.showPreviewAfterSave=false;this.shareAfterSave=false;this.imageData=[];this.previewPressed=false;this.afterSave=false;this.desiredImgSize=156;this.spaceBetweenImg=8;this.extBorder=14;this.blackRectSize=this.desiredImgSize*4+3*this.spaceBetweenImg+2*this.extBorder;this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CAlbums.init,1)}jQuery(document).ready(function(){var c=document.createElement("script");c.setAttribute("type","text/javascript");c.setAttribute("src","http://platform.twitter.com/widgets.js");(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(c);g_passcodeNeeded=true;CUtils.globalInit();var a=CRegUtils.getLoggedInCookie();if(a!=null){CRegUtils.setLoggedInCookie(a.email,a.password,a.period);CRegUtils.sendLoginCredentials(a.email,a.password,"","","","",CAlbums.autoLoginResponse)}else{CRegUtils.facebookInit(CAlbums.autoLoginResponse,"CAlbums.autoLoginResponse")}jQuery("#albumInfoToggler").click(function(){jQuery("#albumInfoContainer").slideToggle();var d=jQuery(this).children("img");if(d.attr("class")=="arrUp"){d.attr("class","arrDwn")}else{d.attr("class","arrUp")}jQuery(this).parent("dl").next(".dlLast").toggleClass("dlLastUp")});jQuery("#createToggler").click(function(){jQuery("#createContainer").slideToggle();var d=jQuery(this).children("img");if(d.attr("class")=="arrUp"){d.attr("class","arrDwn")}else{d.attr("class","arrUp")}jQuery(this).parent("dl").next(".dlLast").toggleClass("dlLastUp")});jQuery("#accountButton").click(function(){jQuery("#accountMenu").toggleClass("on");return false});jQuery("html").click(function(){jQuery("#accountMenu").removeClass("on")});jQuery("#shareButton").click(function(){if(CAlbums.photosInfo.photosIndices.length<16){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareButton",params:"LessThan16"}},null,true);jAlert("You need at least 16 photos to create a 16Pics album","");return}CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareButton",params:""}},null,true);jQuery(".tutorialText,#txtClickBottomImage,.fakeText-1,#txtPickImage").hide();if(CAlbums.selectedAlbumType!="myAlbum"||(CAlbums.selectedAlbumType=="myAlbum"&&CAlbums.albumModified==true)){CAlbums.shareAfterSave=true;CAlbums.saveAlbum();return true}jQuery(".sharePopContainer").fadeIn();jQuery("#copyToClipboardButton").zclip({path:"http://s1.16pics.com/swf/ZeroClipboard.swf",copy:function(){CAlbums.updateShareStats("clipboard");return jQuery("#albumUrl").val()}});var d='<a href="https://twitter.com/share" class="twitter-share-button" data-text="My #16Pics Album \''+CAlbums.photosInfo.albumName+'\'" data-url="'+CAlbums.photosInfo.albumUrl+'" data-size="large" data-count="none">Tweet</a>';jQuery("#twitterShareButton").append(d);twttr.widgets.load();twttr.events.bind("click",function(e){CAlbums.updateShareStats("twitterClicked");jQuery(".sharePop .close").click()});twttr.events.bind("tweet",function(e){CAlbums.updateShareStats("twitterPublished")});return true});jQuery(".sharePop .close").click(function(){jQuery(".sharePopContainer").fadeOut();jQuery("#twitterShareButton").children().remove();return false});jQuery("#albumUrl").bind("copy",function(){CAlbums.updateShareStats("copy")});jQuery("#pencil, #albumName").click(function(){clearTimeout(CAlbums.albumNameTimer);jQuery("#albumNameBox").addClass("active");jQuery("#albumNameEdit").val(jQuery("#albumName").text());jQuery("#albumNameEdit").focus().select();return false});jQuery("#editBoxClose").click(function(){jQuery("#albumNameEdit").val(jQuery("#albumName").text());jQuery("#albumNameBox").removeClass("active");return false});jQuery("#albumNameEdit").blur(function(){CAlbums.albumNameTimer=setTimeout(function(){jQuery("#albumName").text(jQuery("#albumNameEdit").val()).attr("title",jQuery("#albumNameEdit").val());jQuery("#albumNameBox").removeClass("active");return false},300);CAlbums.albumModified=true});jQuery(".albumPreviewPop .close").click(function(){jQuery(".albumPreviewPop").fadeOut();jQuery("#previewOverlay").detach();jQuery("#iframeContainer").detach()});jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback);jQuery(document).keydown(function(d){var f=window.event||d;if(jQuery("#imageGallery").is(":visible")){switch(f.keyCode){case 27:CAlbums.closeGallery();break;case 37:CAlbums.popupArrowLeft();break;case 39:case 32:CAlbums.popupArrowRight();break}}else{switch(f.keyCode){case 13:jQuery("#albumNameEdit").blur();break}}});CAlbums.albumModified=false;if(g_collagePosted=="yes"){var b=jQuery.cookie("collagePosted");jQuery.cookie("collagePosted",null,{path:"/",expires:-1});if(b=="ok"){CAlbums.popupWithTimer("Collage posted on your Facebook wall",4000)}else{if(b=="error"){CAlbums.popupWithTimer("Error posting Collage on your facebook wall",4000)}else{CUtils.redirectHome()}}}})};this.getIsTutorialOn=function(){if(CAlbums.getNumMyAlbums()==0){return true}else{return false}};this.getNumMyAlbums=function(){var a=jQuery("#myAlbumsTable li").length;return a};this.hide16Fake=function(){jQuery("#photosAreaFake").css({visibility:"hidden",zIndex:0})};this.show16Fake=function(){jQuery("#photosAreaFake").css({visibility:"visible",zIndex:1})};this.hideBottomFake=function(){jQuery("#bottomPhotosScrollFake").css({visibility:"hidden",zIndex:0})};this.showBottomFake=function(){jQuery("#bottomPhotosScrollFake").css({visibility:"visible",zIndex:1})};this.hide16=function(){jQuery("#photosAreaContainer").css({visibility:"hidden",zIndex:0})};this.show16=function(){jQuery("#photosAreaContainer").css({visibility:"visible",zIndex:1})};this.hideBottom=function(){jQuery("#bottomPhotosScrollContainer").css({visibility:"hidden",zIndex:0})};this.showBottom=function(){jQuery("#bottomPhotosScrollContainer").css({visibility:"visible",zIndex:1})};this.refreshAll=function(){CAlbums.albumModified=false;g_refreshCounter++;CUtils.sendMessage("Registration","RefreshAll",{webService:CAlbums.selectedProvider,funcArgs:{}},CAlbums.refreshAllResponse,false)};this.refreshAllResponse=function(a){jQuery("#accountMenu").removeClass("on");if(a.errorText==""){if(a.out=="false"){jAlert("There was some problem in the refresh process","")}if(CAlbums.selectedAlbumType=="webAlbum"){CAlbums.getAlbums()}else{CAlbums.getMyAlbums()}}};this.updateProviderTab=function(a){jQuery("#myAlbumsTable").children().removeClass("on");jQuery("#"+CAlbums.selectedProvider+"Button").removeClass("on");jQuery("#"+a+"Button").addClass("on");jQuery.cookie("provider",a,{path:"/",expires:60})};this.setProvider=function(a){if(a!=CAlbums.selectedProvider||CAlbums.selectedAlbumType!="webAlbum"){if(CAlbums.albumModified){CAlbums.discardChangesPopup(this.setProvider,a)}else{if(CAlbums.selectedAlbumType!="webAlbum"){CAlbums.selectedAlbumType="webAlbum";CAlbums.switchToWebAlbumView()}CAlbums.updateProviderTab(a);CAlbums.selectedProvider=a;CAlbums.getAlbums();CAlbums.setAlbumSourceIcon(a)}}};this.savePhotosUrls=function(a){CAlbums.photosInfo.photosUrls=a};this.saveWebService=function(a){CAlbums.photosInfo.webService=a};this.savePhotosAlbumUrl=function(a){CAlbums.photosInfo.albumUrl=a};this.savePhotosIndices=function(b){CAlbums.photosInfo.photosIndices=[];for(var a=0;a<b.length;a++){CAlbums.photosInfo.photosIndices[a]=parseInt(b[a],10)}};this.savePhotosRotation=function(b){CAlbums.resetPhotosRotation();for(var a=0;a<b.length;a++){CAlbums.photosInfo.photosRotation[CAlbums.photosInfo.photosIndices[a]]=parseInt(b[a],10)}};this.savePhotosAlbumId=function(a){CAlbums.photosInfo.albumId=a};this.savePhotosWebServiceAlbumId=function(a){CAlbums.photosInfo.webServiceAlbumId=a};this.savePhotosWebServiceAlbumName=function(a){CAlbums.photosInfo.webServiceAlbumName=a};this.savePhotosAlbumName=function(a){CAlbums.photosInfo.albumName=a};this.autoLoginResponse=function(a){if(a.errorText!=""){CRegUtils.logout();return}else{CRegUtils.setUserDetails(a.out);jQuery("#headerMsg").show();jQuery("#welcomeMessage").html(g_username);if(g_userThumbUrl!=""){jQuery("#userThumb").attr("src",g_userThumbUrl).show()}CAlbums.selectedAlbumType="webAlbum";if(g_picasaToken!=null&&g_picasaToken!=""){jQuery("#picasaButton").show();CAlbums.numWebServices++;if(CAlbums.selectedProvider==null){CAlbums.selectedProvider="picasa"}}if(g_flickrToken!=null&&g_flickrToken!=""){jQuery("#flickrButton").show();CAlbums.numWebServices++;if(CAlbums.selectedProvider==null){CAlbums.selectedProvider="flickr"}}if(g_photobucketToken!=null&&g_photobucketToken!=""){jQuery("#photobucketButton").show();CAlbums.numWebServices++;if(CAlbums.selectedProvider==null){CAlbums.selectedProvider="photobucket"}}if(g_facebookToken!=null&&g_facebookToken!=""){jQuery("#facebookButton").show();CAlbums.numWebServices++;if(CAlbums.selectedProvider==null){CAlbums.selectedProvider="facebook"}}if(g_collagePosted=="yes"){CAlbums.selectedProvider=jQuery.cookie("provider")}CAlbums.updateProviderTab(CAlbums.selectedProvider);CAlbums.getMyAlbums()}};this.getAlbums=function(){if(CAlbums.getIsTutorialOn()){CAlbums.stopTxtPickImageTimer()}CAlbums.show16Fake();CAlbums.showBottomFake();jQuery(".fakeText-1, .fakeText-2, #txtCanShare").hide();CAlbums.showPopupAndFixPosition(jQuery("#waitAnimation"));CUtils.sendMessage("WebPicsApi","GetAllAlbumNames",{webService:CAlbums.selectedProvider},CAlbums.getAlbumsResponse,false)};this.getAlbumsResponse=function(d){CAlbums.hidePopup();if(CAlbums.getIsTutorialOn()){if(CAlbums.numWebServices==1){jQuery("#txtChooseAlbum").fadeIn(500)}else{if(CAlbums.numWebServices>1){jQuery("#txtChooseServiceAndAlbum").fadeIn(500)}else{jQuery(".fakeText-1").hide()}}}if(d.errorText==""){if(CAlbums.getIsTutorialOn()){jQuery("#myAlbumsContainer").hide();if(CAlbums.numWebServices==1){jQuery("#txtChooseAlbum").fadeIn(1000)}else{if(CAlbums.numWebServices>1){jQuery("#txtChooseServiceAndAlbum").fadeIn(500)}else{jQuery(".fakeText-1").hide()}}}else{if(g_collagePosted!="yes"){jQuery("#txtChooseNewOrChooseSaved").fadeIn(500)}}jQuery("#albumTableScroll").unbind().children().unbind();jQuery("#albumsTable").children().remove();for(var c=0;c<d.out.albumsNames.length;c++){var e=d.out.albumsNames[c];var b=d.out.albumsIds[c];jQuery("#albumsTable").append(jQuery("<li>").attr("albumId",b).append(jQuery("<a>").text(e)))}jQuery("#albumsTable").find("li").click(function(){if(CAlbums.albumModified){CAlbums.discardChangesPopup(jQuery(this),null)}else{CAlbums.selectedAlbumType="webAlbum";CAlbums.albumClickedUpdateSelection(this);var g=jQuery(this).children("a").html();var f=jQuery(this).attr("albumId");CAlbums.getPhotos(g,f);if(CAlbums.selectedProvider=="picasa"){CAlbums.picasaSelAlbumName=g}else{if(CAlbums.selectedProvider=="flickr"){CAlbums.flickrSelAlbumName=g}else{if(CAlbums.selectedProvider=="photobucket"){CAlbums.photobucketSelAlbumName=g}else{if(CAlbums.selectedProvider=="facebook"){CAlbums.facebookSelAlbumName=g}}}}}});jQuery("#albumTableScroll").jScrollPane({showArrows:true,verticalGutter:0});if(CAlbums.selectedAlbumType=="webAlbum"){var a;if(CAlbums.selectedProvider=="picasa"){a=CAlbums.picasaSelAlbumName}else{if(CAlbums.selectedProvider=="flickr"){a=CAlbums.flickrSelAlbumName}else{if(CAlbums.selectedProvider=="photobucket"){a=CAlbums.photobucketSelAlbumName}else{if(CAlbums.selectedProvider=="facebook"){a=CAlbums.facebookSelAlbumName}}}}if(a==null){}else{jQuery("#albumsTable").find(":contains('"+a+"')").parent("li").click()}}}};this.getMyAlbums=function(){CAlbums.showPopupAndFixPosition(jQuery("#waitAnimation"));CAlbums.show16Fake();CAlbums.showBottomFake();CUtils.sendMessage("Albums","GetAlbumsNames",{noArgs:""},CAlbums.getMyAlbumsResponse,true)};this.getMyAlbumsResponse=function(e){CAlbums.hidePopup();if(e.errorText==""){if(e.out.albumsNames.length>0){jQuery(".fakeText-1, .fakeText-2").hide();jQuery("#myAlbumsContainer").show();jQuery("#myAlbumTableScroll").unbind().children().unbind();jQuery("#myAlbumsTable").children().remove();for(var d=0;d<e.out.albumsNames.length;d++){var f=e.out.albumsNames[d];var c=e.out.albumsIds[d];jQuery("#myAlbumsTable").append(jQuery("<li>").attr("albumId",c).append(jQuery("<a>").html(f)))}jQuery("#myAlbumsTable").find("li").click(function(){if(CAlbums.albumModified){CAlbums.discardChangesPopup(jQuery(this),null)}else{CAlbums.selectedAlbumType="myAlbum";CAlbums.albumClickedUpdateSelection(this);var i=jQuery(this).children("a").html();var h=jQuery(this).attr("albumId");CAlbums.getMyPhotos(i,h)}});jQuery("#myAlbumTableScroll").jScrollPane({showArrows:true,verticalGutter:0});var g=jQuery.cookie("albumId");if(g!=null){var a=jQuery("#myAlbumsTable").find('[albumId="'+g+'"]');if(a!=null){jQuery(a).click()}else{if(CAlbums.selectedAlbumType=="myAlbum"){jQuery("#myAlbumsTable").find("li").first().click()}}}else{if(CAlbums.selectedAlbumType=="myAlbum"){jQuery("#myAlbumsTable").find("li").first().click()}}}else{jQuery("#myAlbumsContainer").hide();jQuery("#rightSideContainer").hide();jQuery(".tutorialText,#txtClickBottomImage,.fakeText-1,#txtPickImage").hide()}}if(CAlbums.isFirstCall){CAlbums.isFirstCall=false;CAlbums.getAlbums()}if(e.out.albumsNames.length==1){var b=jQuery(document.createElement("img")).attr({src:"http://s2.16pics.com/images/t.gif"}).addClass("fakeText-5");jQuery("#myAlbumsTable").append(jQuery("<li>").append(b))}};this.albumClickedUpdateSelection=function(b){if(CAlbums.selectedAlbum!=null){jQuery(CAlbums.selectedAlbum).removeClass("on")}jQuery(b).addClass("on");CAlbums.selectedAlbum=b;if(jQuery(b).parent().attr("id")=="myAlbumsTable"){var a=new Date();a.setMinutes(a.getMinutes()+10);jQuery.cookie("albumId",jQuery(b).attr("albumId"),{path:"/",expires:a})}else{jQuery.cookie("albumId",null,{path:"/",expires:-1})}};this.stopTxtPickImageTimer=function(){CAlbums.showTxtPickImage=false;if(CAlbums.showTxtPickImageTimer!=null){clearTimeout(CAlbums.showTxtPickImageTimer)}};this.showPopupAndFixPosition=function(a){jQuery(a).show();CAlbums.fixPopupPosition(jQuery(a));jQuery("body").append("<div id=brightOverlay></div>")};this.hidePopup=function(){jQuery("#brightOverlay").detach();jQuery(".servicesPop").hide()};this.getPhotos=function(b,a){jQuery("#txtCanShare").hide();if(CAlbums.getIsTutorialOn()){CAlbums.stopTxtPickImageTimer()}CAlbums.show16Fake();CAlbums.showBottomFake();jQuery(".fakeText-1").hide();CAlbums.showPopupAndFixPosition(jQuery("#generatingAlbumAnimation"));jQuery("#rightSideContainer").hide();jQuery("#infoNameContainer").hide();jQuery("#infoViewsContainer").hide();jQuery("#infoSourceContainer").hide();jQuery("#infoTotalContainer").hide();jQuery("#infoUpdatedContainer").hide();jQuery("#infoViewAlbumButton").hide();CUtils.sendMessage("WebPicsApi","Get16PhotosFromAlbum",{webService:CAlbums.selectedProvider,funcArgs:{webServiceAlbumId:a,albumName:b}},CAlbums.getPhotosResponse,false)};this.getPhotosResponse=function(a){CAlbums.hidePopup();if(a.errorText==""){CAlbums.photosInfo=[];jQuery(".fakeText-1, .fakeText-2").hide();CAlbums.hide16Fake();if(a.out.photosUrls.length>16){if(CAlbums.getIsTutorialOn()){CAlbums.isFirstBottomClick=true;CAlbums.showTxtPickImage=true;CAlbums.showTxtPickImageTimer=setTimeout(function(){if(CAlbums.showTxtPickImage=true){jQuery("#txtPickImage").fadeIn(500)}},5000)}else{CAlbums.isFirstBottomClick=false;CAlbums.hideBottomFake()}}else{CAlbums.hideBottomFake()}CAlbums.savePhotosUrls(a.out.photosUrls);CAlbums.originalIndices=a.out.photosIndices;CAlbums.savePhotosIndices(a.out.photosIndices);CAlbums.savePhotosWebServiceAlbumId(a.out.webServiceAlbumId);CAlbums.savePhotosAlbumName(a.out.albumName);CAlbums.saveWebService(a.out.webService);CAlbums.resetPhotosRotation();CAlbums.switchToWebAlbumView();jQuery("#rightSideContainer").show();CAlbums.fillAllPhotoThumbs();CAlbums.fillAllBottomThumbs();jQuery("#infoTotal").html(CAlbums.getNumPhotos());jQuery("#infoName").html(a.out.albumName);jQuery("#albumName").html(a.out.albumName).attr("title",a.out.albumName);jQuery("#albumNameEdit").val(a.out.albumName);CAlbums.albumStartTime=new Date()}};this.resetPhotosRotation=function(){CAlbums.photosInfo.photosRotation=[];for(var a=0;a<CAlbums.photosInfo.photosUrls.length;a++){CAlbums.photosInfo.photosRotation[a]=0}};this.setPhotoRotation=function(b,a){CAlbums.photosInfo.photosRotation[b]=a};this.getPhotoRotation=function(a){return CAlbums.photosInfo.photosRotation[a]};this.photoRotateLeft=function(c){CAlbums.albumModified=true;jQuery("#photoHolder_"+c).click();var b=CAlbums.photosInfo.photosIndices[c];var a=CAlbums.getPhotoRotation(b);a--;if(a<0){a=3}CAlbums.setPhotoRotation(b,a);CAlbums.fillPhotoThumbByPositionAndIndex(c,b);CAlbums.updateBottomThumbRotation(b)};this.photoRotateRight=function(c){CAlbums.albumModified=true;jQuery("#photoHolder_"+c).click();var b=CAlbums.photosInfo.photosIndices[c];var a=CAlbums.getPhotoRotation(b);a++;if(a==4){a=0}CAlbums.setPhotoRotation(b,a);CAlbums.fillPhotoThumbByPositionAndIndex(c,b);CAlbums.updateBottomThumbRotation(b)};this.getSelectedPhotoPosition=function(){var a=jQuery(".ul16Pic li.current").children().first().children().first().attr("id");var b=a.substring(a.indexOf("_")+1);return b};this.onLoadPhoto=function(){CUtils.cropImage(this);CAlbums.fixThumbRotatedOffset(this)};this.onLoadBottomPhoto=function(){CUtils.cropImage(this);CAlbums.fixThumbRotatedOffset(this)};this.fixImgPreviewRotatedOffset=function(b){if(parseInt(jQuery(b).attr("rot"),10)==1||parseInt(jQuery(b).attr("rot"),10)==3){var f=jQuery(b).width();var d=jQuery(b).height();var e=jQuery(b).offset().left;var a=jQuery(b).offset().top;var h;var c;if(jQuery.browser.mozilla||jQuery.browser.webkit){h=a+(d-f)/2;c=e}else{if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)>=8){h=a+(f-d);c=e-(f-d)/2}else{h=a;c=e}}var g=[];g.top=h;g.left=c;jQuery(b).offset(g)}};this.fixThumbRotatedOffset=function(e){if(parseInt(jQuery(e).attr("rot"),10)==1){var i=jQuery(e).width();var h=jQuery(e).height();var b=jQuery(e).offset().left;var f=jQuery(e).offset().top;var d;var a;if(jQuery.browser.mozilla){d=f;a=b}else{if(jQuery.browser.webkit){if(i>h){d=f-(h-i)/2;a=b+(h-i)/2}else{d=f+(i-h)/2;a=b-(i-h)/2}}else{if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)>=7){if(i>h){d=f-(h-i)/2;a=b+(h-i)/2}else{d=f+(i-h)/2;a=b-(i-h)/2}}else{d=f;a=b}}}var g=[];g.top=d;g.left=a;jQuery(e).offset(g)}else{if(parseInt(jQuery(e).attr("rot"),10)==3){var i=jQuery(e).width();var h=jQuery(e).height();var b=jQuery(e).offset().left;var f=jQuery(e).offset().top;var d;var a;if(jQuery.browser.mozilla){var c=jQuery(e).width();jQuery(e).width(jQuery(e).height());jQuery(e).height(c);d=f-(i-h)/2;a=b+(i-h)/2}else{if(jQuery.browser.webkit){var c=jQuery(e).width();jQuery(e).width(jQuery(e).height());jQuery(e).height(c);d=f;a=b}else{if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)>=7){if(i>h){d=f-(h-i)/2;a=b+(h-i)/2}else{d=f+(i-h)/2;a=b-(i-h)/2}}else{d=f;a=b}}}var g=[];g.top=d;g.left=a;jQuery(e).offset(g)}}};this.fixGalleryRotatedOffset=function(b){if(parseInt(jQuery(b).attr("rot"),10)==1||parseInt(jQuery(b).attr("rot"),10)==3){var f=jQuery(b).width();var d=jQuery(b).height();var e=jQuery(b).offset().left;var a=jQuery(b).offset().top;var h;var c;if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)>=8){h=a;c=e+(d-f)/2}else{if(jQuery.browser.msie){h=a;c=e}else{h=a+(f-d)/2;c=e}}var g=[];g.top=h;g.left=c;jQuery(b).offset(g)}};this.onShowPreview=function(){var d=jQuery(this).find("img");var c=jQuery(d).width();var a=jQuery(d).height();var g=jQuery(this).offset().left;var f=jQuery(this).offset().top;var b=f+(250-a);var e=g+(250-c)/2;var h=[];h.top=b;h.left=e;jQuery(this).offset(h);CAlbums.fixImgPreviewRotatedOffset(this);return};this.fillAllBottomThumbs=function(){jQuery('div[id^="imgPreviewContainer_"]').unbind().remove();jQuery("#bottomPhotosScroll").children().unbind().remove();jQuery("#bottomPhotosScroll").remove();jQuery("#bottomPhotosScrollContainer").append('<div class="scrollPane" id="bottomPhotosScroll"><ul class="ul11Pic"  id="bottomPhotos"></ul></div>');if(CAlbums.getNumPhotos()<=16){jQuery("#closedFtr").show();jQuery("#bottomPhotosScrollContainer").hide();CAlbums.hideBottom()}else{CAlbums.showBottom();jQuery("#closedFtr").hide();jQuery("#bottomPhotosScrollContainer").show();jQuery("#bottomPhotos").width(CAlbums.getNumPhotos()*85);jQuery("#bottomPhotosScroll").jScrollPane({arrowButtonSpeed:170,showArrows:true,animateScroll:true,animateDuration:1000});for(var b=0;b<CAlbums.getNumPhotos();b++){jQuery("#bottomPhotos").append('<li id="bottomPhotoContainer_'+b+'"><div class="inner" id="bottomPhotoHolder_'+b+'" alt=""></div></li>');var a=jQuery(document.createElement("img")).attr({id:"bottomPhoto_"+b,thumb:CAlbums.getMedThumbUrlFromPhotoIdx(b),rot:CAlbums.getRotationFromPhotoIdx(b)}).addClass("pic").click(CAlbums.bottomPhotoClick).imgPreview({srcAttr:"thumb",distanceFromCursor:{top:-275,left:-(250/2)+80/2},containerID:"imgPreviewContainer_"+b,onShow:CAlbums.onShowPreview});jQuery(a).rotate(CAlbums.getRotationFromPhotoIdx(b)*90);jQuery("#bottomPhotoHolder_"+b).empty().unbind().prepend(a);jQuery("#bottomPhoto_"+b).attr({src:CAlbums.getThumbUrlFromPhotoIdx(b)}).imagesLoaded(CAlbums.onLoadBottomPhoto);if(CUtils.findIdx(b,CAlbums.photosInfo.photosIndices)!=-1){jQuery("#bottomPhoto_"+b).addClass("greyed");jQuery("#bottomPhoto_"+b).css("opacity","0.35");jQuery("#bottomPhoto_"+b).attr("inactive","true")}jQuery("#imgPreviewContainer_"+b).addClass("picPic").attr("rot",CAlbums.getRotationFromPhotoIdx(b));jQuery("#imgPreviewContainer_"+b).rotate(CAlbums.getRotationFromPhotoIdx(b)*90)}}if(CAlbums.getIsTutorialOn()){jQuery("#txtClickBottomImage, #txtDontForgetToSave").hide()}else{jQuery("#photoHolder_0").click()}};this.getNumPhotoIndices=function(){return CAlbums.photosInfo.photosIndices.length};this.getNumPhotos=function(){return CAlbums.photosInfo.photosUrls.length};this.fillAllPhotoThumbs=function(){jQuery("#photosContainer").children().unbind().remove();for(var b=0;b<CAlbums.getNumPhotoIndices();b++){var a=CAlbums.photosInfo.photosIndices[b];jQuery("#photosContainer").append('<li id="photoHolder_'+b+'"><div class="inner"></div><div class="frame"></div><div class="actionBar"> <a onClick="CAlbums.photoRotateLeft('+b+')" title="Rotate Left">Rotate Left</a> <a onClick="CAlbums.photoRotateRight('+b+')" title="Rotate Right">Rotate Right</a> <a onClick="CAlbums.showPhotoGallery('+b+')" title="Full Size">FS</a> </div></li>');CAlbums.fillPhotoThumbByPositionAndIndex(b,a)}};this.photoClick=function(){if(CAlbums.getIsTutorialOn()){CAlbums.stopTxtPickImageTimer();jQuery("#txtPickImage").fadeOut(500);CAlbums.hideBottomFake();if(CAlbums.isFirstBottomClick==true&&CAlbums.getNumPhotos()>16){jQuery("#txtClickBottomImage").fadeIn(500)}}var a=this.id.substring(this.id.indexOf("_")+1);CAlbums.updateBottomPhotoLocation(a)};this.updateBottomPhotoLocation=function(c){var a=jQuery("#photoHolder_"+c);var b=CAlbums.photosInfo.photosIndices[c];jQuery(".ul16Pic li.current").removeClass("current");jQuery(a).addClass("current");if(CAlbums.getNumPhotos()<=16){return}setTimeout(function(){var e=jQuery("#bottomPhotosScroll");var d=e.data("jsp");d.scrollToX((b-5)*85);jQuery(".ul11Pic li.current").removeClass("current");jQuery("#bottomPhotoContainer_"+b).addClass("current")},500)};this.getUrlFromPhotoIdx=function(a){return CAlbums.photosInfo.photosUrls[a].url};this.getThumbUrlFromPhotoIdx=function(a){return CAlbums.photosInfo.photosUrls[a].thumbUrl};this.getMedThumbUrlFromPhotoIdx=function(a){return CAlbums.photosInfo.photosUrls[a].medThumbUrl};this.getRotationFromPhotoIdx=function(a){return CAlbums.photosInfo.photosRotation[a]};this.updateBottomThumbRotation=function(a){jQuery("#bottomPhotoHolder_"+a).find("img").attr("rot",CAlbums.getRotationFromPhotoIdx(a)).rotate(CAlbums.getRotationFromPhotoIdx(a)*90);if(jQuery("#bottomPhotoHolder_"+a).find("img").hasClass("greyed")){jQuery("#bottomPhotoHolder_"+a).find("img").css("opacity","0.35")}jQuery("#imgPreviewContainer_"+a).attr("rot",CAlbums.getRotationFromPhotoIdx(a)).rotate(CAlbums.getRotationFromPhotoIdx(a)*90)};this.bottomPhotoClick=function(){if(jQuery(this).hasClass("greyed")){return}CAlbums.albumModified=true;if(CAlbums.getIsTutorialOn()&&CAlbums.isFirstBottomClick==true){jQuery("#txtClickBottomImage").fadeOut(500);jQuery("#txtDontForgetToSave").fadeIn(500);CAlbums.isFirstBottomClick=false}CAlbums.isFirstBottomClick=false;var b=CAlbums.getSelectedPhotoPosition();var a=jQuery(this).attr("id");var c=parseInt(a.substring(a.indexOf("_")+1),10);CAlbums.updateSelectedPhoto(b,c)};this.fillPhotoThumbByPositionAndIndex=function(d,c){jQuery("#photoHolder_"+d).find(".inner").empty().unbind();var b=jQuery(document.createElement("img")).attr({id:"photo_"+d,rot:CAlbums.getRotationFromPhotoIdx(c)}).addClass("pic");jQuery(b).rotate(CAlbums.getRotationFromPhotoIdx(c)*90);jQuery("#photoHolder_"+d).find(".inner").append(b);jQuery("#photoHolder_"+d).find("img").attr({src:CAlbums.getThumbUrlFromPhotoIdx(c)}).imagesLoaded(CAlbums.onLoadPhoto);jQuery("#photoHolder_"+d).click(CAlbums.photoClick);var a=new Image();a.src=CAlbums.getUrlFromPhotoIdx(c)};this.updateSelectedPhoto=function(a,c){var b=CAlbums.photosInfo.photosIndices[a];CAlbums.photosInfo.photosIndices[a]=c;CAlbums.fillPhotoThumbByPositionAndIndex(a,c);jQuery("#photoHolder_"+a).click();jQuery("#bottomPhoto_"+b).removeClass("greyed");jQuery("#bottomPhoto_"+b).css("opacity","");jQuery("#bottomPhoto_"+b).removeAttr("inactive");jQuery("#bottomPhoto_"+c).addClass("greyed");jQuery("#bottomPhoto_"+c).css("opacity","0.35");jQuery("#bottomPhoto_"+c).attr("inactive","true")};this.getMyPhotos=function(b,a){CAlbums.show16Fake();CAlbums.showBottomFake();jQuery(".fakeText-1, .fakeText-2").hide();CAlbums.showPopupAndFixPosition(jQuery("#waitAnimation"));jQuery("#infoNameContainer").hide();jQuery("#infoViewsContainer").hide();jQuery("#infoSourceContainer").hide();jQuery("#infoTotalContainer").hide();jQuery("#infoUpdatedContainer").hide();jQuery("#infoViewAlbumButton").hide();CUtils.sendMessage("Albums","GetAlbumDataByAlbumId",{funcArgs:{albumId:a,albumName:b}},CAlbums.getMyPhotosResponse,true)};this.getMyPhotosResponse=function(b){CAlbums.previewPressed=false;CAlbums.hidePopup();if(b.errorText==""){CAlbums.photosInfo=[];CAlbums.hide16Fake();CAlbums.hideBottomFake();CAlbums.originalIndices=b.out.photosIndices;CAlbums.savePhotosUrls(b.out.photosUrls);CAlbums.savePhotosIndices(b.out.photosIndices);CAlbums.savePhotosRotation(b.out.photosRotation);CAlbums.savePhotosAlbumId(b.out.albumId);CAlbums.savePhotosWebServiceAlbumId(b.out.webServiceAlbumId);CAlbums.savePhotosWebServiceAlbumName(b.out.webServiceAlbumName);CAlbums.savePhotosAlbumName(b.out.albumName);CAlbums.saveWebService(b.out.webService);CAlbums.savePhotosAlbumUrl(b.out.albumUrl);CAlbums.numReplacedPhotos=parseInt(b.out.numReplacedPhotos,10);CAlbums.timeToMakeSeconds=parseInt(b.out.timeToMakeSeconds,10);jQuery("#rightSideContainer").show();CAlbums.switchToMyAlbumView();jQuery("#infoSource").removeClass();jQuery("#infoSource").addClass(b.out.webService);CAlbums.fillAllPhotoThumbs();CAlbums.fillAllBottomThumbs();jQuery("#albumName").html(b.out.albumName).attr("title",b.out.albumName);jQuery("#albumNameEdit").val(b.out.albumName);jQuery("#infoTotal").html(CAlbums.getNumPhotos());jQuery("#infoName").html(b.out.webServiceAlbumName);jQuery("#infoViews").text(b.out.viewCounter);var a=b.out.updated.substr(0,10);jQuery("#infoUpdated").html(a);if(CAlbums.isAfterFirstSave==true){CAlbums.isAfterFirstSave=false;jQuery("#txtCanShare").fadeIn(500)}else{jQuery("#txtCanShare").hide()}CAlbums.albumStartTime=new Date();if(CAlbums.shareAfterSave==false&&CAlbums.afterSave==true){CAlbums.afterSave=false;CAlbums.afterSavePopup()}}else{CAlbums.photosInfo.albumId=b.albumId;jQuery("#rightSideContainer").show();CAlbums.switchToMyAlbumView();jQuery("#saveUpdateButton").addClass("disabled");jQuery("#shareButton").addClass("disabled");jQuery("#infoSource").removeClass();jQuery("#infoTotal").html("");jQuery("#infoName").html("");jQuery("#infoViews").text("");jQuery("#infoUpdated").html("")}if(CAlbums.shareAfterSave==true){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareAfterAutoSave",params:Array(CAlbums.photosInfo.albumId)}},null,true);CAlbums.shareAfterSave=false;jQuery("#shareButton").click()}};this.saveAlbum=function(){if(CAlbums.photosInfo.photosIndices.length<16){jAlert("You need at least 16 photos to create a 16Pics album","");return}if(CAlbums.getIsTutorialOn()){CAlbums.stopTxtPickImageTimer()}jQuery("#albumName").html(jQuery("#albumNameEdit").val());if(jQuery("#albumName").html()==""){jQuery("#albumName").html("no name")}CAlbums.albumModified=false;if(CAlbums.selectedAlbumType=="myAlbum"){CAlbums.updateAlbum();return}CAlbums.showPopupAndFixPosition(jQuery("#generatingCollageAnimation"));if(CAlbums.getIsTutorialOn()){CAlbums.isAfterFirstSave=true;jQuery(".tutorialText,#txtClickBottomImage,.fakeText-1,#txtPickImage").fadeOut(500)}else{CAlbums.isAfterFirstSave=false}var a=[];var c=[];var i=[];for(var d=0;d<CAlbums.photosInfo.photosIndices.length;d++){var b=CAlbums.photosInfo.photosIndices[d];a.push(CAlbums.photosInfo.photosUrls[b]);c.push(b);i.push(CAlbums.photosInfo.photosRotation[b])}var f=CUtils.mergeArrays(CAlbums.originalIndices,c);var h=f.length-CAlbums.originalIndices.length;var j=new Date();var g=Math.round((j-CAlbums.albumStartTime)/1000);if(g>=DEF_MAX_TIME_TO_MAKE_SEC){g=-1}var e="";CUtils.sendMessage("Albums","AddAlbum",{funcArgs:{albumName:jQuery("#albumName").html(),photosIndices:c,photosRotation:i,photosUrls:a,webService:CAlbums.photosInfo.webService,webServiceAlbumId:CAlbums.photosInfo.webServiceAlbumId,webServiceAlbumName:CAlbums.photosInfo.albumName,webServiceNumPhotos:CAlbums.getNumPhotos(),numReplacedPhotos:h,timeToMakeSeconds:g,collage:e}},CAlbums.saveAlbumResponse,true)};this.saveAlbumResponse=function(a){CAlbums.hidePopup();if(a==null||a.errorText!=""){jAlert("Problem occured while saving album. Please try again","");return}else{CAlbums.afterSave=true;CAlbums.selectedAlbumType="myAlbum";CAlbums.getMyAlbums()}};this.updateAlbum=function(){CAlbums.albumModified=false;CAlbums.showPopupAndFixPosition(jQuery("#generatingCollageAnimation"));var f=jQuery("#albumName").html();var b=[];var e=[];var d=[];for(var h=0;h<CAlbums.photosInfo.photosIndices.length;h++){b.push(CAlbums.photosInfo.photosUrls[CAlbums.photosInfo.photosIndices[h]]);e.push(CAlbums.photosInfo.photosIndices[h]);d.push(CAlbums.photosInfo.photosRotation[CAlbums.photosInfo.photosIndices[h]])}var g=CUtils.mergeArrays(CAlbums.originalIndices,e);CAlbums.numReplacedPhotos=g.length-CAlbums.originalIndices.length+CAlbums.numReplacedPhotos;if(CAlbums.numReplacedPhotos>16){CAlbums.numReplacedPhotos=16}CAlbums.originalIndices=e;var c=new Date();if(CAlbums.timeToMakeSeconds!=-1){CAlbums.timeToMakeSeconds=CAlbums.timeToMakeSeconds+Math.round((c-CAlbums.albumStartTime)/1000)}if(CAlbums.timeToMakeSeconds>=DEF_MAX_TIME_TO_MAKE_SEC){CAlbums.timeToMakeSeconds=-1}var a="";CUtils.sendMessage("Albums","UpdateAlbum",{funcArgs:{albumName:f,photosIndices:e,photosRotation:d,photosUrls:b,albumId:CAlbums.photosInfo.albumId,webServiceNumPhotos:CAlbums.getNumPhotos(),numReplacedPhotos:CAlbums.numReplacedPhotos,timeToMakeSeconds:CAlbums.timeToMakeSeconds,collage:a}},CAlbums.updateAlbumResponse,true)};this.fixPopupPosition=function(e){var f=jQuery(e).parent().width();var a=jQuery(e).parent().position().left;var c=jQuery(e).width();var d=jQuery(e).parent().position().left+parseInt(jQuery(e).parent().css("margin-left"),10)+(jQuery(e).parent().width()-jQuery(e).width())/2;var b=jQuery(e).parent().position().top+parseInt(jQuery(e).parent().css("margin-top"),10)+(jQuery(e).parent().height()-jQuery(e).height())/2;jQuery(e).css({left:d+"px",top:b+"px"})};this.popupWithTimer=function(a,b){jQuery("#popupText").html(a);jQuery("#popupWithTimer").fadeIn(0,function(){setTimeout(function(){jQuery("#popupWithTimer").fadeOut(500)},b)});CAlbums.fixPopupPosition(jQuery("#popupWithTimer"))};this.updateAlbumResponse=function(a){CAlbums.hidePopup();if(a==null||a.errorText!=""){jAlert("Problem occured while saving album. Please try again","");return}else{jQuery("#myAlbumsTable").find('[albumId="'+CAlbums.photosInfo.albumId+'"]').find("a").html(jQuery("#albumName").html());if(CAlbums.showPreviewAfterSave==true){CAlbums.showPreviewAfterSave=false;CAlbums.openPreviewIframe()}else{if(CAlbums.shareAfterSave==true){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareAfterAutoSave",params:Array(CAlbums.photosInfo.albumId)}},null,true);CAlbums.shareAfterSave=false;jQuery("#shareButton").click()}}}};this.deleteAlbum=function(){if(jQuery("#deleteButton").hasClass("disabled")){return}CAlbums.areYouSurePopup()};this.deleteAlbumResponse=function(a){if(a.errorText==""){jQuery("#deleteButton").addClass("disabled");jQuery("#rightSideContainer").hide();CAlbums.albumModified=false;CAlbums.getMyAlbums()}else{jAlert("Error while deleting album. Please try again later","")}};this.openPreviewIframe=function(){jQuery("#albumPreviewInner").append('<div id="iframeContainer" class="iframe"><iframe width="1110" height="730" src="'+CAlbums.photosInfo.albumUrl+"&preview&"+CAlbums.viewAlbumCounter+'"></iframe></div>');jQuery("body").append("<div id=previewOverlay></div>");jQuery(".albumPreviewPop").fadeIn();jQuery("#previewOverlay").css("z-index","19997").show()};this.openPreviewAlbumWindow=function(){if(CAlbums.photosInfo.photosIndices.length<16){jAlert("You need at least 16 photos to create a 16Pics album","");return}jQuery("#albumName").html(jQuery("#albumNameEdit").val());if(jQuery("#albumName").html()==""){jQuery("#albumName").html("no name")}if(CAlbums.albumModified||CAlbums.selectedAlbumType=="webAlbum"){var c=[];var a=[];var b=[];for(var f=0;f<CAlbums.photosInfo.photosIndices.length;f++){var d=CAlbums.photosInfo.photosIndices[f];c.push(CAlbums.photosInfo.photosUrls[d].medThumbUrl);a.push(CAlbums.photosInfo.photosUrls[d].url);b.push(CAlbums.photosInfo.photosRotation[d])}var e=new Date();e.setMinutes(e.getMinutes()+2);jQuery.cookie("albumAdditionalData",CUtils.stringify({albumName:jQuery("#albumName").html(),username:g_username,webServiceNumPhotos:CAlbums.getNumPhotos(),numAlbums:CAlbums.getNumMyAlbums(),userThumbUrl:g_userThumbUrl,albumUrl:CAlbums.photosInfo.albumUrl}),{path:"/",expires:e});if(CUtils.hasStorage()){window.localStorage.largePhotosUrls=CUtils.stringify(a);window.localStorage.medThumbPhotosUrls=CUtils.stringify(c);window.localStorage.photosRotation=CUtils.stringify(b);jQuery.cookie("useStorage","yes",{path:"/",expires:e})}else{jQuery.cookie("useStorage","no",{path:"/",expires:e});jQuery.cookie("largePhotosUrls",CUtils.stringify(a),{path:"/",expires:e});jQuery.cookie("medThumbPhotosUrls",CUtils.stringify(c),{path:"/",expires:e});jQuery.cookie("photosRotation",CUtils.stringify(b),{path:"/",expires:e})}if(CAlbums.selectedAlbumType=="webAlbum"){window.open("http://"+g_domain+"/PreviewUnsavedAlbum?"+CAlbums.viewAlbumCounter,"_blank")}else{window.open(CAlbums.photosInfo.albumUrl+"/UnsavedAlbum?"+CAlbums.viewAlbumCounter,"_blank")}}else{window.open(CAlbums.photosInfo.albumUrl+"?"+CAlbums.viewAlbumCounter,"_blank")}};this.viewAlbum=function(){CAlbums.previewPressed=true;CAlbums.viewAlbumCounter++;CAlbums.openPreviewAlbumWindow()};this.switchToMyAlbumView=function(){jQuery("#deleteButton").attr("title","Delete current 16Pics album").removeClass("disabled");jQuery("#saveUpdateButton").attr("title","Update existing 16Pics album").html("Update Album").removeClass("disabled");jQuery("#infoNameContainer").show();jQuery("#infoViewsContainer").show();jQuery("#infoSourceContainer").show();jQuery("#infoTotalContainer").show();jQuery("#infoUpdatedContainer").show();jQuery("#infoViewAlbumButton").show();jQuery("#albumUrl").val(CAlbums.photosInfo.albumUrl);CAlbums.setAlbumSourceIcon("pic16")};this.switchToWebAlbumView=function(){CAlbums.setAlbumSourceIcon(CAlbums.selectedProvider);jQuery("#deleteButton").attr("title","").addClass("disabled");jQuery("#saveUpdateButton").attr("title","Save 16Pics album").html("Save Album").removeClass("disabled");jQuery("#infoNameContainer").show();jQuery("#infoViewsContainer").hide();jQuery("#infoSourceContainer").hide();jQuery("#infoTotalContainer").show();jQuery("#infoUpdatedContainer").hide();jQuery("#infoViewAlbumButton").show();jQuery("#albumUrl").html("")};this.shareOnFacebook=function(){jQuery(".sharePop .close").click();CAlbums.updateShareStats("facebook");CAlbums.showPopupAndFixPosition(jQuery("#waitAnimation"));setTimeout(function(){CUtils.redirect("/php/FacebookUploadPhoto.php?albumId="+CAlbums.photosInfo.albumId),300})};this.showGalleryPhotoByPhotoPosition=function(c){var b=CAlbums.photosInfo.photosIndices[c];var a=jQuery(document.createElement("img")).attr({id:"popImg",src:CAlbums.getUrlFromPhotoIdx(b),rot:CAlbums.getRotationFromPhotoIdx(b)}).click(CAlbums.popupArrowRight).addClass("pic").imagesLoaded(function(){jQuery(a).rotate(CAlbums.getRotationFromPhotoIdx(b)*90);if(!jQuery.browser.msie){if(CAlbums.getRotationFromPhotoIdx(b)==1||CAlbums.getRotationFromPhotoIdx(b)==3){jQuery(a).css({maxWidth:"600px",maxHeight:"800px"})}else{jQuery(a).css({maxWidth:"800px",maxHeight:"600px"})}jQuery("#popImg").fadeOut(300,function(){jQuery("#popImgWrapper").children().remove();jQuery("#popImgWrapper").append(a);if(CAlbums.getRotationFromPhotoIdx(b)==1||CAlbums.getRotationFromPhotoIdx(b)==3){CAlbums.fixGalleryRotatedOffset(jQuery("#popImg"))}jQuery("#popImg").hide();jQuery("#popImg").fadeIn(300)})}else{jQuery("#popImgWrapper").children().remove();jQuery("#popImgWrapper").append(a);var d=jQuery("#popImg").height();var e=jQuery("#popImg").width();if(CAlbums.getRotationFromPhotoIdx(b)==0||CAlbums.getRotationFromPhotoIdx(b)==2){if(d>600){jQuery("#popImg").css({height:"600px",width:"auto"})}e=jQuery("#popImg").width();if(e>800){jQuery("#popImg").css({height:"auto",width:"800px"})}}else{if(e>800){jQuery("#popImg").css({height:"800px",width:"auto"})}d=jQuery("#popImg").height();if(d>600){jQuery("#popImg").css({height:"auto",width:"600px"})}CAlbums.fixGalleryRotatedOffset(jQuery("#popImg"))}}})};this.showPhotoGallery=function(a){CAlbums.currentEnlargePhotoPosition=a;jQuery("body").append("<div id=overlay></div>");jQuery("#overlay").show();jQuery("#imageGallery").fadeIn();if(CAlbums.currentEnlargePhotoPosition==CAlbums.getNumPhotoIndices()-1){jQuery("#popArrowRight").addClass("disable")}else{jQuery("#popArrowRight").removeClass("disable")}if(CAlbums.currentEnlargePhotoPosition==0){jQuery("#popArrowLeft").addClass("disable")}else{jQuery("#popArrowLeft").removeClass("disable")}CAlbums.showGalleryPhotoByPhotoPosition(a);return false};this.closeGallery=function(){jQuery("#imageGallery").fadeOut();jQuery("#overlay").detach();jQuery("#popImg").hide();CAlbums.updateBottomPhotoLocation(CAlbums.currentEnlargePhotoPosition)};this.popupArrowLeft=function(){if(CAlbums.currentEnlargePhotoPosition==0){return}CAlbums.currentEnlargePhotoPosition--;jQuery("#popArrowRight").removeClass("disable");if(CAlbums.currentEnlargePhotoPosition==0){jQuery("#popArrowLeft").addClass("disable")}CAlbums.showGalleryPhotoByPhotoPosition(CAlbums.currentEnlargePhotoPosition)};this.popupArrowRight=function(){if(CAlbums.currentEnlargePhotoPosition==CAlbums.getNumPhotoIndices()-1){return}CAlbums.currentEnlargePhotoPosition++;jQuery("#popArrowLeft").removeClass("disable");if(CAlbums.currentEnlargePhotoPosition==CAlbums.photosInfo.photosRotation.length-1){jQuery("#popArrowRight").addClass("disable")}CAlbums.showGalleryPhotoByPhotoPosition(CAlbums.currentEnlargePhotoPosition)};this.elementRotateRight=function(b){var a=parseInt(jQuery(b).attr("rot"),10);if(a==null){a=0}a++;if(a==4){a=0}jQuery(b).attr("rot",a);jQuery(b).rotate(a*90)};this.elementRotateLeft=function(b){var a=parseInt(jQuery(b).attr("rot"),10);if(a==null){a=0}a--;if(a==-1){a=3}jQuery(b).attr("rot",a);jQuery(b).rotate(a*90)};this.redirect=function(a){if(CAlbums.albumModified){CAlbums.discardChangesPopup(CUtils.redirect,a)}else{CUtils.redirect(a)}};this.discardChangesPopup=function(a,b){if(CAlbums.photosInfo.photosIndices.length<16){CAlbums.albumModified=false;if(b==null){a.click()}else{a(b)}return}if(CAlbums.albumModified==true){jQuery.alerts.okButton=" Yes ";jQuery.alerts.cancelButton=" No ";jConfirm("Do you wish to discard changes?","",function(c){if(c){CAlbums.albumModified=false;if(b==null){a.click()}else{a(b)}}});jQuery.alerts.okButton=" OK ";jQuery.alerts.cancelButton=" Cancel "}};this.saveChangesPopup=function(a){jQuery.alerts.okButton=" Yes ";jQuery.alerts.cancelButton=" No ";jConfirm("Do you wish to save changes before preview?","",function(b){if(b){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ViewAlbumAfterUpdatePopupYes",params:Array(CAlbums.photosInfo.albumId)}},null,true);CAlbums.albumModified=false;CAlbums.showPreviewAfterSave=true;CAlbums.updateAlbum()}else{CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ViewAlbumAfterUpdatePopupNo",params:Array(CAlbums.photosInfo.albumId)}},null,true);CAlbums.albumModified=false;CAlbums.openPreviewIframe();CAlbums.albumModified=true}});jQuery.alerts.okButton=" OK ";jQuery.alerts.cancelButton=" Cancel "};this.areYouSurePopup=function(){jQuery.alerts.okButton=" Yes ";jQuery.alerts.cancelButton=" No ";jQuery("body").append("<div id=brightOverlay></div>");jConfirm("Are you sure you want to delete this album ?","",function(a){if(a){CUtils.sendMessage("Albums","DeleteAlbumByAlbumId",{funcArgs:{albumId:CAlbums.photosInfo.albumId}},CAlbums.deleteAlbumResponse,true)}jQuery("#brightOverlay").detach()});jQuery.alerts.okButton=" OK ";jQuery.alerts.cancelButton=" Cancel "};this.afterSavePopup=function(){jQuery.alerts.okButton=" Yes ";jQuery.alerts.cancelButton=" Later ";jQuery("body").append("<div id=brightOverlay></div>");if(CAlbums.previewPressed){jConfirm("Share Album ?","",function(a){if(a){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareAfterSave",params:Array("yes")}},null,true);jQuery("#shareButton").click()}else{CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"ShareAfterSave",params:Array("no")}},null,true)}jQuery("#brightOverlay").detach()})}else{jConfirm("Preview Album (as your friends will see it) ?","",function(a){if(a){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"PreviewAfterSave",params:Array("yes")}},null,true);CAlbums.viewAlbum()}else{CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"PreviewAfterSave",params:Array("no")}},null,true)}jQuery("#brightOverlay").detach()})}jQuery.alerts.okButton=" OK ";jQuery.alerts.cancelButton=" Cancel "};this.updateShareStats=function(a){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"Share",params:Array(a)}},null,true)};this.setAlbumSourceIcon=function(a){jQuery("#editBoxLogo").removeClass();jQuery("#editBoxLogo").addClass(a)}};var DEF_SHOW_ERRORS=false;var DEF_MIN_NAME_LENGTH=2;var DEF_MIN_PASSWORD_LENGTH=6;var DEF_DEBUG=true;var DEF_MAX_TIME_TO_MAKE_SEC=900;var g_userId="";var g_userEmail="";var g_username="";var g_picasaToken="";var g_flickrToken="";var g_photobucketToken="";var g_facebookToken="";var g_loginType="";var g_facebookId="";var g_passcodeNeeded=true;var g_refreshCounter=Math.floor(Math.random()*1000000);var g_sessionDurationMinutes=30;var g_userDataTable="";var g_userThumbUrl="";var g_demoClicked=false;var g_isPreview="no";var CHome=new function(){this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CHome.init,1)}jQuery(document).ready(function(){g_passcodeNeeded=true;CUtils.globalInit();jQuery("#accountButton").click(function(){jQuery("#accountMenu").toggleClass("on");return false});jQuery("html").click(function(){jQuery("#accountMenu").removeClass("on")});jQuery("#demoButton").click(function(){if(g_demoClicked==false){g_demoClicked=true;CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"demo",params:""}},null,true);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"demoClicked",param:"home"}},null,true)}jQuery("#demoPopInner").append('<div id="videoContainer" class="video"><iframe width="800" height="572" src="http://www.youtube.com/embed/u9WtIV52JRs?autoplay=1&rel=0" frameborder="0"></iframe></div>');jQuery("body").append("<div id=overlay></div>");jQuery(".demoPop").fadeIn();jQuery("#overlay").css("z-index","9997").show()});jQuery(".demoPop .close").click(function(){jQuery(".demoPop").fadeOut();jQuery("#overlay").detach();jQuery("#videoContainer").detach()});jQuery("a[rel=signIn]").click(function(){jQuery("body").append("<div id=overlay></div>");jQuery(".signInPop").fadeIn();jQuery("#overlay").css("z-index","9998").show();return false});jQuery("#signUpButton,#signUpFreeButton").click(function(){jQuery("body").append("<div id=overlay></div>");jQuery(".signUpPop").fadeIn();jQuery("#overlay").css("z-index","9998").show();return false});jQuery(".signPop .close").click(function(){jQuery(".signPop").fadeOut();jQuery("#overlay").detach()});jQuery(".pwdRecoveryPop .close").click(function(){jQuery(".pwdRecoveryPop").fadeOut();jQuery("#overlay").detach()});jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback);var a=CRegUtils.getLoggedInCookie();if(a!=null){CRegUtils.setLoggedInCookie(a.email,a.password,a.period);CRegUtils.sendLoginCredentials(a.email,a.password,"","","","",CHome.autoLoginResponse)}else{CRegUtils.facebookInit(CHome.autoLoginResponse,"CHome.autoLoginResponse");FB.Event.subscribe("auth.login",function(b){CHome.loginWithFacebook(b)});jQuery(".fb-login-button").show()}jQuery(".tosPop .close").click(function(){jQuery(".tosPop").fadeOut();jQuery("#opac_tmp").detach();jQuery("#overlay").detach()})})};this.signInPopKeyDown=function(a){if(!jQuery(".signInPop").is(":visible")){return}switch(a.keyCode){case 13:CHome.login();break}};this.autoLoginResponse=function(a){if(a.errorText!=""){CRegUtils.clearUserDetails();CRegUtils.clearLoggedInCookie();jQuery("#userIn").hide();jQuery("#guestUser").show();if(g_loginType!=""){CRegUtils.logout()}}else{CRegUtils.setUserDetails(a.out);if(g_isHomePage){CUtils.redirect("/");return}jQuery("#guestUser").hide();jQuery("#userInside").show();jQuery("#welcomeMessage").html(g_username);if(g_userThumbUrl!=""){jQuery("#userThumb").attr("src",g_userThumbUrl).show()}}};this.login=function(){if(jQuery("#remember_me:checked").val()==undefined){CRegUtils.clearLoggedInCookie()}if(jQuery("#login_email").val().length==0||jQuery("#login_password").val().length==0){jAlert("Please fill email and password to log in","");return}else{if(jQuery("#login_password").val().length<DEF_MIN_PASSWORD_LENGTH||CRegUtils.isValidEmail(jQuery("#login_email").val()==false)){jAlert("Login credentials incorrect","");jQuery("#login_email").val("");jQuery("#login_password").val("");return}else{CRegUtils.sendLoginCredentials(jQuery("#login_email").val(),Crypto.MD5(jQuery("#login_password").val()),"","","","",CHome.loginResponse)}}};this.loginResponse=function(a){if(a.errorText!=""){CUtils.handleError(a.errorText);jAlert(a.errorText,"");jQuery("#login_email").val("");jQuery("#login_password").val("");CRegUtils.clearUserDetails();CRegUtils.clearLoggedInCookie();jQuery("#userIn").hide();jQuery("#guestUser").show();return}else{CRegUtils.setUserDetails(a.out);if(jQuery("#remember_me:checked").val()!=undefined){if(a.webService!="facebook"){CRegUtils.setLoggedInCookie(jQuery("#login_email").val(),Crypto.MD5(jQuery("#login_password").val()),"long")}}else{CRegUtils.clearLoggedInCookie();CRegUtils.setLoggedInCookie(jQuery("#login_email").val(),Crypto.MD5(jQuery("#login_password").val()),"short");jQuery("#login_email").val("");jQuery("#login_password").val("")}CUtils.redirect("/")}};this.loginWithFacebook=function(a){if(g_loginType=="facebook"){return}g_loginType="facebook";FB.api({method:"fql.query",query:"SELECT name, email, uid, pic_square FROM user WHERE uid="+a.authResponse.userID},function(b){if(b[0].email!=null&&b[0].email.length>0&&b[0].uid!=null&&b[0].uid.length>0&&b[0].name!=null&&b[0].name.length>0){CRegUtils.sendLoginCredentials(b[0].email,"","facebook",b[0].uid,b[0].name,b[0].pic_square,CHome.loginResponse)}else{jAlert("Problem with Facebook connect","")}})};this.openPwdRecoverPopUp=function(){jQuery(".signPop .close").click();jQuery("body").append("<div id=overlay></div>");$(".pwdRecoveryPop").fadeIn();$("#overlay").css("z-index","9998").show();return false};this.openTOSPopUp=function(){jQuery(".signUpPop").append("<div class=opac id=opac_tmp></div>");jQuery("body").append("<div id=overlay></div>");$(".tosPop").fadeIn();$("#overlay").css("z-index","9998").show();return false};this.verifyRegForm=function(){if(jQuery("#agree_terms:checked").val()==undefined){jAlert("Please accept terms of service","");return}CRegUtils.checkName("name","valid_name","name_err");CRegUtils.checkEmail("email","valid_email","email_err");CRegUtils.checkPassword("password","valid_password","password_err","password_again","valid_password_again","password_again_err");if(jQuery("#name").val()==""||jQuery("#valid_name").val()=="0"){jAlert("Please enter a valid name in the form","");return}if(jQuery("#email").val()==""||jQuery("#valid_email").val()=="0"){jAlert("Please enter a valid Email address","");return}if(jQuery("#password").val()==""||jQuery("#valid_password").val()=="0"){jAlert("Please enter valid password","");return}if(jQuery("#password_again").val()==""||jQuery("#valid_password_again").val()=="0"){jAlert("Please enter matching password","");return}jQuery("#waitAnimation").show();CHome.submitRegistrationForm();return};this.submitRegistrationForm=function(){jQuery("#name").attr("disabled",true);jQuery("#name").addClass("disabled");jQuery("#email").attr("disabled",true);jQuery("#email").addClass("disabled");jQuery("#password").attr("disabled",true);jQuery("#password").addClass("disabled");jQuery("#password_again").attr("disabled",true);jQuery("#password_again").addClass("disabled");jQuery("#submitSignUp").attr("disabled",true);jQuery("#submitSignUp").addClass("disabled");jQuery("#agree_terms").attr("disabled",true);jQuery("#agree_terms").addClass("disabled");jQuery("#emailUpdates").attr("disabled",true);jQuery("#emailUpdates").addClass("disabled");jQuery("#fb_login_btn").hide();CUtils.sendMessage("Registration","AddUserToVerify",{funcArgs:{username:jQuery("#name").val(),email:jQuery("#email").val(),password:Crypto.MD5(jQuery("#password").val()),updates:(jQuery("#emailUpdates:checked").val()!=undefined)}},CHome.getRegResponse,true)};this.getRegResponse=function(a){jQuery("#name").attr("disabled",false);jQuery("#name").removeClass("disabled");jQuery("#email").attr("disabled",false);jQuery("#email").removeClass("disabled");jQuery("#password").attr("disabled",false);jQuery("#password").removeClass("disabled");jQuery("#password_again").attr("disabled",false);jQuery("#password_again").removeClass("disabled");jQuery("#submitSignUp").attr("disabled",false);jQuery("#submitSignUp").removeClass("disabled");jQuery("#agree_terms").attr("disabled",false);jQuery("#agree_terms").removeClass("disabled");jQuery("#emailUpdates").attr("disabled",false);jQuery("#emailUpdates").removeClass("disabled");jQuery("#fb_login_btn").show();jQuery("#waitAnimation").hide();if(a.errorText!=""){jAlert(a.errorText,"");return}else{jQuery("#name").val("");jQuery("#email").val("");jQuery("#password").val("");jQuery("#password_again").val("");jQuery("#agree_terms").attr("checked",false);jQuery("#emailUpdates").attr("checked",true);jQuery(".signPop .close").click();jAlert("An email with activation key will be sent to you shortly.<br>Please follow the link to complete registration.","")}}};var CLanding=new function(){this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CLanding.init,1)}jQuery(document).ready(function(){if(g_initFlag=="1"){CRegUtils.logout();return}var a=jQuery.cookie("passcode");if(a=="ok"){CLanding.setPasscodeCookie();CUtils.redirectHome()}jQuery("#passcode").keydown(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(b==13){jQuery("#go").click()}});jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback);g_passcodeNeeded=false;CUtils.globalInit();jQuery("#demoButton").click(function(){if(g_demoClicked==false){g_demoClicked=true;CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"demo",params:""}},null,true);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"demoClicked",param:"landing"}},null,true)}jQuery("#demoPopInner").append('<div id="videoContainer" class="video"><iframe width="800" height="572" src="http://www.youtube.com/embed/u9WtIV52JRs?autoplay=1&rel=0" frameborder="0" allowfullscreen></iframe></div>');jQuery("body").append("<div id=overlay></div>");jQuery(".demoPop").fadeIn();jQuery("#overlay").css("z-index","9997").show()});jQuery(".demoPop .close").click(function(){jQuery(".demoPop").fadeOut();jQuery("#overlay").detach();jQuery("#videoContainer").detach()})})};this.submitPasscode=function(){if(jQuery("#passcode").val().length==0||jQuery("#passcode").val().length==0){jAlert("Please fill passcode or leave email for early registration","");return}else{CUtils.sendMessage("Registration","CheckPasscode",{funcArgs:{passcode:jQuery("#passcode").val()}},CLanding.submitPasscodeResponse,true)}};this.setPasscodeCookie=function(){var a=new Date();a.setMinutes(a.getMinutes()+60*24*240);jQuery.cookie("passcode","ok",{path:"/",expires:a})};this.submitPasscodeResponse=function(a){if(a.out.passcode=="ok"){CLanding.setPasscodeCookie();CUtils.redirectHome()}else{jAlert("Wrong passcode","")}}};var CPasswordRecovery=new function(){this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CPasswordRecovery.init,1)}jQuery(document).ready(function(){g_passcodeNeeded=false;CUtils.globalInit();var a=CRegUtils.getLoggedInCookie();if(a!=null){CRegUtils.setLoggedInCookie(a.email,a.password,a.period);CRegUtils.sendLoginCredentials(a.email,a.password,"","","","",CPasswordRecovery.autoLoginResponse)}else{CRegUtils.facebookInit(CPasswordRecovery.autoLoginResponse,"CPasswordRecovery.autoLoginResponse")}jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback)})};this.autoLoginResponse=function(a){if(a.errorText!=""){CRegUtils.clearUserDetails();CRegUtils.clearLoggedInCookie();return}else{CRegUtils.setUserDetails(a.out)}};this.getRecoveryResponse=function(a){jQuery("#waitAnimation").hide();jQuery("#pwd_recover_email").attr("disabled",false);jQuery("#submit").attr("disabled",false);jQuery("#submit").removeClass("disabled");if(a.errorText!=""){jAlert(a.errorText,"");return}else{jAlert("An email with password recovery instructions will be sent to you shortly.","");jQuery(".pwdRecoveryPop .close").click()}};this.submitRecoveryForm=function(){jQuery("#waitAnimation").show();jQuery("#pwd_recover_email").attr("disabled",true);jQuery("#submit").attr("disabled",true);jQuery("#submit").addClass("disabled");CUtils.sendMessage("Registration","PasswordRecovery",{funcArgs:{email:jQuery("#pwd_recover_email").val()}},CPasswordRecovery.getRecoveryResponse,true)};this.verifyRecoveryForm=function(){CRegUtils.checkEmail("pwd_recover_email","pwd_recover_valid","pwd_recover_err");if(jQuery("#pwd_recover_email").val()==""||jQuery("#pwd_recover_valid").val()=="0"){jAlert("Please enter a valid Email address","");return}CPasswordRecovery.submitRecoveryForm();return};this.resetRecoveryForm=function(){jQuery("#email").val("");jQuery("#email_err").hide().html("");jQuery("#valid_email").val("0")};this.getNewPasswordResponse=function(a){if(a.errorText!=""){jAlert(a.errorText,"");jQuery("#password").attr("disabled",false);jQuery("#password_again").attr("disabled",false);jQuery("#submit").attr("disabled",false);jQuery("#reset").attr("disabled",false);jQuery("#submit").removeClass("disabled");jQuery("#reset").removeClass("disabled");jQuery("#status_message").html("");return}else{jQuery("#status_message").html("Your password was changed successfuly")}};this.submitNewPasswordForm=function(){jQuery("#status_message").html("Changing password...");jQuery("#password").attr("disabled",true);jQuery("#password_again").attr("disabled",true);jQuery("#submit").attr("disabled",true);jQuery("#reset").attr("disabled",true);jQuery("#submit").addClass("disabled");jQuery("#reset").addClass("disabled");CUtils.sendMessage("Registration","PasswordChange",{funcArgs:{recoveryKey:g_recoveryKey,password:Crypto.MD5(jQuery("#password").val())}},CPasswordRecovery.getNewPasswordResponse,true)};this.verifyNewPasswordForm=function(){CRegUtils.checkPassword("password","valid_password","password_err","password_again","valid_password_again","password_again_err");if(jQuery("#password").val()==""||jQuery("#valid_password").val()=="0"){jAlert("Please enter valid password","");return}if(jQuery("#password_again").val()==""||jQuery("#valid_password_again").val()=="0"){jAlert("Please enter matching password","");return}CPasswordRecovery.submitNewPasswordForm();return};this.resetNewPasswordForm=function(){jQuery("#password").val("");jQuery("#password_err").hide().html("");jQuery("#valid_password").val("0");jQuery("#password_again").val("");jQuery("#password_again_err").hide().html("");jQuery("#valid_password_again").val("0")}};var CRegUtils=new function(){this.logout=function(){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"Logout",params:""}},null,true);setTimeout(function(){CRegUtils.clearLoggedInCookie();CRegUtils.clearUserIdCookie();CRegUtils.clearUserDataTableCookie();CUtils.clearSessionIdCookie();if(g_loginType=="facebook"){FB.logout(function(response){CUtils.redirectHome();return})}else{CUtils.redirectHome();return}},100)};this.isValidEmail=function(email){if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(email))){return false}else{return true}};this.sendLoginCredentials=function(loginEmail,loginPassword,webServiceName,uid,loginName,thumbUrl,callbackFunc){var page=window.location.pathname.substring(1);var endPos=page.search("/");if(endPos==-1){endPos=page.length}page=page.substring(0,endPos);CUtils.sendMessage("Registration","CheckLoginCredentials",{funcArgs:{email:loginEmail,password:loginPassword,webService:webServiceName,webServiceUid:uid,username:loginName,userThumbUrl:thumbUrl,url:page}},callbackFunc,true);g_userEmail=loginEmail};this.setLoggedInCookie=function(userEmail,userPassword,lifetime){if(userEmail!=""){var expTime=new Date();if(lifetime=="long"){expTime.setMinutes(expTime.getMinutes()+60*24*30)}else{expTime.setMinutes(expTime.getMinutes()+30)}var cookieStr=CUtils.stringify({email:userEmail,password:userPassword,period:lifetime});jQuery.cookie("LoggedIn",cookieStr,{path:"/",expires:expTime})}if(lifetime=="short"){setInterval(CUtils.saveLoggedInCookie,29*60*1000,cookieStr)}};this.clearLoggedInCookie=function(){jQuery.cookie("LoggedIn",null,{path:"/",expires:-1})};this.clearUserIdCookie=function(){jQuery.cookie("userId",null,{path:"/",expires:-1})};this.clearUserDataTableCookie=function(){jQuery.cookie("userDataTable",null,{path:"/",expires:-1})};this.getLoggedInCookie=function(){var userText=jQuery.cookie("LoggedIn");var userObj;userObj=jQuery.parseJSON(userText);if(userObj==null){return null}if(userObj.Email!="-1"&&userObj.Password!="-1"&&userObj.period!="-1"){return userObj}else{return null}};this.setFacebookCallbackCookie=function(cb){jQuery.cookie("FacebookCB",cb,{path:"/",expires:1})};this.getFacebookCallbackCookie=function(){var cb=jQuery.cookie("FacebookCB");return cb};this.setUserDetails=function(loginResponseOut){g_username=loginResponseOut.username;g_picasaToken=loginResponseOut.picasaToken;g_flickrToken=loginResponseOut.flickrToken;g_photobucketToken=loginResponseOut.photobucketToken;g_facebookToken=loginResponseOut.facebookToken;g_loginType=loginResponseOut.loginType;g_userId=loginResponseOut.userId;g_refreshCounter=loginResponseOut.refreshCounter;g_userDataTable=loginResponseOut.userDataTable;g_userThumbUrl=loginResponseOut.userThumbUrl;CUtils.saveUserIdCookie();CUtils.saveUserDataTableCookie()};this.clearUserDetails=function(){g_username="";g_picasaToken="";g_flickrToken="";g_photobucketToken="";g_facebookToken="";g_loginType="";g_userId=""};this.webServiceAutoLogin=function(webServiceName,webServiceUid,username,email,userThumbUrl,callbackFunc){CRegUtils.sendLoginCredentials(email,"",webServiceName,webServiceUid,username,userThumbUrl,callbackFunc)};this.facebookAutoLogin=function(response,callbackFunc){if(g_loginType=="facebook"){return}g_loginType="facebook";FB.api({method:"fql.query",query:"SELECT name, email, uid, pic_square FROM user WHERE uid="+response.authResponse.userID},function(response){if(response[0].email!=null&&response[0].email.length>0&&response[0].uid!=null&&response[0].uid.length>0&&response[0].name!=null&&response[0].name.length>0){CRegUtils.webServiceAutoLogin("facebook",response[0].uid,response[0].name,response[0].email,response[0].pic_square,callbackFunc)}else{jAlert("Problem with Facebook connect","")}})};this.facebookInit=function(callbackForAutoLogin,callbackName){var cb=callbackForAutoLogin;CRegUtils.setFacebookCallbackCookie(callbackName);FB.init({appId:g_facebookId,channelURL:"//"+g_domain+"/channel.html",status:true,oauth:true,cookie:true,xfbml:true});FB.getLoginStatus(function(response){var facebookCbName=CRegUtils.getFacebookCallbackCookie();if(facebookCbName==null){CUtils.redirectHome();return}else{var facebookCb=eval(facebookCbName)}if(response.status=="connected"){CRegUtils.facebookAutoLogin(response,facebookCb)}else{if(jQuery.cookie("passcode")!="ok"&&g_passcodeNeeded==true){CUtils.redirectHome();return}var responseData=[];responseData.errorText="Facebook not logged in";facebookCb(responseData)}})};this.checkName=function(name,valid,err){name="#"+name;valid="#"+valid;err="#"+err;jQuery(name).val(jQuery(name).val().replace(/^\s*/,"").replace(/\s*$/,""));if(jQuery(name).val().length==0){jQuery(err).html("Enter name");jQuery(valid).val("0")}else{if(/[^A-Za-z -.]/.test(jQuery(name).val())){jQuery(err).html("Name contains illegal characters");jQuery(valid).val("0")}else{if(!(/\w+/.test(jQuery(name).val()))){jQuery(err).html("Name must contain letters");jQuery(valid).val("0")}else{if(jQuery(name).val().length<DEF_MIN_NAME_LENGTH){jQuery(err).html("Name is too short");jQuery(valid).val("0")}else{jQuery(err).html("");jQuery(valid).val("1")}}}}};this.checkEmail=function(email,valid,err){email="#"+email;valid="#"+valid;err="#"+err;if(jQuery(email).val()==""){jQuery(err).html("Enter email address");jQuery(valid).val("0")}else{if(!CRegUtils.isValidEmail(jQuery(email).val())){jQuery(err).html("Invalid Email address");jQuery(valid).val("0")}else{jQuery(err).html("");jQuery(valid).val("1")}}};this.checkPassword=function(pwd,valid,err,pwd_again,valid_again,err_again){pwd="#"+pwd;valid="#"+valid;err="#"+err;pwd_again="#"+pwd_again;valid_again="#"+valid_again;err_again="#"+err_again;if(jQuery(pwd).val()==""&&jQuery(pwd_again).val()==""){jQuery(err).show().html("");jQuery(err_again).show().html("");jQuery(valid).val("1");jQuery(valid_again).val("1");return}else{if(jQuery(pwd).val().length<DEF_MIN_PASSWORD_LENGTH){jQuery(err).show().html("Password too short ( <"+DEF_MIN_PASSWORD_LENGTH+" )");jQuery(valid).val("0");jQuery(err_again).hide().html("");jQuery(valid_again).val("0")}else{jQuery(err).hide().html("");jQuery(valid).val("1")}}if(jQuery(pwd_again).val().length==0){jQuery(valid_again).val("0")}else{if(jQuery(valid).val()=="1"){if(jQuery(pwd).val()!=jQuery(pwd_again).val()){jQuery(err_again).show().html("Passwords don't match");jQuery(valid_again).val("0")}else{jQuery(err_again).hide().html("");jQuery(valid_again).val("1")}}else{if(jQuery(pwd_again).val().length<DEF_MIN_PASSWORD_LENGTH){jQuery(err_again).show().html("Password too short ( <"+DEF_MIN_PASSWORD_LENGTH+" )");jQuery(valid_again).val("0")}else{jQuery(err_again).hide().html("");jQuery(valid_again).val("0")}}}}};var CSettings=new function(){this.numMyServices=0;this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CSettings.init,1)}jQuery(document).ready(function(){g_passcodeNeeded=true;CUtils.globalInit();jQuery("#waitAnimation").show();var a=CRegUtils.getLoggedInCookie();if(a!=null){CRegUtils.setLoggedInCookie(a.email,a.password,a.period);CRegUtils.sendLoginCredentials(a.email,a.password,"","","","",CSettings.autoLoginResponse)}else{CRegUtils.facebookInit(CSettings.autoLoginResponse,"CSettings.autoLoginResponse")}jQuery("#accountButton").click(function(){jQuery("#accountMenu").toggleClass("on");return false});jQuery("html").click(function(){jQuery("#accountMenu").removeClass("on")});jQuery(".services .tabs a").click(function(){CSettings.restoreAccountDetails();var b=jQuery(this).attr("rel");jQuery(".services .tabs li").removeClass("on");jQuery(this).parent("li").addClass("on");jQuery(".tabDiv").hide();jQuery("#"+b).fadeIn();return false});jQuery(".myServices .icon").click(function(){jQuery("body").append("<div id=brightOverlay></div>");jQuery(this).next(".servicesPop").fadeIn();jQuery("#brightOverlay").css("z-index","9997").show()});jQuery(".servicesPop .close").click(function(){jQuery(this).parent(".servicesPop").fadeOut();jQuery("#brightOverlay").detach();return false});jQuery("#showAlbumsButton").click(function(){if(jQuery(this).is(".disabled")){return}else{CUtils.redirect("/Albums")}});jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback)})};this.autoLoginResponse=function(a){if(a.errorText!=""){CRegUtils.logout();return}else{CRegUtils.setUserDetails(a.out);jQuery("#headerMsg").show();jQuery("#welcomeMessage").html(g_username);if(g_userThumbUrl!=""){jQuery("#userThumb").attr("src",g_userThumbUrl).show()}if(g_picasaToken==null||g_picasaToken==""){CSettings.webServiceConnected("picasa",false)}else{CSettings.webServiceConnected("picasa",true);CSettings.numMyServices++}if(g_flickrToken==null||g_flickrToken==""){CSettings.webServiceConnected("flickr",false)}else{CSettings.webServiceConnected("flickr",true);CSettings.numMyServices++}if(g_photobucketToken==null||g_photobucketToken==""){CSettings.webServiceConnected("photobucket",false)}else{CSettings.webServiceConnected("photobucket",true);CSettings.numMyServices++}if(g_facebookToken==null||g_facebookToken==""){CSettings.webServiceConnected("facebook",false)}else{CSettings.webServiceConnected("facebook",true);CSettings.numMyServices++}CSettings.updateShowAlbumsButton();jQuery("#waitAnimation").hide()}};this.authenticate=function(a){jQuery("#waitAnimation").show();switch(a){case"picasa":CUtils.redirect("/php/PicasaAuth.php");return;case"flickr":CUtils.redirect("/php/FlickrAuth.php");return;case"facebook":CUtils.redirect("/php/FacebookAuth.php");return;case"photobucket":CUtils.redirect("/php/PhotobucketAuth.php");return}};this.updateShowAlbumsButton=function(){if(CSettings.numMyServices>0){jQuery("#myServicesNoServices").hide();jQuery("#showAlbumsButton").removeClass("disabled")}else{jQuery("#myServicesNoServices").fadeIn(500);jQuery("#showAlbumsButton").addClass("disabled")}};this.webServiceConnected=function(a,b){if(b==true){jQuery("#"+a+"Login").addClass("disabled").unbind("click");jQuery("#my"+a).show()}else{jQuery("#"+a+"Login").removeClass("disabled").click(function(){CSettings.authenticate(a)});jQuery("#my"+a).hide()}};this.disconnectService=function(a){CUtils.sendMessage("Registration","DeleteWebServiceToken",{funcArgs:{webService:a}},CSettings.disconnectServiceResponse,true)};this.disconnectServiceResponse=function(a){jQuery("#brightOverlay").detach();if(a.errorText!=""){jAlert("Problem disconnecting service")}else{CSettings.numMyServices--;CSettings.webServiceConnected(a.out.webService,false);CSettings.updateShowAlbumsButton()}};this.saveAccountDetails=function(){CRegUtils.checkName("accountName","valid_name","name_err");CRegUtils.checkEmail("accountEmail","valid_email","email_err");if(g_loginType!="facebook"){CRegUtils.checkPassword("accountNewPwd","valid_password","password_err","accountConfirmNewPwd","valid_password_again","password_again_err")}if(jQuery("#accountName").val()==""||jQuery("#valid_name").val()=="0"){jAlert("Please enter a valid name in the form","");return}if(jQuery("#accountEmail").val()==""||jQuery("#valid_email").val()=="0"){jAlert("Please enter a valid Email address","");return}if(jQuery("#valid_password").val()=="0"){jAlert("Please enter valid password","");return}if(jQuery("#valid_password_again").val()=="0"){jAlert("Please enter matching password","");return}if(jQuery("#accountNewPwd").val()!=""&&jQuery("#accountOldPwd").val()==""){jAlert("Please enter old password","");return}var b,a;if(jQuery("#accountNewPwd").val()!=""){b=Crypto.MD5(jQuery("#accountNewPwd").val());a=Crypto.MD5(jQuery("#accountOldPwd").val())}else{b="";a=""}CUtils.sendMessage("Registration","ChangeLoginCredentials",{funcArgs:{username:jQuery("#accountName").val(),email:jQuery("#accountEmail").val(),password:b,old_password:a,emailUpdates:(jQuery("#emailUpdates:checked").val()!=undefined)}},CSettings.saveAccountDetailsResponse,true)};this.saveAccountDetailsResponse=function(b){if(b.errorText==""){g_username=b.out.username;g_userEmail=b.out.email;var a=CRegUtils.getLoggedInCookie();if(a!=null){if(b.out.password==""){new_pwd=a.password}else{new_pwd=b.out.password}CRegUtils.setLoggedInCookie(g_userEmail,new_pwd,a.period)}jAlert("Changes Saved","");jQuery("#servicesTab").click();return}else{jAlert(b.errorText,"Operation Failed");return}};this.restoreAccountDetails=function(){CUtils.sendMessage("Registration","GetUserDetailsByUserId",{funcArgs:{userId:g_userId}},function(a){jQuery("#accountName").val(a.out.username);jQuery("#accountEmail").val(a.out.email);jQuery("#emailUpdates").attr("checked",a.out.emailUpdates=="1")},true);jQuery("#accountNewPwd").val("");jQuery("#accountConfirmNewPwd").val("");jQuery("#accountOldPwd").val("");if(g_loginType=="facebook"){jQuery("#accountName").addClass("disabled");jQuery("#accountName").attr("disabled",true);jQuery("#accountEmail").addClass("disabled");jQuery("#accountEmail").attr("disabled",true);jQuery("#accountNewPwd").addClass("disabled");jQuery("#accountNewPwd").attr("disabled",true);jQuery("#accountConfirmNewPwd").addClass("disabled");jQuery("#accountConfirmNewPwd").attr("disabled",true);jQuery("#accountOldPwd").addClass("disabled");jQuery("#accountOldPwd").attr("disabled",true)}jQuery("#name_err").html("");jQuery("#valid_name").val("1");jQuery("#email_err").html("");jQuery("#valid_email").val("1");jQuery("#password_err").html("");jQuery("#valid_password").val("1");jQuery("#password_again_err").html("");jQuery("#valid_password_again").val("1")}};var CUtils=new function(){this.stringify=function(a){var d="{";var c=0;for(var b in a){if(c>0){d+=","}d+='"'+b+'":"'+a[b]+'"';c++}d+="}";return d};this.showHideFeedback=function(){var a;if(typeof g_viewAlbumsPage=="undefined"){a=1030}else{a=1155}if(jQuery(window).width()<a){jQuery("#contactable").hide()}else{jQuery("#contactable").show()}};this.handleError=function(a){jQuery("#waitImg").hide();if(a!=""&&DEF_SHOW_ERRORS){jAlert(a,"");return}};this.redirectHome=function(){CUtils.redirect("/")};this.globalInit=function(){CUtils.saveSessionIdCookie();setInterval(CUtils.saveSessionIdCookie,(g_sessionDurationMinutes-1)*60*1000)};this.sendMessage=function(e,g,h,b,f,d){if(!CUtils.getSessionIdCookie()){CUtils.saveSessionIdCookie();setTimeout(function(){CUtils.sendMessage(e,g,h,b,f,d)},100);return}else{var a;var c;if(typeof(d)=="undefined"){d=g_refreshCounter}if(f==true){a="POST";c=false}else{a="GET";c=true}jQuery.ajax({type:a,url:"/php/ClientApi.php",cache:c,data:{debug:DEF_DEBUG,module:e,"in":h,func:g,refreshCounter:d,sid:g_sessionId},timeout:100000,dataType:"json",success:b,error:function(k,i,j){CUtils.handleError("error: xhr="+k+" ; Error="+i+" ; e="+j)}})}};this.clearSessionIdCookie=function(){jQuery.cookie("sessionId",null,{path:"/",expires:-1})};this.getSessionIdCookie=function(){return jQuery.cookie("sessionId")};this.saveSessionIdCookie=function(){var a=new Date();a.setMinutes(a.getMinutes()+g_sessionDurationMinutes);CUtils.clearSessionIdCookie();jQuery.cookie("sessionId",g_sessionId,{path:"/",expires:a})};this.saveUserIdCookie=function(){jQuery.cookie("userId",null,{path:"/",expires:-1});jQuery.cookie("userId",g_userId,{path:"/",expires:30})};this.saveUserDataTableCookie=function(){jQuery.cookie("userDataTable",g_userDataTable,{path:"/",expires:30})};this.saveLoggedInCookie=function(a){jQuery.cookie("LoggedIn",null,{path:"/",expires:-1});var b=new Date();b.setMinutes(b.getMinutes()+30);jQuery.cookie("LoggedIn",a,{path:"/",expires:b})};this.executeFunctionByName=function(f,c){var a=Array.prototype.slice.call(arguments).splice(2);var e=f.split(".");var d=e.pop();for(var b=0;b<e.length;b++){c=c[e[b]]}return c[d].apply(this,a)};this.redirect=function(a){if(!CUtils.getSessionIdCookie()){CUtils.saveSessionIdCookie();setTimeout(function(){CUtils.redirect(a)},100);return}else{CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"Redirect",params:a}},null,true);setTimeout(function(){parent.location=a},100)}};this.findIdx=function(e,b){var a=-1;var d=b.length;for(var c=0;c<d;c++){a=(e==b[c])?c:-1;if(-1!=a){break}}return a};this.cropImage=function(d){var c=jQuery(d).width();var a=jQuery(d).height();var f=jQuery(d).parent().width();if(jQuery.browser.msie&&jQuery(d).attr("rot")==1||jQuery(d).attr("rot")==3){var e=c;c=a;a=e}if(c>a){var g=f*c/a;jQuery(d).css({height:f+"px",width:g+"px",left:-(g-f)/2+"px"})}else{var b=f*a/c;jQuery(d).css({width:f+"px",height:b+"px",top:-(b-f)/2+"px"})}jQuery(d).show()};this.mergeArrays=function(b,a){var c=b.slice();for(idx=0;idx<a.length;idx++){if(CUtils.indexOf(b,a[idx])===-1){c.push(a[idx])}}return c};this.indexOf=function(a,c){for(var b=0;b<a.length;b++){if(a[b]==c){return b}}return -1};this.insertAddThis=function(){var a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src","http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4ea1d7cf2d3841e4");(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(a)};this.hasStorage=function(){if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<8){return false}else{try{window.localStorage.setItem("tst","test storage");window.localStorage.removeItem("tst");return true}catch(a){return false}}};this.objectLength=function(c){var a=c.length?--c.length:0;for(var b in c){a++}return a}};var CViewAlbums=new function(){this.currentEnlargePhotoPosition=0;this.photosRotation=[];this.photosUrls=[];this.signupSlideShown=false;this.signupSlideClicked=false;this.init=function(){if(typeof jQuery=="undefined"||typeof end16pics=="undefined"||typeof end16picsExt=="undefined"){return setTimeout(CViewAlbums.init,1)}jQuery(document).ready(function(){var a;if(g_useStorage==true){var c=jQuery.parseJSON(window.localStorage.largePhotosUrls);var e=jQuery.parseJSON(window.localStorage.medThumbPhotosUrls);var d=jQuery.parseJSON(window.localStorage.photosRotation);CViewAlbums.photosUrls=[];CViewAlbums.photosRotation=[];var g=CUtils.objectLength(e);for(a=0;a<g;a++){var f=new Object();f.url=c[a];f.medThumbUrl=e[a];CViewAlbums.photosUrls.push(f);CViewAlbums.photosRotation.push(d[a])}}else{CViewAlbums.photosRotation=jQuery.parseJSON(g_photosRotation);CViewAlbums.photosUrls=jQuery.parseJSON(g_photosUrls)}for(a=0;a<CViewAlbums.photosRotation.length;a++){CViewAlbums.photosRotation[a]=parseInt(CViewAlbums.photosRotation[a],10)}CViewAlbums.Show16Photos();jQuery(document).keydown(function(h){if(!jQuery("#imageGallery").is(":visible")){return}if(jQuery(".signPop").is(":visible")){return}var h=window.event||h;switch(h.keyCode){case 27:CViewAlbums.closeGallery();break;case 37:CViewAlbums.popupArrowLeft();break;case 39:case 32:CViewAlbums.popupArrowRight();break}});jQuery("#slideShow").click(function(){CViewAlbums.showPhotoGallery(0)});if(g_isPreview){return}jQuery("a[rel=makeAlbum]").click(function(){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"MakeAlbum",params:Array(g_userId,g_albumId)}},null,true);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"viewPageClicked",param:g_promTextVer}},null,true);CUtils.redirect("/")});jQuery("#signUpButton,#signUpFreeButton").click(function(){jQuery("body").append("<div id=overlay></div>");jQuery(".signUpPop").fadeIn();jQuery("#overlay").css("z-index","9998").show();if(CViewAlbums.signupSlideClicked==false){CViewAlbums.signupSlideClicked=true;CViewAlbums.signupClicked()}return false});jQuery(".signPop .close").click(function(){jQuery(".signPop").fadeOut();jQuery("#overlay").detach()});jQuery(".tosPop .close").click(function(){jQuery(".tosPop").fadeOut();jQuery("#opac_tmp").detach();jQuery("#overlay").detach()});CRegUtils.facebookInit(CHome.autoLoginResponse,"CHome.autoLoginResponse");FB.Event.subscribe("auth.login",function(h){if(CViewAlbums.signupSlideClicked==false){CViewAlbums.signupSlideClicked=true;CViewAlbums.signupClicked()}CHome.loginWithFacebook(h);CUtils.redirectHome()});jQuery("#contactable").contactable({subject:location.href});CUtils.showHideFeedback();jQuery(window).resize(CUtils.showHideFeedback);CLanding.setPasscodeCookie();g_passcodeNeeded=false;CUtils.globalInit();var b=CRegUtils.getLoggedInCookie();if(b!=null){CRegUtils.setLoggedInCookie(b.email,b.password,b.period);CRegUtils.sendLoginCredentials(b.email,b.password,"","","","",CViewAlbums.autoLoginResponse)}else{CRegUtils.facebookInit(CViewAlbums.autoLoginResponse,"CViewAlbums.autoLoginResponse")}if(g_isPreviewUnsavedAlbum){return}setTimeout(CViewAlbums.increaseViewCounter,5000)})};this.signupClicked=function(){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"SignupSlideClicked",params:Array("")}},null,true);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"signupSlideClicked",param:""}},null,true)};this.signupShown=function(){CUtils.sendMessage("Info","AddAction",{funcArgs:{action:"SignupSlideShown",params:Array("")}},null,true);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"signupSlideShown",param:""}},null,true)};this.autoLoginResponse=function(a){};this.increaseViewCounter=function(){CUtils.sendMessage("Albums","IncreaseViewCounter",{funcArgs:{albumId:g_albumId,userDataTableNumber:g_userDataTableNumber}},null,false,0);CUtils.sendMessage("Info","Stats",{funcArgs:{stat:"viewPageShown",param:g_promTextVer}},null,true)};this.showGalleryPhotoByPhotoPosition=function(b){var a=jQuery(document.createElement("img")).attr({id:"popImg",src:CViewAlbums.photosUrls[b].url,rot:CViewAlbums.photosRotation[b]}).click(CViewAlbums.popupArrowRight).addClass("pic").imagesLoaded(function(){jQuery(a).rotate(CViewAlbums.photosRotation[b]*90);if(!jQuery.browser.msie){if(CViewAlbums.photosRotation[b]==1||CViewAlbums.photosRotation[b]==3){jQuery(a).css({maxWidth:"600px",maxHeight:"800px"})}else{jQuery(a).css({maxWidth:"800px",maxHeight:"600px"})}jQuery("#popImg").fadeOut(300,function(){jQuery("#popImg").remove();jQuery("#popImgWrapper").append(a);if(CViewAlbums.photosRotation[b]==1||CViewAlbums.photosRotation[b]==3){CViewAlbums.fixGalleryRotatedOffset(jQuery("#popImg"))}jQuery("#popImg").hide();jQuery("#popImg").fadeIn(300)})}else{jQuery("#popImg").remove();jQuery("#popImgWrapper").append(a);var c=jQuery("#popImg").height();var d=jQuery("#popImg").width();if(CViewAlbums.photosRotation[b]==0||CViewAlbums.photosRotation[b]==2){if(c>600){jQuery("#popImg").css({height:"600px",width:"auto"})}d=jQuery("#popImg").width();if(d>800){jQuery("#popImg").css({height:"auto",width:"800px"})}}else{if(d>800){jQuery("#popImg").css({height:"800px",width:"auto"})}c=jQuery("#popImg").height();if(c>600){jQuery("#popImg").css({height:"auto",width:"600px"})}CViewAlbums.fixGalleryRotatedOffset(jQuery("#popImg"))}}})};this.fixGalleryRotatedOffset=function(b){if(parseInt(jQuery(b).attr("rot"))==1||parseInt(jQuery(b).attr("rot"))==3){var f=jQuery(b).width();var d=jQuery(b).height();var e=jQuery(b).offset().left;var a=jQuery(b).offset().top;var h;var c;if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)>=8){if(f>d){h=a;c=e+(d-f)/2}else{h=a;c=e+(d-f)/2}}else{if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<8){if(f>d){h=a;c=e}else{h=a;c=e}}else{h=a+(f-d)/2;c=e}}var g=[];g.top=h;g.left=c;jQuery(b).offset(g)}};this.showPhotoGallery=function(a){CViewAlbums.currentEnlargePhotoPosition=a;jQuery("body").append("<div id=galleryOverlay></div>");jQuery("#galleryOverlay").show();jQuery("#imageGallery").fadeIn();if(CViewAlbums.currentEnlargePhotoPosition==CViewAlbums.photosRotation.length-1&&!g_newUser){jQuery("#popArrowRight").addClass("disable")}else{jQuery("#popArrowRight").removeClass("disable")}if(CViewAlbums.currentEnlargePhotoPosition==0&&!g_newUser){jQuery("#popArrowLeft").addClass("disable")}else{jQuery("#popArrowLeft").removeClass("disable")}CViewAlbums.showGalleryPhotoByPhotoPosition(a);return false};this.closeGallery=function(){jQuery("#imageGallery").fadeOut();jQuery("#galleryOverlay").detach();jQuery("#popImg").hide();jQuery("#signupSlide").hide()};this.popupArrowLeft=function(){if(CViewAlbums.currentEnlargePhotoPosition==0){if(g_newUser){if(CViewAlbums.signupSlideShown==false){CViewAlbums.signupSlideShown=true;CViewAlbums.signupShown()}jQuery("#popArrowLeft").addClass("disable");CViewAlbums.currentEnlargePhotoPosition--;jQuery("#popImg").fadeOut(300,function(){jQuery("#signupSlide").fadeIn(300)});return}else{return}}if(CViewAlbums.currentEnlargePhotoPosition==-1){return}if(CViewAlbums.currentEnlargePhotoPosition==CViewAlbums.photosRotation.length){jQuery("#signupSlide").hide()}CViewAlbums.currentEnlargePhotoPosition--;jQuery("#popArrowRight").removeClass("disable");if(CViewAlbums.currentEnlargePhotoPosition==0&&!g_newUser){jQuery("#popArrowLeft").addClass("disable")}CViewAlbums.showGalleryPhotoByPhotoPosition(CViewAlbums.currentEnlargePhotoPosition)};this.popupArrowRight=function(){jQuery("#popArrowLeft").removeClass("disable");if(CViewAlbums.currentEnlargePhotoPosition==CViewAlbums.photosRotation.length-1){if(g_newUser){if(CViewAlbums.signupSlideShown==false){CViewAlbums.signupSlideShown=true;CViewAlbums.signupShown()}jQuery("#popArrowRight").addClass("disable");CViewAlbums.currentEnlargePhotoPosition++;jQuery("#popImg").fadeOut(300,function(){jQuery("#signupSlide").fadeIn(300)});return}else{return}}if(CViewAlbums.currentEnlargePhotoPosition==CViewAlbums.photosRotation.length){return}if(CViewAlbums.currentEnlargePhotoPosition==-1){jQuery("#signupSlide").hide()}CViewAlbums.currentEnlargePhotoPosition++;if(CViewAlbums.currentEnlargePhotoPosition==CViewAlbums.photosRotation.length-1&&!g_newUser){jQuery("#popArrowRight").addClass("disable")}CViewAlbums.showGalleryPhotoByPhotoPosition(CViewAlbums.currentEnlargePhotoPosition)};this.Show16Photos=function(){jQuery("#albumName").html(g_albumName);jQuery("#userNameIsUsing").html(g_username);jQuery("#userHeadline").html(g_username);jQuery("#numAlbums").html(g_numAlbums);jQuery("#webServiceNumPhotos").html(g_webServiceNumPhotos);jQuery("#numPhotos").html(CViewAlbums.photosRotation.length);if(g_userThumb!=""){jQuery("#userThumb").attr("src",g_userThumb).show()}for(var d=0;d<CViewAlbums.photosUrls.length;d++){jQuery("#photosContainer").append('<li id="photoHolder_'+d+'" onClick="CViewAlbums.showPhotoGallery('+d+')"></li>');var c=CViewAlbums.photosUrls[d].medThumbUrl;var b=jQuery(document.createElement("img")).attr({id:"photo_"+d,src:CViewAlbums.photosUrls[d].medThumbUrl,rot:CViewAlbums.photosRotation[d]}).addClass("pic").rotate(CViewAlbums.photosRotation[d]*90).hide().imagesLoaded(function(){CUtils.cropImage(this);CAlbums.fixThumbRotatedOffset(this)});jQuery("#photoHolder_"+d).append(b);var a=new Image();a.src=CViewAlbums.photosUrls[d].url}}};var end16pics="end";
