function SNPictureUtils() { var me = this; init(); // constructor function init() {} this.setNavButtonState = function() { // disable NextPhoto button if there are no more photos var btnNext = document.getElementById("image_next"); var caption=myListCaptionOwner[selectedPhoto]; document.getElementById("posted").innerHTML=caption; if( photoCount == (selectedPhoto+1) && btnNext ) { btnNext.src = "http://media.supernova.com/images/buttons/next-grey.jpg"; btnNext.onclick = null; btnNext.className = "sn_floatLeft"; } else { btnNext.src = "http://media.supernova.com/images/buttons/next.jpg"; btnNext.onclick = me.loadNextPhoto; btnNext.className = "sn_floatLeft sn_pointer"; } // disable PrevPhoto button if there are no more photos var btnPrev = document.getElementById("image_prev"); if( 0 == selectedPhoto && btnPrev ) { btnPrev.src = "http://media.supernova.com/images/buttons/prev-grey.jpg"; btnPrev.onclick = null; btnPrev.className = "sn_floatLeft"; } else { btnPrev.src = "http://media.supernova.com/images/buttons/prev.jpg"; btnPrev.onclick = me.loadPrevPhoto; btnPrev.className = "sn_floatLeft sn_pointer"; } // disable prev-line-grey.jpg if there are no more photos var albumNavWidth = parseInt(document.getElementById("albumNav").style.width); var albumNavContainerLeft = parseInt(document.getElementById("albumNavContainer").style.left); var albumNavContainerWidth = parseInt(document.getElementById("albumNavContainer").style.width); var albumNavContainerRight = albumNavContainerLeft-albumNavWidth; //disable/enable prev-line-grey.jpg & next-line-grey.jpg if(albumNavWidth < albumNavContainerWidth) // more than 7 pictures { var btnPrevLine = document.getElementById("image_prev_line"); var btnNextLine = document.getElementById("image_next_line"); if (albumNavContainerLeft == 0) { btnPrevLine.src = "http://media.supernova.com/images/buttons/prev-line-grey.jpg"; btnPrevLine.className = "sn_floatLeft"; }else{ btnPrevLine.src = "http://media.supernova.com/images/buttons/prev-line.jpg"; btnPrevLine.className = "sn_floatLeft sn_pointer"; } if (albumNavContainerRight == -albumNavContainerWidth) { btnNextLine.src = "http://media.supernova.com/images/buttons/next-line-grey.jpg"; btnNextLine.className = "sn_floatLeft"; }else{ btnNextLine.src = "http://media.supernova.com/images/buttons/next-line.jpg"; btnNextLine.className = "sn_floatLeft sn_pointer"; } } } // sets up the nav // must get an array to construct // args[ // nav icon width, // nav icon spacing, // selectedPhoto, // ] var navIconWidth=0, navIconSpace=0, navTotalWidth=0; var waitUptoDate=""; this.setupNav = function(args) { me.navIconWidth = args[0]; me.navIconSpace = args[1]; me.navTotalWidth = me.navIconWidth + me.navIconSpace; me.waitUptoDate=""; this.setNavButtonState(); } /* loadImage * Load an image into the photo viewer. * @param args [pictureID, sequenceNumber] * @author Tharsan Bhuvanendran */ this.loadPhoto = function(args) { // parse arguments var pictureID = args[0]; var sequenceNum = args[1]; //Get navBar and Picture Position + AlbumNav width var navBarPosition = document.getElementById("albumNavContainer").style.left; //get navBar left position navBarPosition = parseInt( navBarPosition.substring(0, navBarPosition.length-2) ); //delete "px" var photoPosition = document.getElementById("picture_" + sequenceNum).style.left; //get Picture left position photoPosition = parseInt( photoPosition.substring(0, photoPosition.length-2) ); //delete "px" var albumNavWidth = document.getElementById("albumNav").style.width; //get AlbumNav width albumNavWidth = parseInt( albumNavWidth.substring(0, albumNavWidth.length-2) ); //delete "px" //Test if we need to if( (navBarPosition + photoPosition) > albumNavWidth ) me.navSkipRight(1); else if( (navBarPosition + photoPosition) < 0 ) me.navSkipLeft(1); //update the picture var imageFileName = myListImageFiles[sequenceNum]; document.getElementById("pictureDisplay").src = imagesRootPath + imageFileName; //set the yellow cursor document.getElementById("currentImageBorder").style.left = document.getElementById("picture_" + sequenceNum).style.left; //set "Photo x od y" var countTxt='Photo '+(sequenceNum+1)+' of '+photoCount; document.getElementById("countDiv").innerHTML=countTxt; //set buttons selectedPhoto = sequenceNum; me.setNavButtonState(); //reload comment (need time +++) me.updateMyCommentBlock(pictureID, sequenceNum); //reload ad on a top (need time ++++++++) me.loadNewTopAd(); } this.loadNextPhoto = function() { if (selectedPhoto < (photoCount - 1)) { var pictureID = document.getElementById("picture_" + (selectedPhoto+1)).name.substring(8); me.reloadNav(); me.loadPhoto(new Array(pictureID, (selectedPhoto+1))); } } this.loadPrevPhoto = function() { var pictureID = document.getElementById("picture_" + (selectedPhoto-1)).name.substring(8); me.reloadNav(); me.loadPhoto(new Array(pictureID, (selectedPhoto-1))); } // navigates n pictures left this.navSkipLeft = function(n) { if(parseInt(document.getElementById("albumNavContainer").style.left) > (n*-me.navTotalWidth) ) // navigate bar should always have pictures n = parseInt(document.getElementById("albumNavContainer").style.left)/-me.navTotalWidth; me.scrollIt(n); me.setNavButtonState(); } // navigates n pictures right this.navSkipRight = function(n) { var albumNavContainerRight = parseInt(document.getElementById("albumNavContainer").style.left)-parseInt(document.getElementById("albumNav").style.width); var albumNavContainerWidth = -(parseInt(document.getElementById("albumNavContainer").style.width)); if(((albumNavContainerRight)+n*-me.navTotalWidth) < albumNavContainerWidth ) // navigate bar should always have pictures n=(albumNavContainerRight-albumNavContainerWidth)/me.navTotalWidth; n = 0 - n; me.scrollIt(n); me.setNavButtonState(); } // scrolls the given object, a given number of pixels in a given direction this.scrollIt = function(direction) { var obj = document.getElementById("albumNavContainer"); var moveTo_px = 0; if (direction > 0) moveTo_px = 48 * direction; else if (direction < 0) moveTo_px = 48 * direction; obj.style.left = parseInt(obj.style.left) + moveTo_px + "px"; } // To be certain we can see the yellow square this.reloadNav = function() { var albumNavWidth = parseInt(document.getElementById("albumNav").style.width); var albumNavContainerLeft = parseInt(document.getElementById("albumNavContainer").style.left); var albumNavContainerWidth = parseInt(document.getElementById("albumNavContainer").style.width); var yellowLeft = selectedPhoto*48; //To be sure AlbumNav is full... if(!((-albumNavContainerLeft<=(yellowLeft))&( (yellowLeft) < ((-albumNavContainerLeft)+albumNavWidth) ))) { if((selectedPhoto*48)>(albumNavContainerWidth-albumNavWidth)) document.getElementById("albumNavContainer").style.left=((-selectedPhoto+6)*48)+"px"; else document.getElementById("albumNavContainer").style.left=(-selectedPhoto*48)+"px"; } } //to load a new ad on a top this.loadNewTopAd = function() { // we need or we don't need to change the add //belowTop = 75; //=> the distance between the top of the web-site and the Internet Browser window top //if(this.whereIsTheTop() < belowTop) // document.getElementById("IframeAd").src = "http://optimizedby.rmxads.com/st?ad_type=iframe&ad_size=728x90§ion=184092"; } //to load new comments this.updateMyCommentBlock = function(pictureID, sequenceNum) { nojump = true; document.getElementById("cmntsContainer").innerHTML = ""; //Clear the old comments document.getElementById("cmntsContainer").style.display = "none"; document.getElementById("waitScreen").style.display = "block"; var ajaxObj=createXMLHttp(); ajaxObj.open("GET", "/App_Info/GetPictureComments3.aspx?p="+pictureID+"&isShow="+isShow+"&sequenceNum="+sequenceNum,true); ajaxObj.onreadystatechange = function() { if(ajaxObj.readyState == 4) { document.getElementById("cmntsContainer").style.display = "block"; document.getElementById("waitScreen").style.display = "none"; document.getElementById("cmntsContainer").innerHTML=ajaxObj.responseText; //Load the new ones. forceInit(); } } ajaxObj.send(null); } // to call the yellow window pop-up this.confirmDelete = function(pictureID) { document.toolkit.confirm('Are you sure you wish to delete this image?',document.pictureutils3.deletePhoto,pictureID); } // to delete picture [show picture and album picture ] this.deletePhoto = function(pictureID) { var ajaxObj=createXMLHttp(); ajaxObj.open("GET", "/App_Info/DeletePhoto3.aspx?p="+pictureID+"&isShow="+isShow,true); ajaxObj.onreadystatechange = function() { if(ajaxObj.readyState == 4) { window.location.reload(); } } ajaxObj.send(null); } // Those 2 below fonctions make for knowing the distance between the top of the web-site and the Internet Browser window top. this.whereIsTheTop = function() { return this.filterResults(window.pageYOffset ? window.pageYOffset : 0,document.documentElement ? document.documentElement.scrollTop : 0,document.body ? document.body.scrollTop : 0 ); } this.filterResults = function(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } } document.pictureutils3 = new SNPictureUtils();