    var opacityOut = 100;
    var opacityIn = 0;
    var step = 10;
    var sdly = 0;
    var intervalTimer;
	var currentPhoto;
	var photosInGallery;
	var pageStart;
	var pageEnd;
	var pdelay= 10;
	
	function getobj(o){

	    if (document.getElementById)
	        return document.getElementById(o)
	    else if (document.all)
	        return document.all.o
	}
	    
    function isImageLoaded(img) {
        if (!img.complete) {
            return false;
        }

        if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
            return false;
        }

        return true;
    }
        
	function truebody(){
	  return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : 	document.body
	}

	var effects = {
	    fadeout : function (id) {
	        this.fadeOutLoop(id, opacityOut);
	    },
	    fadeOutLoop : function (id, opacityOut) {
	        var o = getobj(id);
	        if (opacityOut >= step) {
	            effects.setOpacity(o, opacityOut);
	            opacityOut -= step;
	            //setTimeout("effects.fadeOutLoop('" + id + "', " + opacityOut + ")", sdly);
	            effects.fadeOutLoop(id,opacityOut);
	        }else{
	            //setTimeout("effects.setOpacity(document.getElementById('"+id+"'), 0)",sdly);
	            effects.setOpacity(document.getElementById(id),0);
	     	}
	    },
	    fadein : function (id) {
	    	this.init();
	        this.fadeInLoop(id, opacityIn);
	    },
	    fadeInLoop : function (id, opacityIn) {
	        var o = getobj(id);
	        if (opacityIn < 100) {
	            effects.setOpacity(o, opacityIn);
	            opacityIn += step;
	            setTimeout("effects.fadeInLoop('" + id + "', " + opacityIn + ")", sdly);
	           	//effects.fadeInLoop(id,opacityIn);
	     	}else{
	            setTimeout("effects.setOpacity(document.getElementById('"+id+"'), 100)",sdly);
	            //effects.setOpacity(document.getElementById(id), 100);
	     	}
	    },
	    setOpacity : function (o, opacity) {
	        o.style.opacity = opacity / 100.0; // Mozilla (new)
	        o.style.filter = "alpha(style=0,opacity:" + opacity + ")"; // IE
	        //o.style.KHTMLOpacity = opacity; // Konqueror
	        //o.style.MozOpacity = opacity; // Mozilla (old)
	    },
	    init : function() {
	    	opacityOut = 100;
	    	opacityIn  = 0;
	    }
	}
    var windim = new Array();

    function getwinsize() {
        
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            windim[0] = window.innerWidth;
            windim[1] = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            windim[0] = document.documentElement.clientWidth;
            windim[1] = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            windim[0] = document.body.clientWidth;
            windim[1] = document.body.clientHeight;
        }
    }

function closePhoto(dnh)
{
    //effects.setOpacity(getobj('photo'),0);
    getobj('photo').style.display='none';
    if (!dnh) getobj('greybackdrop').style.display='none';
    getobj('image').src='/blank.gif';
}

function show(action,i)
{
	if (action == 'next') {
		i++;
		if (i <= pageEnd) {
			closePhoto(true);
			setTimeout("eval(getobj("+i+").href);",pdelay);
		}
	}
	else if (action == 'prev') {
		i--;
		if (i >= pageStart) {
			closePhoto(true);
			setTimeout("eval(getobj("+i+").href);",pdelay);
			//eval(getobj(i).href);
		}
	}
}

function showFoto(i,imgsrc,w,h,f) 
{
	currentPhoto = i;
	getwinsize();
	moveX = (windim[0] - (w+100)) / 2;
	moveY = (windim[1] - (h+100)) / 2;
	if(moveY <= 0) moveY = 10;
	getobj('fname').innerHTML = decodeURI(f);
	getobj('photo').style.left = moveX;
	getobj('photo').style.top = moveY;
	getobj('image').src = imgsrc;
	getobj('image').width = w;
	getobj('image').height = h;

	if (h+120 > windim[1]) {
		getobj('greybackdrop').style.height= h+170;
	}
	else if (windim[0] > windim[1] && w > h)
	{
		getobj('greybackdrop').style.height= windim[0];
	}
	else 
	{
		getobj('greybackdrop').style.height= windim[1];
	}
	
	getobj('greybackdrop').style.display='block';
	getobj('photo').style.display='block';
	//effects.setOpacity(getobj('photo'),100);

	if(i < pageEnd) {
		getobj('next').style.display='';
	}
	else{
		getobj('next').style.display='none';
	}
	if (i > pageStart) {
		getobj('prev').style.display='';
	}
	else {
		getobj('prev').style.display='none';
	}
	getobj('email').onclick = function() {
   								var emailaddress;
   								var u = document.location+'&i='+i;
   								var subject = decodeURI(f);
								emailaddress = prompt('Please enter the email address of the person you want to send a link to this photo:','<Enter an email address>');
								if(emailaddress != null){
									document.location='mailto:'+emailaddress+'?subject='+subject+' Photo on photography.stulevine.com&body='+encodeURIComponent(u);
								}
							}
	getobj('linkto').onclick = function() {
   								//u = encodeURI(document.location+'&i='+i);
   								u = document.location+'&i='+i;
   								alert(u);
							}
}

function swapImage(a,b){
	var a,b;
 	i1=document.getElementById(a);
 	i2=document.getElementById(b);
	s2=i2.src;
	i1.setAttribute('src',s2);
 	document.getElementById('ltxt').style.visibility = "hidden";
}

function emailphoto(u,subject){
   	var emailaddress;
   	var u;
   	var subject;
	emailaddress = prompt('Please enter the email address of the person you want to send a link to this photo:','<Enter an email address>');
	if(emailaddress != null)
	{
    	document.location='mailto:'+emailaddress+'?subject='+subject+'&body='+u;
	}
}

