function selGalleryChange() {
    var selGallery = document.getElementById("selGallery");
    LoadGallery(selGallery[selGallery.selectedIndex].value, 0)
}

function LoadGallery(gallery, imageIndex) {
    var fc = document.getElementById("flashcontent");

    // SIMPLEVIEWER CONFIGURATION OPTIONS
    // To use an option, uncomment it by removing the "//" at the start of the line
    // For a description of config options, go to: 
    // http://www.airtightinteractive.com/simpleviewer/options.html

    //fo.addVariable("xmlDataPath", "gallery.xml");
    //fo.addVariable("firstImageIndex", "5");	
    //fo.addVariable("langOpenImage", "Open Image in New Window");
    //fo.addVariable("langAbout", "About");	
    //fo.addVariable("preloaderColor", "0xFFFFFF");

     //Check for existing SWF
    if (isObject("gallery")) {

        //replace object/element with a new div
        replaceSwfWithEmptyDiv("gallery");
    }
    var params = {
      wmode: "transparent",
      bg_color: '#FFFFFF'
    };
    var flashvars = {};
    flashvars.firstImageIndex = imageIndex;
    flashvars.xmlDataPath = "/Portals/9/propertyDevelopment/" + gallery + "/gallery.xml";
    flashvars.preloaderColor = "0xFFFFFF"
    swfobject.embedSWF("/Portals/9/propertyDevelopment/viewer.swf", "gallery", "420", "340", "8", "#ffffff", flashvars, params);

 

}

//Support function: checks to see if target
//element is an object or embed element

function isObject(targetID) {

    var isFound = false;
    var el = document.getElementById(targetID);

    if (el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")) {

        isFound = true;

    }

    return isFound;
}

//Support function: creates an empty
//element to replace embedded SWF object

function replaceSwfWithEmptyDiv(targetID) {

    var el = document.getElementById(targetID);

    if (el) {

        var div = document.createElement("div");
        el.parentNode.insertBefore(div, el);

        //Remove the SWF
        swfobject.removeSWF(targetID);

        //Give the new DIV the old element's ID
        div.setAttribute("id", targetID);

    }

}
