
var galleryLoader;
var selectedGallery = 0;
var showGallery = false;
var requestUri = location.href;
var re = /[\?&](ghash=(.*))/gi;
requestUri = requestUri.replace(re, '');
if(requestUri.indexOf('?') < 0) {
    requestUri = requestUri + '?';
} else {
    requestUri = requestUri + '&';
}
if (galleryLoader == undefined || selectedGallery == 1) {
    showGallery = true;
}
 showGallery = true;
var imageGalleryLeftPos       = 31;
var previewImgContainerHeight = 307;
var imageGalleryWidth         = 369;
var maxGalleryXPos            = 31;
var minGalleryXPos            = -1227;
var thumbnailsPosition        = 'H';
var scrollingSpeed            = 60;
var slideShowDelay            = 5000;
var ihost                     = '/pmt_common/images/gallery2/';
var ipath                     = '/pmt_common/d_images/unit_gallery/';
var Photos                    = new Array();
Photos[0] = new Array( ipath + 'image_7720.jpeg', ipath + 'thumbnail_7720.jpeg', "Waterfront Condo at Harbor Village", "Waterfront Condo at Harbor Village", "Waterfront Condo at Harbor Village", "400", "300");
Photos[1] = new Array( ipath + 'image_7727.jpeg', ipath + 'thumbnail_7727.jpeg', "Gas Fireplace", "Gas Fireplace", "Gas Fireplace", "400", "300");
Photos[2] = new Array( ipath + 'image_7722.jpeg', ipath + 'thumbnail_7722.jpeg', "Upstairs Bedroom with Queen Bed", "Upstairs Bedroom with Queen Bed", "Upstairs Bedroom with Queen Bed", "400", "300");
Photos[3] = new Array( ipath + 'image_7723.jpeg', ipath + 'thumbnail_7723.jpeg', "Waterfront Dining", "Waterfront Dining", "Waterfront Dining", "400", "300");
Photos[4] = new Array( ipath + 'image_7721.jpeg', ipath + 'thumbnail_7721.jpeg', "Fully furnished kitchen with breakfast bar", "Fully furnished kitchen with breakfast bar", "Fully furnished kitchen with breakfast bar", "377", "300");
Photos[5] = new Array( ipath + 'image_7740.jpeg', ipath + 'thumbnail_7740.jpeg', "Indoor Pool and Spa", "Indoor Pool and Spa", "Indoor Pool and Spa", "400", "300");
Photos[6] = new Array( ipath + 'image_7724.jpeg', ipath + 'thumbnail_7724.jpeg', "Lower Left Bedroom with Sofa Bed and TV/DVD", "Lower Left Bedroom with Sofa Bed and TV/DVD", "Lower Left Bedroom with Sofa Bed and TV/DVD", "400", "300");
Photos[7] = new Array( ipath + 'image_7725.jpeg', ipath + 'thumbnail_7725.jpeg', "Living Room with Fireplace", "Living Room with Fireplace", "Living Room with Fireplace", "400", "300");
Photos[8] = new Array( ipath + 'image_7726.jpeg', ipath + 'thumbnail_7726.jpeg', "Downstairs Full Bath with Shower/Tub", "Downstairs Full Bath with Shower/Tub", "Downstairs Full Bath with Shower/Tub", "400", "300");
Photos[9] = new Array( ipath + 'image_7741.jpeg', ipath + 'thumbnail_7741.jpeg', "Fitness Center", "Fitness Center", "Fitness Center", "400", "300");
Photos[10] = new Array( ipath + 'image_7728.jpeg', ipath + 'thumbnail_7728.jpeg', "Turn-a-bout at Harbor Village Entrance", "Turn-a-bout at Harbor Village Entrance", "Turn-a-bout at Harbor Village Entrance", "400", "300");
Photos[11] = new Array( ipath + 'image_7729.jpeg', ipath + 'thumbnail_7729.jpeg', "View from Loft", "View from Loft", "View from Loft", "400", "300");
Photos[12] = new Array( ipath + 'image_7730.jpeg', ipath + 'thumbnail_7730.jpeg', "Approach View", "Approach View", "Approach View", "400", "300");
Photos[13] = new Array( ipath + 'image_7731.jpeg', ipath + 'thumbnail_7731.jpeg', "Laundry in Condo", "Laundry in Condo", "Laundry in Condo", "400", "300");
Photos[14] = new Array( ipath + 'image_7732.jpeg', ipath + 'thumbnail_7732.jpeg', "View from Boat Slip", "View from Boat Slip", "View from Boat Slip", "400", "300");
Photos[15] = new Array( ipath + 'image_7733.jpeg', ipath + 'thumbnail_7733.jpeg', "Loft Bedroom", "Loft Bedroom", "Loft Bedroom", "400", "300");
Photos[16] = new Array( ipath + 'image_7735.jpeg', ipath + 'thumbnail_7735.jpeg', "Downstairs Bedroom View 2", "Downstairs Bedroom View 2", "Downstairs Bedroom View 2", "400", "300");
Photos[17] = new Array( ipath + 'image_7736.jpeg', ipath + 'thumbnail_7736.jpeg', "Private Patio with BBQ", "Private Patio with BBQ", "Private Patio with BBQ", "400", "300");
Photos[18] = new Array( ipath + 'image_7737.jpeg', ipath + 'thumbnail_7737.jpeg', "Upstairs Full Bath", "Upstairs Full Bath", "Upstairs Full Bath", "400", "300");
Photos[19] = new Array( ipath + 'image_7739.jpeg', ipath + 'thumbnail_7739.jpeg', "View from Patio", "View from Patio", "View from Patio", "400", "300");
var style_link = document.getElementById('gallery_css_2674');
if (style_link) {
    style_link.parentNode.removeChild(style_link);
}
style_link = document.createElement('link');
style_link.id = 'gallery_css_2674';
style_link.href = '/pmt_common/gallery2/unit_2674.css';
style_link.type = 'text/css';
style_link.rel = 'stylesheet';
var head = document.getElementsByTagName('HEAD')[0];
if (head) {
    head.appendChild(style_link);
} else {
    document.write('<link href="/pmt_common/gallery2/unit_2674.css" type="text/css" rel="stylesheet" />');
}
if (showGallery) {
    var preloadPhotos = new Array('' + ihost + 'b_next.gif', '' + ihost + 'b_next_over.gif', '' + ihost + 'b_pause.gif', '' + ihost + 'b_pause_over.gif', '' + ihost + 'b_play.gif', '' + ihost + 'b_play_over.gif', '' + ihost + 'b_previous.gif', '' + ihost + 'b_previous_over.gif', '' + ihost + 'b_scroll_down.gif', '' + ihost + 'b_scroll_down_over.gif', '' + ihost + 'b_scroll_up.gif', '' + ihost + 'b_scroll_up_over.gif', '' + ihost + 'b_scroll_left_over.gif', '' + ihost + 'b_scroll_right_over.gif', '' + ihost + 'title_bg.gif', '' + ipath + 'image_7720.jpeg', '' + ipath + 'thumbnail_7720.jpeg', '' + ipath + 'thumbnail_7727.jpeg');
    var preloadPhotosAfter = new Array('' + ipath + 'image_7727.jpeg', '' + ipath + 'image_7722.jpeg', '' + ipath + 'thumbnail_7722.jpeg', '' + ipath + 'image_7723.jpeg', '' + ipath + 'thumbnail_7723.jpeg', '' + ipath + 'image_7721.jpeg', '' + ipath + 'thumbnail_7721.jpeg', '' + ipath + 'image_7740.jpeg', '' + ipath + 'thumbnail_7740.jpeg', '' + ipath + 'image_7724.jpeg', '' + ipath + 'thumbnail_7724.jpeg', '' + ipath + 'image_7725.jpeg', '' + ipath + 'thumbnail_7725.jpeg', '' + ipath + 'image_7726.jpeg', '' + ipath + 'thumbnail_7726.jpeg', '' + ipath + 'image_7741.jpeg', '' + ipath + 'thumbnail_7741.jpeg', '' + ipath + 'image_7728.jpeg', '' + ipath + 'thumbnail_7728.jpeg', '' + ipath + 'image_7729.jpeg', '' + ipath + 'thumbnail_7729.jpeg', '' + ipath + 'image_7730.jpeg', '' + ipath + 'thumbnail_7730.jpeg', '' + ipath + 'image_7731.jpeg', '' + ipath + 'thumbnail_7731.jpeg', '' + ipath + 'image_7732.jpeg', '' + ipath + 'thumbnail_7732.jpeg', '' + ipath + 'image_7733.jpeg', '' + ipath + 'thumbnail_7733.jpeg', '' + ipath + 'image_7735.jpeg', '' + ipath + 'thumbnail_7735.jpeg', '' + ipath + 'image_7736.jpeg', '' + ipath + 'thumbnail_7736.jpeg', '' + ipath + 'image_7737.jpeg', '' + ipath + 'thumbnail_7737.jpeg', '' + ipath + 'image_7739.jpeg', '' + ipath + 'thumbnail_7739.jpeg');
} else {
    var preloadPhotos = new Array(ihost + 'title_bg.gif');
}
function drawGallery()
{
    igallery = document.getElementById("gallery_slideshow");
    if (showGallery) {
    preview_pane = document.createElement('div');
    preview_pane.setAttribute('id', "previewPane");
    gncontainer = document.createElement('div');
    gncontainer.setAttribute('id', "galleryTitle");
    gnscontainer = document.createElement('div');
    gnTitle = document.createTextNode( "Harbor Village Luxury Condo with Boat Slip - Home" );
    gnscontainer.appendChild(gnTitle);
    gncontainer.appendChild(gnscontainer);
    preview_pane.appendChild(gncontainer);
    preview_pane_img_div = document.createElement('div');
    preview_pane_img_div.setAttribute('id', 'gPreviewImgContainer');
    preview_pane_img = document.createElement('img');
    preview_pane_img.setAttribute('id', 'gPreviewImg');
    if (Photos.length > 0) {
        var margin_top = roundnumber( (previewImgContainerHeight/2 - 4) - (Photos[0][6]/2), 0);
        preview_pane_img.setAttribute('src', Photos[0][0]);
        preview_pane_img.setAttribute('width', Photos[0][5]);
        preview_pane_img.setAttribute('height', Photos[0][6]);
        preview_pane_img.setAttribute('style', 'margin-top: ' + margin_top + 'px;text-align: center;');
    }
    preview_pane_img_div.appendChild(preview_pane_img);
    preview_pane_center = document.createElement('center');
    preview_pane_center.appendChild(preview_pane_img_div);
    preview_pane.appendChild(preview_pane_center);
    itext = document.createElement('div');
    itext.setAttribute('id', "imgTextContainer");
    if (Photos.length > 0 && Photos[0][3] != '') {
        var txt = document.createTextNode(Photos[0][3]);
        itext.appendChild(txt);
    }
    preview_pane.appendChild(itext);
    sscontainer = document.createElement('div');
    sscontainer.setAttribute('id', "slideShowContainer");
    prev_img_a = document.createElement('a');
    prev_img_a.setAttribute('onclick', "prevPhoto();return false");
    prev_img_a.setAttribute('href', "javascript:prevPhoto();");
    prev_img_a.setAttribute('onfocus', "this.blur()");
    prev_img = document.createElement('img');
    prev_img.setAttribute('id', 'prevSlideCtrl');
    prev_img.setAttribute('src', ihost + 'b_previous.gif');
    prev_img.setAttribute('alt', 'Previous');
    prev_img.setAttribute('title', 'Previous');
    prev_img_a.appendChild(prev_img);
    sscontainer.appendChild(prev_img_a);
    stop_img_a = document.createElement('a');
    stop_img_a.setAttribute('onclick', "stopSlideShow();return false");
    stop_img_a.setAttribute('href', "javascript:stopSlideShow();");
    stop_img_a.setAttribute('id', "stopSlideCtrlA");
    stop_img_a.setAttribute('onfocus', "this.blur()");
    stop_img = document.createElement('img');
    stop_img.setAttribute('id', 'stopSlideCtrl');
    stop_img.setAttribute('src', ihost + 'b_pause.gif');
    stop_img.setAttribute('alt', 'Pause');
    stop_img.setAttribute('title', 'Pause');
    stop_img_a.appendChild(stop_img);
    sscontainer.appendChild(stop_img_a);
    start_img_a = document.createElement('a');
    start_img_a.setAttribute('onclick', "startSlideShow();return false");
    start_img_a.setAttribute('href', "javascript:startSlideShow();");
    start_img_a.setAttribute('id', "startSlideCtrlA");
    start_img_a.setAttribute('onfocus', "this.blur()");
    start_img = document.createElement('img');
    start_img.setAttribute('id', 'startSlideCtrl');
    start_img.setAttribute('src', ihost + 'b_play.gif');
    start_img.setAttribute('alt', 'Play');
    start_img.setAttribute('title', 'Play');
    start_img_a.appendChild(start_img);
    sscontainer.appendChild(start_img_a);
    next_img_a = document.createElement('a');
    next_img_a.setAttribute('onclick', "nextPhoto();return false");
    next_img_a.setAttribute('href', "javascript:nextPhoto();");
    next_img_a.setAttribute('onfocus', "this.blur()");
    next_img_a.setAttribute('class', "none");
    next_img_a.setAttribute('className', "none");
    next_img = document.createElement('img');
    next_img.setAttribute('id', 'nextSlideCtrl');
    next_img.setAttribute('src', ihost + 'b_next.gif');
    next_img.setAttribute('alt', 'Next');
    next_img.setAttribute('title', 'Next');
    next_img_a.appendChild(next_img);
    sscontainer.appendChild(next_img_a);
    preview_pane.appendChild(sscontainer);
    icontainer = document.createElement('div');
    icontainer.setAttribute('id', "galleryContainer");
    arr_left_img_div = document.createElement('div');
    arr_left_img_div.setAttribute('id', "arrow_left");
    arr_left_img = document.createElement('img');
    arr_left_img.setAttribute('src', ihost + "b_scroll_left.gif");
    arr_left_img.setAttribute('id', "arrow_left_image");
    arr_left_img.setAttribute('width', "31");
    arr_left_img.setAttribute('height', "58");
    arr_left_img_div.appendChild(arr_left_img);
    icontainer.appendChild(arr_left_img_div);
    arr_right_img_div = document.createElement('div');
    arr_right_img_div.setAttribute('id', "arrow_right");
    arr_right_img = document.createElement('img');
    arr_right_img.setAttribute('src', ihost + "b_scroll_right.gif");
    arr_right_img.setAttribute('id', "arrow_right_image");
    arr_right_img.setAttribute('width', "33");
    arr_right_img.setAttribute('height', "58");
    arr_right_img_div.appendChild(arr_right_img);
    icontainer.appendChild(arr_right_img_div);
    the_img_div = document.createElement('div');
    the_img_div.setAttribute('id', "theImages");
    the_img_div_container = document.createElement('div');
    the_img_div_container.setAttribute('style', "left: 31px;");
    for (i=0; i<Photos.length; i++) {
        prev_img_a = document.createElement('a');
        prev_img_a.setAttribute('onclick', "showPreview(Photos[" + i + "][0], " + i +", Photos[" + i + "][3], Photos[" + i + "][5], Photos[" + i + "][6]);return false");
        prev_img_a.setAttribute('href', "javascript:showPreview(Photos[" + i + "][0], " + i +", Photos[" + i + "][3], Photos[" + i + "][5], Photos[" + i + "][6]);");
        prev_img = document.createElement('img');
        prev_img.setAttribute('src', Photos[i][1]);
        prev_img.setAttribute('alt', Photos[i][4]);
        if (i == Photos.length) {
            prev_img.setAttribute('style', 'margin: 0px;');
        }
        prev_img_a.appendChild(prev_img);
        the_img_div_container.appendChild(prev_img_a);
    }
    slide_end_div = document.createElement('div');
    slide_end_div.setAttribute('id', "slideEnd");
    the_img_div_container.appendChild(slide_end_div);
    the_img_div.appendChild(the_img_div_container);
    icontainer.appendChild(the_img_div);
    igallery.appendChild(preview_pane);
    igallery.appendChild(icontainer);
}
}
window.ua = navigator.userAgent.toLowerCase();
var Safari = (ua.indexOf('safari') != -1)?true:false;

var slideShowInterval;
var currentPhoto           = 0;
var arrowImageHeight       = 31;	// Height of arrow image in pixels;
var previewImage           = false;
var previewImageParent     = false;
var slideSpeed             = 0;
var previewImagePane       = false;
var slideEndMarker         = false;
var galleryContainer       = false;
var disablePlay            = false;

function getTopPos(inputObj)
{
    var returnValue = inputObj.offsetTop;
    while((inputObj = inputObj.offsetParent) != null) {
        returnValue += inputObj.offsetTop;
    }
    return returnValue;
}

function getLeftPos(inputObj)
{
    var returnValue = inputObj.offsetLeft;
    while((inputObj = inputObj.offsetParent) != null) {
        returnValue += inputObj.offsetLeft;
    }
    return returnValue;
}

function roundnumber(n, d)
{
    n = n - 0;
    if (d == null) d = 2;
    var f = Math.pow(10, d);
    n += Math.pow(10, - (d + 1));
    n = Math.round(n * f) / f;
    n += Math.pow(10, - (d + 1));
    n += '';
    return d == 0 ? n.substring(0, n.indexOf('.')) :  n.substring(0, n.indexOf('.') + d + 1);
}

function showPreview(newSrc, idx, imageText, width, height)
{
    currentPhoto = idx;
    var previewImage = document.getElementById('gPreviewImg');
    var margin_top = roundnumber( (previewImgContainerHeight/2 - 4) - (height/2), 0);
    previewImage.src = newSrc;
    previewImage.width = width;
    previewImage.height = height;
    previewImage.setAttribute('style', 'margin-top: ' + margin_top + 'px;');
    if (imageText == 'undefined') {
        imageText = '';
    }
    var imgTextContainer = document.getElementById('imgTextContainer');
    if (imageText != '') {

    }
    imgTextContainer.innerHTML = imageText;
}

function initSlide(e)
{
    if(document.all) {
        e = event;
    }
    var id = this.id;

    if(this.src.indexOf('over') < 0) {
        this.src = this.src.replace('.gif','_over.gif');
    }

    if (Safari) {
      slideSpeed = 10;
    } else {
        if (thumbnailsPosition == 'V') {
            slideSpeed = e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop) - getTopPos(this);
            if(this.src.indexOf('down')>=0) {
                slideSpeed = (slideSpeed)*-1;
            } else {
                slideSpeed = arrowImageHeight - slideSpeed;
            }
            slideSpeed = Math.round(slideSpeed * 15 / arrowImageHeight);
        } else {
            if(this.id=='arrow_right_image') {
                slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5);
                slideSpeed = -1*slideSpeedMultiply;
                slideSpeed = Math.max(-10,slideSpeed);
            } else {
                slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5);
                slideSpeed = 1*slideSpeedMultiply;
                slideSpeed = Math.min(10,slideSpeed);
                if(slideSpeed<0) slideSpeed=10;
            }
        }
    }
}

function stopSlide()
{
    slideSpeed = 0;
    this.src = this.src.replace('_over', '');
}

function slidePreviewPane()
{
    if(slideSpeed != 0) {
        if (thumbnailsPosition == 'V') {
            var topPos = previewImagePane.style.top.replace(/[^\-0-9]/g,'')/1;

            if(slideSpeed<0 && slideEndMarker.offsetTop<(previewImageParent.offsetHeight - topPos)) {
                slideSpeed = 0;
            }
            topPos = topPos + slideSpeed;
            if(topPos>0) {
                topPos = 0;
            }
            previewImagePane.style.top = topPos + 'px';
        } else {
            var leftPos = previewImageParent.offsetLeft;
            leftPos = leftPos/1 + slideSpeed;
            if(leftPos > maxGalleryXPos){
                leftPos = maxGalleryXPos;
                slideSpeed = 0;
            }
            if(leftPos < minGalleryXPos){
                leftPos = minGalleryXPos;
                slideSpeed = 0;
            }
			previewImageParent.style.left = leftPos + 'px';
        }
    }
    setTimeout('slidePreviewPane()', scrollingSpeed);
}

function revealThumbnail()
{
    this.style.filter = 'alpha(opacity=100)';
    this.style.opacity = 1;
}

function hideThumbnail()
{
    this.style.filter = 'alpha(opacity=50)';
    this.style.opacity = 0.5;
}

function initGalleryScript()
{
    drawGallery();

    previewImageParent = document.getElementById('theImages');
    if( previewImageParent != null ) {
        galleryContainer  = document.getElementById('galleryContainer');

        previewImagePane = document.getElementById('theImages').getElementsByTagName('DIV')[0];
        previewImagePane.style.top = '0px';

        var images = previewImagePane.getElementsByTagName('IMG');
        for(var no=0;no<images.length;no++){
            images[no].onmouseover = revealThumbnail;
            images[no].onmouseout = hideThumbnail;
        }
        slideEndMarker = document.getElementById('slideEnd');

        if (thumbnailsPosition == 'V') {
            document.getElementById('arrow_up_image').onmousemove = initSlide;
            document.getElementById('arrow_up_image').onmouseout = stopSlide;

            document.getElementById('arrow_down_image').onmousemove = initSlide;
            document.getElementById('arrow_down_image').onmouseout = stopSlide;
        } else {
            document.getElementById('arrow_left_image').onmousemove = initSlide;
            document.getElementById('arrow_left_image').onmouseout = stopSlide;

            document.getElementById('arrow_right_image').onmousemove = initSlide;
            document.getElementById('arrow_right_image').onmouseout = stopSlide;
        }

        document.getElementById('prevSlideCtrl').onmousemove = initCtrlBtn;
        document.getElementById('prevSlideCtrl').onmouseout = stopCtrlBtn;

        document.getElementById('startSlideCtrl').onmousemove = initCtrlBtn;
        document.getElementById('startSlideCtrl').onmouseout = stopCtrlBtn;

        document.getElementById('stopSlideCtrl').onmousemove = initCtrlBtn;
        document.getElementById('stopSlideCtrl').onmouseout = stopCtrlBtn;

        document.getElementById('nextSlideCtrl').onmousemove = initCtrlBtn;
        document.getElementById('nextSlideCtrl').onmouseout = stopCtrlBtn;

        slidePreviewPane();
    }
}

/*** Slide show functions ***/
function initCtrlBtn()
{
    if (this.id != 'startSlideCtrl' || disablePlay == false) {
        if(this.src.indexOf('over') < 0) {
            this.src = this.src.replace('.gif', '_over.gif');
        }
    }
}
function stopCtrlBtn()
{
    if (this.id != 'startSlideCtrl' || disablePlay == false) {
        if(this.src.indexOf('over') >= 0) {
            this.src = this.src.replace('_over', '');
        }
    }
}
function nextPhoto()
{
    currentPhoto++;
    if (currentPhoto >= Photos.length) { currentPhoto = 0; }
    showPreview(Photos[currentPhoto][0], currentPhoto, Photos[currentPhoto][3], Photos[currentPhoto][5], Photos[currentPhoto][6]);
}

function prevPhoto()
{
    currentPhoto--;
    if (currentPhoto >= Photos.length || currentPhoto < 0) { currentPhoto = Photos.length-1; }
    showPreview(Photos[currentPhoto][0], currentPhoto, Photos[currentPhoto][3], Photos[currentPhoto][5], Photos[currentPhoto][6]);
}

function doSlideshow()
{
    nextPhoto( );
    slideShowInterval = setTimeout("doSlideshow()", slideShowDelay);
}

function startSlideShow(initpic)
{
    slideShowInterval = setTimeout("doSlideshow()", slideShowDelay);
    var elm = document.getElementById('startSlideCtrl');
    var elm_ctrl = document.getElementById('startSlideCtrlA');
    disablePlay = true;
    if(elm.src.indexOf('over') < 0) {
        elm.src = elm.src.replace('.gif', '_over.gif');
    }
}

function stopSlideShow()
{
    clearTimeout(slideShowInterval);
    var elm = document.getElementById('startSlideCtrl');
    var elm_ctrl = document.getElementById('startSlideCtrlA');
    disablePlay = false;
    if(elm.src.indexOf('over') >= 0) {
        elm.src = elm.src.replace('_over', '');
    }
}

function viodAction()
{

}

// Image Preloader
function ImagePreloader(images,callback)
{
	// store the callback
	this.callback = callback;

	// initialize internal state.
	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = new Array;

	// record the number of images.
	this.nImages = images.length;

	// for each image, call preload()
	for ( var i = 0; i < images.length; i++ )
		this.preload(images[i]);
}
ImagePreloader.prototype.preload = function(image)
{
	// create new Image object and add to array
	var oImage = new Image;
	this.aImages.push(oImage);

	// set up event handlers for the Image object
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;

	// assign pointer back to this.
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;
	oImage.source = image;

	// assign the .src property of the Image object
	oImage.src = image;
}
ImagePreloader.prototype.onComplete = function()
{
	this.nProcessed++;
	if ( this.nProcessed == this.nImages )
		this.callback(this.aImages);
}
ImagePreloader.prototype.onload = function()
{
	this.bLoaded = true;
	this.oImagePreloader.nLoaded++;
	this.oImagePreloader.onComplete();
}
ImagePreloader.prototype.onerror = function()
{
	this.bError = true;
	this.oImagePreloader.onComplete();
}
ImagePreloader.prototype.onabort = function()
{
	this.bAbort = true;
	this.oImagePreloader.onComplete();
}

if (galleryLoader == undefined) {
    document.write('<div id="gallery_slideshow"><\/div>');
    var giv = new ImagePreloader(preloadPhotos, initGalleryScript);
    var aiv = new ImagePreloader(preloadPhotosAfter, viodAction);
}
