function showSell() {
    var url = document.getElementById("mainWphoto").src;
    if(url.toLowerCase().match("mc_") != null){
	document.getElementById("sellLink").style.display = "block";
    }
    else {
	document.getElementById("sellLink").style.display = "none";
    }
}

function openSell() {
    var url = document.getElementById("mainWphoto").src;
    var urlString = url.split("/");
    var filename = urlString[urlString.length-1];
    if(filename.toLowerCase().match("mc_") != null){
        window.open("http://northjersey.mycapture.com/mycapture/lookup.asp?originalname="+filename+"&page=image", "Buy_Print").focus();
    }
        
    return false;
}

var slideShow=function(){
    var bxs,bxe,fxs,fxe,xp;
        
    var isIE = document.all ? true : false;
    var thumbs = null;
    var thumbsNumber = 0;
    var startY = 0;
    var endY = 0;
    var scrollTD = 3; 
    var scrollSize = 3; 
    var fadeTD = 5;
    var yp = 0;
        
    var thumbsBlock = document.getElementById("slidethumbs");
    if (thumbsBlock != null) {
        thumbs = thumbsBlock.getElementsByTagName('li'); 
    }
        
    return{
        init:function(){
            if (thumbsBlock != null) {
                document.onmousemove = this.pos; 
                startY = this.toppos(thumbsBlock); 
                endY = startY + thumbsBlock.offsetHeight;
                thumbsNumber = thumbs.length;
                for(var i = 0; i < thumbsNumber; i++){
                    var id = thumbs[i].value; 
                    thumbs[i].onclick = new Function("slideShow.getimg('" + id + "')");
                }
            }
        },
        scrl:function(d){
            if (thumbsBlock != null) {
                clearInterval(thumbsBlock.timer);
                var l=(d==-1)?0:(thumbs[thumbsNumber-1].offsetLeft-(thumbsBlock.parentNode.offsetWidth-thumbs[thumbsNumber-1].offsetWidth)+10)
                thumbsBlock.timer=setInterval(function(){slideShow.mv(d,l)}, scrollTD);
            }
        },
        mv:function(d,l){
            if (thumbsBlock != null) {
                thumbsBlock.style.left=thumbsBlock.style.left||'0px';
                var left=thumbsBlock.style.left.replace('px','');
                if(d == 1){
                    if(l - Math.abs(left) <= scrollSize){
                        if (l > 0) {
                            thumbsBlock.style.left='-'+l+'px';
                        }
                    } else{
                        thumbsBlock.style.left=left - scrollSize+'px'
                    }
                } else {
                    if(Math.abs(left)-l<=scrollSize){
                        thumbsBlock.style.left=l+'px';
                    }else{thumbsBlock.style.left=parseInt(left)+scrollSize+'px'}
                }
            }
        },
        fadeMainPhoto:function() {
            var mainPhoto = document.getElementById("mainWphoto");
            mainPhoto.av=0; 
            mainPhoto.style.filter='alpha(opacity=0)';
            mainPhoto.timer=setInterval(function(){slideShow.fdin(mainPhoto)},fadeTD);
            
        },
        getimg:function(id){
            var mainPhoto = document.getElementById("mainWphoto");
            mainPhoto.style.opacity=0;
            mainPhoto.src=slideimageUrls[id];
            document.getElementById('weddisc').innerHTML = slideimageCaptions[id];
        },
        fdin:function(i){
            if(i.complete){i.av=i.av+fadeTD; i.style.opacity=i.av/100; i.style.filter='alpha(opacity='+i.av+')'}
            if(i.av>=100){clearInterval(i.timer); ci=i}
        },
        lim:function(){
            if (thumbsBlock != null) {
                var taw = thumbsBlock.parentNode.offsetWidth; 
                var taa = taw/4; 
                bxs = slideShow.leftpos(thumbsBlock); 
                bxe = bxs + taa; 
                fxe = bxs + taw; 
                fxs = fxe - taa;
            }
        },
        pos:function(e){
            xp = isIE ? event.clientX + document.documentElement.scrollLeft : e.pageX; 
            yp = isIE ? event.clientY + document.documentElement.scrollTop : e.pageY;
            if(xp>bxs && xp < bxe && yp > startY && yp < endY) {
                slideShow.scrl(-1);
            }else if(xp > fxs && xp < fxe && yp > startY && yp < endY) {
                slideShow.scrl(1);
            }
            else {
                clearInterval(thumbsBlock.timer);
            }
        },
        leftpos:function(thumbs){
            var l=0;
            if(thumbs.offsetParent){
                while(1){
                    l+=thumbs.offsetLeft; 
                    if(!thumbs.offsetParent){
                        break;
                    }
                    thumbs=thumbs.offsetParent}
            }else if(thumbs.x){
                l+=thumbs.x;
            }
            return l;
        },
        toppos:function(thumbs){
            var p=0;
            if(thumbs.offsetParent){
                while(1){
                    p+=thumbs.offsetTop; 
                    if(!thumbs.offsetParent){
                        break;
                    }
                    thumbs=thumbs.offsetParent}
            }
            else if(thumbs.y){
                p+=thumbs.y;
            }
            return p;
        }
    };
}();

window.onload=function(){slideShow.init(); slideShow.lim()};
