slideShowURL = 'SlideShow_assets/SlideShow.html';       // parameter from openSlideShowWindow.js
slideShowNS4URL = 'SlideShow_assets/SlideShowNS4.html'; // parameter from openSlideShowWindow.js

slides = new Array();
slides[0] = new Slide('../Tihama_files/Ganous Mahawit Road 461.jpg', '536', '800', '');
slides[1] = new Slide('../Tihama_files/Ganous Mahawit Road 951.jpg', '536', '800', '');
slides[2] = new Slide('../Tihama_files/Kamis Bany Said 007.jpg', '536', '800', '');
slides[3] = new Slide('../Tihama_files/Bait Al Faqeh 779.jpg', '536', '800', '');
slides[4] = new Slide('../Tihama_files/Mahawiet Zuhra 249.jpg', '536', '800', '');
slides[5] = new Slide('../Tihama_files/Bait Al Faqeh 395.jpg', '536', '800', 'The Friday beautiful souq of Bayt Al-Faqih, one of the most beautiful Tihama Souqs in general in the area to the south of Hodeidah. I t was established in the early 18th century AD as a trading point for coffee which the caravans used to carry either to Hodeidah Seaport or Mokha. Also there were in the town the widest activity for the trade of the famed Yemeni Coffee Traders from Egypt, Syria, Constantinople, Morocco, Iran, India and Europe.');
slides[6] = new Slide('../Tihama_files/Bait Al Faqeh 105.jpg', '536', '800', 'There is a strong tradition of local markets.');
slides[7] = new Slide('../Tihama_files/MZZ_0261.jpg', '536', '800', '');
slides[8] = new Slide('../Tihama_files/hdfisport.jpg', '536', '800', 'The Al Hodeidah spectacular fishing port. The People of the Tihama mostly fish and farm, though some of them are herders.');
slides[9] = new Slide('../Tihama_files/thm.jpg', '536', '800', 'Tihami decorated boat');
slides[10] = new Slide('../Tihama_files/tihamboy.jpg', '536', '800', '');
slides[11] = new Slide('../Tihama_files/Tihamadanc.jpg', '536', '800', 'Tihama sword and drum dance');
slides[12] = new Slide('../Tihama_files/dmbch.jpg', '536', '800', 'Doum palm, Hyphaene thebaica, growing beside the new road between Al Faza beach and Al –Khawkha beach.');
slides[13] = new Slide('../Tihama_files/DSC_0063.jpg', '536', '800', 'The common type of Tihama building is the reed hut. They are rectangular in form, becoming dominantly circular in the midst of the Tihama plain. ');
slides[14] = new Slide('../Tihama_files/tihhut.jpg', '536', '800', 'Az Zuhra Hut. The building of the hut takes about twenty days. It begins with a skeleton made of branches and the boughs of trees, carefully bound together at the top.');
slides[15] = new Slide('../Tihama_files/DSC_0740.jpg', '536', '800', 'Doum palm, Hyphaene thebaica. The timber of the Doum palm which is strong, compact, and heavy, is used for many purposes: furniture, agriculture, and building. Its leaves have been widely used for basketry, ropes, and similar fibrous items.');
slides[16] = new Slide('../Tihama_files/DSC_0202.jpg', '536', '800', 'Their size can be as large as 6 meters across.  Tihama huts takes stones, mud, reeds, grasses and palms for their materials.\n');
slides[17] = new Slide('../Tihama_files/DSC_0407.jpg', '536', '800', 'The huts may look primitive from a distance, but if you walk inside the village and the houses you will be surprised of its interior beauty.');
slides[18] = new Slide('../Tihama_files/DSC_0395.jpg', '536', '800', 'The floors and walls are completely surfaced with mud all the way up to the domed ceiling. The walls are often painted with bright colors and lively motifs.\n');
slides[19] = new Slide('../Tihama_files/DSC_0465.jpg', '536', '800', 'Decoration is often applied to the ceilings, usually by the women, with highly coloured paints. The paintings represent the panoply of creation: animals, people, Islamic inscriptions and everyday objects, including cars, rockets and aeroplanes.');
slides[20] = new Slide('../Tihama_files/tihamgirl.jpg', '536', '800', 'There is an African flavour about the Tihama’s delightfully crafted mud and reed huts and the many unveiled, brighly dreesed women seen in Public.');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = true;

var smallTransparentGif = "";
function fixupIEPNG(strImageID, transparentGif) 
{
    smallTransparentGif = transparentGif;
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        var img = document.getElementById(strImageID);
        if (img)
        {
            var src = img.src;
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
            img.src = transparentGif;
            img.attachEvent("onpropertychange", imgPropertyChanged);
        }
    }
}

var windowsInternetExplorer = false;
var browserVersion = 0;
function detectBrowser()
{
    windowsInternetExplorer = false;
    var appVersion = navigator.appVersion;
    if ((appVersion.indexOf("MSIE") != -1) &&
        (appVersion.indexOf("Macintosh") == -1))
    {
        var temp = appVersion.split("MSIE");
        browserVersion = parseFloat(temp[1]);
        windowsInternetExplorer = true;
    }
}

var inImgPropertyChanged = false;
function imgPropertyChanged()
{
    if ((window.event.propertyName == "src") && (! inImgPropertyChanged))
    {
        inImgPropertyChanged = true;
        var el = window.event.srcElement;
        if (el.src != smallTransparentGif)
        {
            el.filters.item(0).src = el.src;
            el.src = smallTransparentGif;
        }
        inImgPropertyChanged = false;
    }
}

function fixupIEPNGBG(oBlock) 
{
    if (oBlock)
    {
        var currentBGImage = oBlock.currentStyle.backgroundImage;
        var currentBGRepeat = oBlock.currentStyle.backgroundRepeat;
        var urlStart = currentBGImage.indexOf('url(');
        var urlEnd = currentBGImage.indexOf(')', urlStart);
        var imageURL = currentBGImage.substring(urlStart + 4, urlEnd);

        if (imageURL.charAt(0) == '"')
        {
            imageURL = imageURL.substring(1);
        }
        
        if (imageURL.charAt(imageURL.length - 1) == '"')
        {
            imageURL = imageURL.substring(0, imageURL.length - 1);
        }

        var overrideRepeat = false;

        var filterStyle =
            "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
            imageURL +
            "', sizingMethod='crop');";

        if (RegExp("/C[0-9A-F]{8}.png$").exec(imageURL) != null)
        {
            filterStyle =
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
                imageURL +
                "', sizingMethod='scale');";

            overrideRepeat = true;
        }

        var backgroundImage = new Image();
        backgroundImage.src = imageURL;
        var tileWidth = backgroundImage.width;
        var tileHeight = backgroundImage.height; 
        
        var blockWidth = 0;
        var blockHeight = 0;
        if (oBlock.style.width)
        {
            blockWidth = parseInt(oBlock.style.width);
        }
        else
        {
            blockWidth = oBlock.offsetWidth;
        }
        if (oBlock.style.height)
        {
            blockHeight = parseInt(oBlock.style.height);
        }
        else
        {
            blockHeight = oBlock.offsetHeight;
        }

        if ((blockWidth == 0) || (blockHeight == 0))
        {
            return;
        }
        
        var wholeRows = 1;
        var wholeCols = 1;
        var extraHeight = 0;
        var extraWidth = 0;
        
        if ((currentBGRepeat.indexOf("no-repeat") != -1) ||
              ((tileWidth == 0) && (tileHeight == 0)) ||
              overrideRepeat)
        {
            tileWidth = blockWidth;
            tileHeight = blockHeight;

        }
        else if ((currentBGRepeat.indexOf("repeat-x") != -1) ||
              (tileHeight == 0))
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            tileHeight = blockHeight;

        }
        else if (currentBGRepeat.indexOf("repeat-y") != -1)
        {
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraHeight = blockHeight - (tileHeight * wholeRows);
            tileWidth = blockWidth;

        }
        else
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            extraHeight = blockHeight - (tileHeight * wholeRows);
        }
        
        var wrappedContent = document.createElement("div");
        wrappedContent.style.position = "relative";
        wrappedContent.style.zIndex = "1";
        wrappedContent.style.left = "0px";
        wrappedContent.style.top = "0px";
        if (!isNaN(parseInt(oBlock.style.width)))
        {
            wrappedContent.style.width = "" + blockWidth + "px";
        }
        if (!isNaN(parseInt(oBlock.style.height)))
        {
            wrappedContent.style.height = "" + blockHeight + "px";
        }
        var pngBGFixIsWrappedContentEmpty = true;
        while (oBlock.hasChildNodes())
        {
            if (oBlock.firstChild.nodeType == 3)
            {
                if (RegExp("^ *$").exec(oBlock.firstChild.data) == null)
                {
                    pngBGFixIsWrappedContentEmpty = false;
                }
            }
            else
            {
                pngBGFixIsWrappedContentEmpty = false;
            }
            wrappedContent.appendChild(oBlock.firstChild);
        }
        if (pngBGFixIsWrappedContentEmpty)
        {
            wrappedContent.style.lineHeight = "0px";
        }
        
        var newMarkup = "";
        for (var currentRow = 0; 
             currentRow < wholeRows; 
             currentRow++)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        
        if (extraHeight != 0)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        oBlock.innerHTML = newMarkup;

        oBlock.appendChild(wrappedContent);
        oBlock.style.background= "";
    }
}

function fixupAllIEPNGBGs()
{
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        try
        {
            var oDivNodes = document.getElementsByTagName('DIV');
            for (var iIndex=0; iIndex<oDivNodes.length; iIndex++)
            {
                var oNode = oDivNodes.item(iIndex);
                if (oNode.currentStyle &&
                    oNode.currentStyle.backgroundImage &&
                    (oNode.currentStyle.backgroundImage.indexOf('url(') != -1) &&
                    (oNode.currentStyle.backgroundImage.indexOf('.png")') != -1))
                {
                    fixupIEPNGBG(oNode);
                }
            }
        }
        catch (e)
        {
        }
    }
}

function onPageLoad()
{
    detectBrowser();
    fixupIEPNG("id1", "Tihama_files/transparent.gif");
    fixupIEPNG("id2", "Tihama_files/transparent.gif");
    fixupIEPNG("id3", "Tihama_files/transparent.gif");
    fixupIEPNG("id4", "Tihama_files/transparent.gif");
    fixupAllIEPNGBGs();
    fixupIEPNG("id5", "Tihama_files/transparent.gif");
    fixupIEPNG("id6", "Tihama_files/transparent.gif");
    fixupIEPNG("id7", "Tihama_files/transparent.gif");
    fixupIEPNG("id8", "Tihama_files/transparent.gif");
    fixupIEPNG("id9", "Tihama_files/transparent.gif");
    fixupIEPNG("id10", "Tihama_files/transparent.gif");
    fixupIEPNG("id11", "Tihama_files/transparent.gif");
    fixupIEPNG("id12", "Tihama_files/transparent.gif");
    fixupIEPNG("id13", "Tihama_files/transparent.gif");
    fixupIEPNG("id14", "Tihama_files/transparent.gif");
    fixupIEPNG("id15", "Tihama_files/transparent.gif");
    return true;
}

