
var galleryLoader;
var selectedGallery = 0;
var showGallery_197 = false;
var requestUri_197 = location.href;
var re = /[\?&](ghash=(.*))/gi;
requestUri_197 = requestUri_197.replace(re, '');
if(requestUri_197.indexOf('?') < 0) {
    requestUri_197 = requestUri_197 + '?';
} else {
    requestUri_197 = requestUri_197 + '&';
}
if (galleryLoader == undefined || selectedGallery == 1) {
    showGallery_197 = true;
}
 showGallery_197 = true;
var imageGalleryLeftPos_197       = 31;
var previewImgContainerHeight_197 = 367;
var imageGalleryWidth_197         = 449;
var maxGalleryXPos_197            = 31;
var minGalleryXPos_197            = -403;
var thumbnailsPosition_197        = 'H';
var scrollingSpeed_197            = 60;
var slideShowDelay_197            = 10000;
var ihost_197                     = 'http://images.sonoranseacondo.com/';
var ipath_197                     = ihost_197 + '27/';
var Photos_197                    = new Array();
Photos_197[0] = new Array( ipath_197 + '5296.jpg', ipath_197 + 'thumbnail_5296.jpg', "IMG_4732.JPG", "View from one of the homes at Cholla Bay", "View from one of the homes at Cholla Bay", "480", "360");
Photos_197[1] = new Array( ipath_197 + '5297.jpg', ipath_197 + 'thumbnail_5297.jpg', "IMG_4737.JPG", "View from a home at Cholla Bay", "View from a home at Cholla Bay", "480", "360");
Photos_197[2] = new Array( ipath_197 + '5298.jpg', ipath_197 + 'thumbnail_5298.jpg', "IMG_4735.JPG", "Cholla Bay view into the bay", "Cholla Bay view into the bay", "480", "360");
Photos_197[3] = new Array( ipath_197 + '5299.jpg', ipath_197 + 'thumbnail_5299.jpg', "IMG_4731.JPG", "This is a house\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'s balcony view", "This is a house\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'s balcony view", "480", "360");
Photos_197[4] = new Array( ipath_197 + '5300.jpg', ipath_197 + 'thumbnail_5300.jpg', "IMG_4736.JPG", "View from a home at Cholla Bay", "View from a home at Cholla Bay", "480", "360");
Photos_197[5] = new Array( ipath_197 + '5370.jpg', ipath_197 + 'thumbnail_5370.jpg', "mex006cc_60cb.jpg", "Aerial of Cholla Bay", "Aerial of Cholla Bay", "465", "360");
Photos_197[6] = new Array( ipath_197 + '5371.jpg', ipath_197 + 'thumbnail_5371.jpg', "mex007 11-23-06cc_199cb.jpg", "Aerial of Cholla Bay", "Aerial of Cholla Bay", "465", "360");
Photos_197[7] = new Array( ipath_197 + '5372.jpg', ipath_197 + 'thumbnail_5372.jpg', "mex007 11-23-06cc_31cb.jpg", "Aerial of Cholla Bay", "Aerial of Cholla Bay", "465", "360");
Photos_197[8] = new Array( ipath_197 + '5373.jpg', ipath_197 + 'thumbnail_5373.jpg', "mex006cc_56cb.jpg", "Aerial of Cholla Bay", "Aerial of Cholla Bay", "465", "360");
if (showGallery_197) {
    var preloadPhotos_197 = new Array('' + ihost_197 + 'b_next.gif', '' + ihost_197 + 'b_next_over.gif', '' + ihost_197 + 'b_pause.gif', '' + ihost_197 + 'b_pause_over.gif', '' + ihost_197 + 'b_play.gif', '' + ihost_197 + 'b_play_over.gif', '' + ihost_197 + 'b_previous.gif', '' + ihost_197 + 'b_previous_over.gif', '' + ihost_197 + 'b_scroll_down.gif', '' + ihost_197 + 'b_scroll_down_over.gif', '' + ihost_197 + 'b_scroll_up.gif', '' + ihost_197 + 'b_scroll_up_over.gif', '' + ihost_197 + 'title_bg.gif', '' + ihost_197 + 'show_rental_details.gif', '' + ihost_197 + 'show_rental_details_over.gif', '' + ipath_197 + '5296.jpg', '' + ipath_197 + 'thumbnail_5296.jpg', '' + ipath_197 + 'thumbnail_5297.jpg');
    var preloadPhotos = new Array('' + ihost_197 + 'b_next.gif', '' + ihost_197 + 'b_next_over.gif', '' + ihost_197 + 'b_pause.gif', '' + ihost_197 + 'b_pause_over.gif', '' + ihost_197 + 'b_play.gif', '' + ihost_197 + 'b_play_over.gif', '' + ihost_197 + 'b_previous.gif', '' + ihost_197 + 'b_previous_over.gif', '' + ihost_197 + 'b_scroll_down.gif', '' + ihost_197 + 'b_scroll_down_over.gif', '' + ihost_197 + 'b_scroll_up.gif', '' + ihost_197 + 'b_scroll_up_over.gif', '' + ihost_197 + 'title_bg.gif', '' + ihost_197 + 'show_rental_details.gif', '' + ihost_197 + 'show_rental_details_over.gif', '' + ipath_197 + '5296.jpg', '' + ipath_197 + 'thumbnail_5296.jpg', '' + ipath_197 + 'thumbnail_5297.jpg');
    var preloadPhotosAfter_197 = new Array('' + ipath_197 + '5297.jpg', '' + ipath_197 + '5298.jpg', '' + ipath_197 + 'thumbnail_5298.jpg', '' + ipath_197 + '5299.jpg', '' + ipath_197 + 'thumbnail_5299.jpg', '' + ipath_197 + '5300.jpg', '' + ipath_197 + 'thumbnail_5300.jpg', '' + ipath_197 + '5370.jpg', '' + ipath_197 + 'thumbnail_5370.jpg', '' + ipath_197 + '5371.jpg', '' + ipath_197 + 'thumbnail_5371.jpg', '' + ipath_197 + '5372.jpg', '' + ipath_197 + 'thumbnail_5372.jpg', '' + ipath_197 + '5373.jpg', '' + ipath_197 + 'thumbnail_5373.jpg');
} else {
    var preloadPhotos_197 = new Array(ihost_197 + 'title_bg.gif');
    var preloadPhotos = new Array(ihost_197 + 'title_bg.gif');
}
function drawGallery_197()
{
    if (document.getElementById("gallery_slideshow_197") != null ) {
    igallery_197 = document.getElementById("gallery_slideshow_197");
    } else {
    igallery_197 = document.getElementById("gallery_slideshow");
    }
    if (showGallery_197) {
    preview_pane_197 = document.createElement('div');
    preview_pane_197.setAttribute('id', "previewPane_197");
    gncontainer_197 = document.createElement('div');
    gncontainer_197.setAttribute('id', "galleryTitle_197");
    gnscontainer_197 = document.createElement('div');
    gnTitle_197 = document.createTextNode( "Cholla Bay Gallery" );
    gnscontainer_197.appendChild(gnTitle_197);
    gncontainer_197.appendChild(gnscontainer_197);
    preview_pane_197.appendChild(gncontainer_197);
    preview_pane_img_div_197 = document.createElement('div');
    preview_pane_img_div_197.setAttribute('id', 'gPreviewImgContainer_197');
    preview_pane_img_197 = document.createElement('img');
    preview_pane_img_197.setAttribute('id', 'gPreviewImg_197');
    if (Photos_197.length > 0) {
        var margin_top = roundnumber_197( (previewImgContainerHeight_197/2 - 4) - (Photos_197[0][6]/2), 0);
        preview_pane_img_197.setAttribute('src', Photos_197[0][0]);
        preview_pane_img_197.setAttribute('width', Photos_197[0][5]);
        preview_pane_img_197.setAttribute('height', Photos_197[0][6]);
        preview_pane_img_197.setAttribute('style', 'margin-top: ' + margin_top + 'px;');
    }
    preview_pane_img_div_197.appendChild(preview_pane_img_197);
    preview_pane_197.appendChild(preview_pane_img_div_197);
    itext_197 = document.createElement('div');
    itext_197.setAttribute('id', "imgTextContainer_197");
    if (Photos_197.length > 0 && Photos_197[0][3] != '') {
        itext_197.innerHTML = Photos_197[0][3];
    }
    preview_pane_197.appendChild(itext_197);
    sscontainer_197 = document.createElement('div');
    sscontainer_197.setAttribute('id', "slideShowContainer_197");
    prev_img_a_197 = document.createElement('a');
    prev_img_a_197.setAttribute('onclick', "prevPhoto_197();return false");
    prev_img_a_197.setAttribute('href', "javascript:prevPhoto_197();");
    prev_img_a_197.setAttribute('onfocus', "this.blur()");
    prev_img_197 = document.createElement('img');
    prev_img_197.setAttribute('id', 'prevSlideCtrl_197');
    prev_img_197.setAttribute('src', ihost_197 + 'b_previous.gif');
    prev_img_197.setAttribute('alt', 'Previous');
    prev_img_197.setAttribute('title', 'Previous');
    prev_img_a_197.appendChild(prev_img_197);
    sscontainer_197.appendChild(prev_img_a_197);
    stop_img_a_197 = document.createElement('a');
    stop_img_a_197.setAttribute('onclick', "stopSlideShow_197();return false");
    stop_img_a_197.setAttribute('href', "javascript:stopSlideShow_197();");
    stop_img_a_197.setAttribute('id', "stopSlideCtrlA_197");
    stop_img_a_197.setAttribute('onfocus', "this.blur()");
    stop_img_197 = document.createElement('img');
    stop_img_197.setAttribute('id', 'stopSlideCtrl_197');
    stop_img_197.setAttribute('src', ihost_197 + 'b_pause.gif');
    stop_img_197.setAttribute('alt', 'Pause');
    stop_img_197.setAttribute('title', 'Pause');
    stop_img_a_197.appendChild(stop_img_197);
    sscontainer_197.appendChild(stop_img_a_197);
    start_img_a_197 = document.createElement('a');
    start_img_a_197.setAttribute('onclick', "startSlideShow_197();return false");
    start_img_a_197.setAttribute('href', "javascript:startSlideShow_197();");
    start_img_a_197.setAttribute('id', "startSlideCtrlA_197");
    start_img_a_197.setAttribute('onfocus', "this.blur()");
    start_img_197 = document.createElement('img');
    start_img_197.setAttribute('id', 'startSlideCtrl_197');
    start_img_197.setAttribute('src', ihost_197 + 'b_play.gif');
    start_img_197.setAttribute('alt', 'Play');
    start_img_197.setAttribute('title', 'Play');
    start_img_a_197.appendChild(start_img_197);
    sscontainer_197.appendChild(start_img_a_197);
    next_img_a_197 = document.createElement('a');
    next_img_a_197.setAttribute('onclick', "nextPhoto_197();return false");
    next_img_a_197.setAttribute('href', "javascript:nextPhoto_197();");
    next_img_a_197.setAttribute('onfocus', "this.blur()");
    next_img_a_197.setAttribute('class', "none_197");
    next_img_a_197.setAttribute('className', "none_197");
    next_img_197 = document.createElement('img');
    next_img_197.setAttribute('id', 'nextSlideCtrl_197');
    next_img_197.setAttribute('src', ihost_197 + 'b_next.gif');
    next_img_197.setAttribute('alt', 'Next');
    next_img_197.setAttribute('title', 'Next');
    next_img_a_197.appendChild(next_img_197);
    sscontainer_197.appendChild(next_img_a_197);
    preview_pane_197.appendChild(sscontainer_197);
    icontainer_197 = document.createElement('div');
    icontainer_197.setAttribute('id', "galleryContainer_197");
    arr_left_img_div_197 = document.createElement('div');
    arr_left_img_div_197.setAttribute('id', "arrow_left_197");
    arr_left_img_197 = document.createElement('img');
    arr_left_img_197.setAttribute('src', ihost_197 + "b_scroll_left.gif");
    arr_left_img_197.setAttribute('id', "arrow_left_image_197");
    arr_left_img_197.setAttribute('width', "31");
    arr_left_img_197.setAttribute('height', "69");
    arr_left_img_div_197.appendChild(arr_left_img_197);
    icontainer_197.appendChild(arr_left_img_div_197);
    arr_right_img_div_197 = document.createElement('div');
    arr_right_img_div_197.setAttribute('id', "arrow_right_197");
    arr_right_img_197 = document.createElement('img');
    arr_right_img_197.setAttribute('src', ihost_197 + "b_scroll_right.gif");
    arr_right_img_197.setAttribute('id', "arrow_right_image_197");
    arr_right_img_197.setAttribute('width', "33");
    arr_right_img_197.setAttribute('height', "69");
    arr_right_img_div_197.appendChild(arr_right_img_197);
    icontainer_197.appendChild(arr_right_img_div_197);
    the_img_div_197 = document.createElement('div');
    the_img_div_197.setAttribute('id', "theImages_197");
    the_img_div_container_197 = document.createElement('div');
    the_img_div_container_197.setAttribute('style', "left: 31px;");
    for (var i=0; i<Photos_197.length; i++) {
        prev_img_a_197 = document.createElement('a');
        prev_img_a_197.setAttribute('onclick', "showPreview_197(Photos_197[" + i + "][0], " + i +", Photos_197[" + i + "][3], Photos_197[" + i + "][5], Photos_197[" + i + "][6]);return false");
        prev_img_a_197.setAttribute('href', "javascript:showPreview_197(Photos_197[" + i + "][0], " + i +", Photos_197[" + i + "][3], Photos_197[" + i + "][5], Photos_197[" + i + "][6]);");
        prev_img_197 = document.createElement('img');
        prev_img_197.setAttribute('src', Photos_197[i][1]);
        prev_img_197.setAttribute('alt', Photos_197[i][4]);
        if (i == Photos_197.length) {
            prev_img_197.setAttribute('style', 'margin: 0px;');
        }
        prev_img_a_197.appendChild(prev_img_197);
        the_img_div_container_197.appendChild(prev_img_a_197);
    }
    slide_end_div_197 = document.createElement('div');
    slide_end_div_197.setAttribute('id', "slideEnd_197");
    the_img_div_container_197.appendChild(slide_end_div_197);
    the_img_div_197.appendChild(the_img_div_container_197);
    icontainer_197.appendChild(the_img_div_197);
    igallery_197.appendChild(preview_pane_197);
    igallery_197.appendChild(icontainer_197);
}
}
window.ua = navigator.userAgent.toLowerCase();
var Safari = (ua.indexOf('safari') != -1)?true:false;

var slideShowInterval_197;
var currentPhoto_197           = 0;
var arrowImageHeight_197       = 31;	// Height of arrow image in pixels;
var previewImage_197           = false;
var previewImageParent_197     = false;
var slideSpeed_197             = 0;
var previewImagePane_197       = false;
var slideEndMarker_197         = false;
var galleryContainer_197       = false;
var disablePlay_197            = false;

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

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

function roundnumber_197(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_197(newSrc, idx, imageText, width, height)
{
    currentPhoto_197 = idx;
    var previewImage_197 = document.getElementById('gPreviewImg_197');
    var margin_top_197 = roundnumber_197( (previewImgContainerHeight_197/2 - 4) - (height/2), 0);
    previewImage_197.src = newSrc;
    previewImage_197.width = width;
    previewImage_197.height = height;
    previewImage_197.setAttribute('style', 'margin-top: ' + margin_top_197 + 'px;');
    if (imageText == 'undefined') {
        imageText = '';
    }
    var imgTextContainer_197 = document.getElementById('imgTextContainer_197');
    if (imageText != '') {

    }
    imgTextContainer_197.innerHTML = imageText;
}

function initSlide_197(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_197 = 10;
    } else {
        if (thumbnailsPosition_197 == 'V') {
            slideSpeed_197 = e.clientY + Math.max(document.body.scrollTop, document.documentElement.scrollTop) - getTopPos_197(this);
            if(this.src.indexOf('down') >= 0) {
                slideSpeed_197 = (slideSpeed_197) * -1;
            } else {
                slideSpeed_197 = arrowImageHeight_197 - slideSpeed_197;
            }
            slideSpeed_197 = Math.round(slideSpeed_197 * 15 / arrowImageHeight_197);
        } else {
            if(this.id=='arrow_right_image_197') {
                slideSpeedMultiply_197 = Math.floor((e.clientX - this.offsetLeft) / 5);
                slideSpeed_197 = -1 * slideSpeedMultiply_197;
                slideSpeed_197 = Math.max(-10, slideSpeed_197);
            } else {
                slideSpeedMultiply_197 = 10 - Math.floor((e.clientX - this.offsetLeft) / 5);
                slideSpeed_197 = 1 * slideSpeedMultiply_197;
                slideSpeed_197 = Math.min(10, slideSpeed_197);
                if(slideSpeed_197 < 0) { slideSpeed_197 = 10; }
            }
        }
    }
}

function stopSlide_197()
{
    slideSpeed_197 = 0;
    this.src = this.src.replace('_over', '');
}

function slidePreviewPane_197()
{
    if(slideSpeed_197 != 0) {
        if (thumbnailsPosition_197 == 'V') {
            var topPos_197 = previewImagePane_197.style.top.replace(/[^\-0-9]/g,'')/1;

            if(slideSpeed_197 < 0 && slideEndMarker_197.offsetTop < (previewImageParent_197.offsetHeight - topPos_197)) {
                slideSpeed_197 = 0;
            }
            topPos_197 = topPos_197 + slideSpeed_197;
            if(topPos_197 > 0) {
                topPos_197 = 0;
            }
            previewImagePane_197.style.top = topPos_197 + 'px';
        } else {
            var leftPos_197 = previewImageParent_197.offsetLeft;
            leftPos_197 = leftPos_197/1 + slideSpeed_197;
            if(leftPos_197 > maxGalleryXPos_197) {
                leftPos_197 = maxGalleryXPos_197;
                slideSpeed_197 = 0;
            }
            if(leftPos_197 < minGalleryXPos_197){
                leftPos_197 = minGalleryXPos_197;
                slideSpeed_197 = 0;
            }
			previewImageParent_197.style.left = leftPos_197 + 'px';
        }
    }
    setTimeout('slidePreviewPane_197()', scrollingSpeed_197);
}

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

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

function initGalleryScript_197()
{
    drawGallery_197();

    previewImageParent_197 = document.getElementById('theImages_197');
    if( previewImageParent_197 != null ) {
        galleryContainer_197  = document.getElementById('galleryContainer_197');

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

        var images_197 = previewImagePane_197.getElementsByTagName('IMG');
        for(var no=0; no<images_197.length; no++) {
            images_197[no].onmouseover = revealThumbnail_197;
            images_197[no].onmouseout = hideThumbnail_197;
        }
        slideEndMarker_197 = document.getElementById('slideEnd_197');

        if (thumbnailsPosition_197 == 'V') {
            document.getElementById('arrow_up_image_197').onmousemove = initSlide_197;
            document.getElementById('arrow_up_image_197').onmouseout = stopSlide_197;

            document.getElementById('arrow_down_image_197').onmousemove = initSlide_197;
            document.getElementById('arrow_down_image_197').onmouseout = stopSlide_197;
        } else {
            document.getElementById('arrow_left_image_197').onmousemove = initSlide_197;
            document.getElementById('arrow_left_image_197').onmouseout = stopSlide_197;

            document.getElementById('arrow_right_image_197').onmousemove = initSlide_197;
            document.getElementById('arrow_right_image_197').onmouseout = stopSlide_197;
        }

        document.getElementById('prevSlideCtrl_197').onmousemove = initCtrlBtn_197;
        document.getElementById('prevSlideCtrl_197').onmouseout = stopCtrlBtn_197;

        document.getElementById('startSlideCtrl_197').onmousemove = initCtrlBtn_197;
        document.getElementById('startSlideCtrl_197').onmouseout = stopCtrlBtn_197;

        document.getElementById('stopSlideCtrl_197').onmousemove = initCtrlBtn_197;
        document.getElementById('stopSlideCtrl_197').onmouseout = stopCtrlBtn_197;

        document.getElementById('nextSlideCtrl_197').onmousemove = initCtrlBtn_197;
        document.getElementById('nextSlideCtrl_197').onmouseout = stopCtrlBtn_197;

        slidePreviewPane_197();
    }
}

function rprentals_button_197(rpr_el)
{
    if(rpr_el.src.indexOf('over') < 0) {
        rpr_el.src = rpr_el.src.replace('.gif', '_over.gif');
    } else {
        rpr_el.src = rpr_el.src.replace('_over.gif', '.gif');
    }
}

/*** Slide show functions ***/
function initCtrlBtn_197()
{
    if (this.id != 'startSlideCtrl_197' || disablePlay_197 == false) {
        if(this.src.indexOf('over') < 0) {
            this.src = this.src.replace('.gif', '_over.gif');
        }
    }
}
function stopCtrlBtn_197()
{
    if (this.id != 'startSlideCtrl_197' || disablePlay_197 == false) {
        if(this.src.indexOf('over') >= 0) {
            this.src = this.src.replace('_over', '');
        }
    }
}
function nextPhoto_197()
{
    currentPhoto_197++;
    if (currentPhoto_197 >= Photos_197.length) { currentPhoto_197 = 0; }
    showPreview_197(Photos_197[currentPhoto_197][0], currentPhoto_197, Photos_197[currentPhoto_197][3], Photos_197[currentPhoto_197][5], Photos_197[currentPhoto_197][6]);
}

function prevPhoto_197()
{
    currentPhoto_197--;
    if (currentPhoto_197 >= Photos_197.length || currentPhoto_197 < 0) { currentPhoto_197 = Photos_197.length-1; }
    showPreview_197(Photos_197[currentPhoto_197][0], currentPhoto_197, Photos_197[currentPhoto_197][3], Photos_197[currentPhoto_197][5], Photos_197[currentPhoto_197][6]);
}

function doSlideshow_197()
{
    nextPhoto_197( );
    slideShowInterval_197 = setTimeout("doSlideshow_197()", slideShowDelay_197);
}

function startSlideShow_197(initpic)
{
    slideShowInterval_197 = setTimeout("doSlideshow_197()", slideShowDelay_197);
    var elm = document.getElementById('startSlideCtrl_197');
    var elm_ctrl = document.getElementById('startSlideCtrlA_197');
    disablePlay_197 = true;
    if(elm.src.indexOf('over') < 0) {
        elm.src = elm.src.replace('.gif', '_over.gif');
    }
}

function stopSlideShow_197()
{
    clearTimeout(slideShowInterval_197);
    var elm = document.getElementById('startSlideCtrl_197');
    var elm_ctrl = document.getElementById('startSlideCtrlA_197');
    disablePlay_197 = false;
    if(elm.src.indexOf('over') >= 0) {
        elm.src = elm.src.replace('_over', '');
    }
}

function initGalleryScript()
{
    initGalleryScript_197();
}

function viodAction_197()
{

}

// Image Preloader
function ImagePreloader_197(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_197(images[i]);
}
ImagePreloader_197.prototype.preload_197 = 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_197.prototype.onload_197;
	oImage.onerror = ImagePreloader_197.prototype.onerror_197;
	oImage.onabort = ImagePreloader_197.prototype.onabort_197;

	// 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_197.prototype.onComplete_197 = function()
{
	this.nProcessed++;
	if ( this.nProcessed == this.nImages )
		this.callback(this.aImages);
}
ImagePreloader_197.prototype.onload_197 = function()
{
	this.bLoaded = true;
	this.oImagePreloader.nLoaded++;
	this.oImagePreloader.onComplete_197();
}
ImagePreloader_197.prototype.onerror_197 = function()
{
	this.bError = true;
	this.oImagePreloader.onComplete_197();
}
ImagePreloader_197.prototype.onabort_197 = function()
{
	this.bAbort = true;
	this.oImagePreloader.onComplete_197();
}

// 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();
}

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

  for ( var i = 0; i < images.length; i++ ) { preLdImg(images[i]); }
  this.callback(images);
}

//this part special for safari only
function preLdImg(oHref) {
  if( typeof( oHref ) != 'string' ) { return; }
  if( window.imgLdAr ) { for( var x = 2; x < window.imgLdAr.length; x++ ){ imgLdAr[x].onerror = null; imgLdAr[x].onload = null; } }
  window.imgLdAr = new Array(); window.imgCount = 0; window.hasLoadedImg = new Array();
  for( var x = 2; x < arguments.length; x++ ) {
    if( typeof( arguments[x] ) != 'string' || !document.images ) { self.location.href = oHref; }
    imgLdAr[x] = new Image();
    imgLdAr[x].onload = new Function( //write the function as a string. Allows me to put in the number of images
      'if( hasLoadedImg[imgLdAr['+x+'].src] ){ return; } hasLoadedImg[imgLdAr['+x+'].src] = true; window.imgCount++;'+
      ( arguments[1] ? ( arguments[1] + '( window.imgCount / ' + ( arguments.length - 2 ) + ' );' ) : '' )+
      "if( imgCount == " + ( arguments.length - 2 ) + " ) { self.location.href = '"+oHref+"'; }" );
    imgLdAr[x].onerror = new Function( "for(var x = 2;x<window.imgLdAr.length;x++){imgLdAr[x].onerror=null;imgLdAr[x].onload=null;}if( window.confirm( 'Pre-load error:\\n\\nThe following image failed to load:\\n'+this.src+'\\n\\nDo you want to jump to the next page without pre-loading images?' ) ) { self.location.href = '"+oHref+"'; }" );
    imgLdAr[x].src = arguments[x];
    if( imgLdAr[x].complete ) { imgLdAr[x].onload(); }
  }
}
*******/


if (galleryLoader == undefined) {
    document.write('<div id="gallery_slideshow_197"><\/div>');
    var giv = new ImagePreloader_197(preloadPhotos_197, initGalleryScript_197);
    var aiv = new ImagePreloader_197(preloadPhotosAfter_197, viodAction_197);
}
