﻿var ancCountryChic = new Array();
var ancRTK = new Array();
var ancTRG = new Array();

function preLoadGalleryImages() {
    var _imageList1 = new Array();
    var imageType = preLoadGalleryImages.arguments[0];
    for (x = 0; x < preLoadGalleryImages.arguments.length; x++) {
        _imageList1[x] = preLoadGalleryImages.arguments[x];
    }
    var _imageList = new Array;
    _imageList = _imageList1.slice(1);
    //alert(_imageList.length);
    var _created = 0;
    for (i = 0; i < _imageList.length; i = i + 2) {
        //alert("start1");
        if (imageType == "cc") {
            //alert("start" + _created.toString());

            ancCountryChic[_created] = document.createElement('a');
            ancCountryChic[_created].href = "javascript:ShowGalleryImage('img/Theme/" + imageType + "/Main/" + imageType + _imageList[i] + ".jpg','" + _imageList[i + 1] + "')";
            //alert(ancCountryChic[_created].href);
            ancCountryChic[_created].rel = "thumbnail";
            ancCountryChic[_created].title = "thumb id " + imageType + " image " + _imageList[i];
            var imgLink = new Image();
            //alert('createimage' + x);
            imgLink.src = 'img/Theme/' + imageType + '/Thumb/' + imageType + _imageList[i] + ".jpg";
            imgLink.style.width = "60px";
            imgLink.style.height = "60px";
            ancCountryChic[_created].appendChild(imgLink);
            ancCountryChic[_created].appendChild(document.createTextNode(' '));
            //alert('createdimage' + _created.toString());
            _created++;
        }
        if (imageType == "rtk") {
            //alert("start" + _created.toString());

            ancRTK[_created] = document.createElement('a');
            ancRTK[_created].href = "javascript:ShowGalleryImage('img/Theme/" + imageType + "/Main/" + imageType + _imageList[i] + ".jpg','" + _imageList[i + 1] + "')";
            //alert(ancCountryChic[_created].href);
            ancRTK[_created].rel = "thumbnail";
            ancRTK[_created].title = "thumb id " + imageType + " image " + _imageList[i];
            var imgLink = new Image();
            //alert('createimage' + x);
            imgLink.src = 'img/Theme/' + imageType + '/Thumb/' + imageType + _imageList[i] + ".jpg";
            imgLink.style.width = "60px";
            imgLink.style.height = "60px";
            ancRTK[_created].appendChild(imgLink);
            ancRTK[_created].appendChild(document.createTextNode(' '));
            //alert('createdimage' + _created.toString());
            _created++;
        }
        if (imageType == "trg") {
            //alert("start" + _created.toString());

            ancTRG[_created] = document.createElement('a');
            ancTRG[_created].href = "javascript:ShowGalleryImage('img/Theme/" + imageType + "/Main/" + imageType + _imageList[i] + ".jpg','" + _imageList[i + 1] + "')";
            //alert(ancCountryChic[_created].href);
            ancTRG[_created].rel = "thumbnail";
            ancTRG[_created].title = "thumb id " + imageType + " image " + _imageList[i];
            var imgLink = new Image();
            //alert('createimage' + x);
            imgLink.src = 'img/Theme/' + imageType + '/Thumb/' + imageType + _imageList[i] + ".jpg";
            imgLink.style.width = "60px";
            imgLink.style.height = "60px";
            ancTRG[_created].appendChild(imgLink);
            ancTRG[_created].appendChild(document.createTextNode(' '));
            //alert('createdimage' + _created.toString());
            _created++;
        }
    } //for loop end
}

function addThumbs(GallaryID) {
    var gallaryDIV = document.getElementById('thumbs');
    var ccDIV = document.getElementById('thumbsPictures');

    gallaryDIV.removeChild(ccDIV);
    //remove other thumb divs here
    //add the relevant div back in
    var thumbDiv = document.createElement('thumbsPictures');
    thumbDiv.id = "thumbsPictures";

    if (GallaryID == "cc") {
        document.getElementById('galleryText').innerHTML = 'Country Chic Gallery';
        for (x = 0; x < ancCountryChic.length - 0; x++) {
            thumbDiv.appendChild(ancCountryChic[x]);
        }
    }
    if (GallaryID == "rtk") {
        document.getElementById('galleryText').innerHTML = 'Rock the Kasbah Gallery' ;
        for (x = 0; x < ancRTK.length - 0; x++) {
            thumbDiv.appendChild(ancRTK[x]);
        }
    }
    if (GallaryID == "trg") {
        document.getElementById('galleryText').innerHTML = 'Rose Garden Gallery' ;
        for (x = 0; x < ancTRG.length - 0; x++) {
            thumbDiv.appendChild(ancTRG[x]);
        }
    }
    gallaryDIV.appendChild(thumbDiv);
    document.imgGalleryDisplay.style.visibility = 'hidden';
}

function ShowGalleryImage(filename, sizeOfFile) {
    document.imgGalleryDisplay.src = "";
    document.imgGalleryDisplay.alt = "Please wait loading image";

        if (sizeOfFile == 'h') 
        {document.imgGalleryDisplay.style.width = '85%';
        document.imgGalleryDisplay.style.height = '85%';}
    else    
        {document.imgGalleryDisplay.style.width = '45%';
       document.imgGalleryDisplay.style.height = '85%';}
    

    document.imgGalleryDisplay.src = filename;
    document.imgGalleryDisplay.style.visibility = 'visible';
}




