function $( tag ) {
		return (typeof( tag ) == "object" ? tag : document.getElementById( tag ));
	}

function objdisplay( tag, display ) {
		obj = $( tag );
		if( typeof( obj ) == "object" ) {
			return (obj.style.display = (display ? 'block' : 'none'));
		} else {
			return false;
		}
	}

function setopacity( obj, opacity ) {
	if( get_msie() ) {
	//	objdisplay( obj, opacity>.5?1:0 );
		return false;
	}
	obj = (typeof( obj ) == "object" ? obj : $( obj ));
	obj.style.opacity = parseFloat( opacity );
	obj.style.filter = "alpha( opacity="+Math.round(parseInt(opacity*100))+" )";
}

function divdisplay( tag, display, duration ) {
		setopacity( tag, display ? 0 : 1 ); // setting fade value before fading
		objdisplay( tag, display ? 1 : 0 );
		var d = new Date();
		typeof( duration ) == "undefined" && (duration = 750); // in milliseconds
		setTimeout( 'fade(\"'+tag+'\", '+display+', '+duration+', '+d.getTime()+' );', 0 );
	}

function fade( tag, direction, duration, s ) {
		// fades out when direction is 0, in when direction is 1
		obj = $( tag );
		var d = new Date();
		ratio = (d.getTime() - s)/duration;
		if( ratio > 1 ) {
			// it ends here.
			setopacity( obj, direction );
			return;
		}
		direction || (ratio = 1 - ratio);
		setopacity( obj, ratio );
		setTimeout( 'fade( \"'+tag+'\", '+direction+', '+duration+', '+s+' );', 50 ); // option to build an array of 'ready' divs and then show all.. instead of 1 by 1
	}

function fadein( obj, duration ) {
	divdisplay( $( obj ).id, 1, duration );
}

function fadeout( obj, duration ) {
	divdisplay( $( obj ).id, 0, duration );
}

function showshadow( shadow, tag ) {
	// showshadow( shadowobj, obj )  displays shadowobj if and only if obj.imgpath's filename is 'empty.png'.
	// usage: 1.load page 2.run onLoad=showshadow(shadowobj, this.id) 
	var imgpath =  $( tag ).src.split( "/" );
	if( imgpath[imgpath.length-1] != "empty.png" ) {
		objdisplay( shadow, 1 );
	}
}

function screenheight( ) {
	return window.innerHeight != null ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : ( document.body != null ? document.body.clientHeight : null) );
}

function init_page( ) {
	// Init.
	(document.addEventListener) ? document.addEventListener("DOMContentLoaded", function() {finalise_page()}, false) : document.onreadystatechange = function() { if( document.readyState == "complete" ) { finalise_page(); } };
	
}

function finalise_page( ) {
	// called when the page has finished transferring & rendering
	var showphoto3 = ($('photocontainer3') && $('photo3')) ? 1 : 0;
	showphoto3 && displayextraphoto();
}

function displayextraphoto( ) {
	if( screenheight() > 660 ) {
		objdisplay( 'photocontainer3', 1 );
		objdisplay( 'photo3shadow', 1);
		objdisplay( 'photo3', 1 );
		setopacity( 'photo3', 0);
		setopacity( 'photo3shadow', 0);
		divdisplay( 'photo3', 1 );
		divdisplay( 'photo3shadow', 1 );
//		$( 'photo3' ).style.
		// if photo3 won't show up in IE6, it's probably skipping the width&height attribute. Set them manually to 145px.

		return true;
	}
	return false;
}

init_page();


