
/**
 * @author Neon Thi Zero
 */
var destination = "/uploads/js/infoTools/Gallery01/";
var imgGalType_ = "default";
//var imgGalType_ = "milkbox";
var imgGalSkin_ = "black";
var bgCol_ = "#000";
var useSlider_ = true;
var useResize_ = true;
var readyToInit = true;
//var mooToolsBgColour = "white";
if(zoomPageURL == null){
	var zoomPageURL = "";
}


if (imageArray == null || imageArray.length == 0) {
    readyToInit = false;
    alert("Error: could not load images...");
  /*  var imageArray = new Array();
    imageArray[0] = new Array(4);
    imageArray[0][0] = 0;
    imageArray[0][1] = destination + "IMG_193.jpg"//SRC small
    imageArray[0][2] = destination + "IMG_193.jpg"
    imageArray[0][3] = "Image 1" //title
    imageArray[0][4] = "762131923"//Notes
    imageArray[1] = new Array(4);
    imageArray[1][0] = 0;
    imageArray[1][1] = destination + "IMG_194.jpg"//SRC small
    imageArray[1][2] = destination + "IMG_194.jpg"
    imageArray[1][3] = "Image 2"
    imageArray[1][4] = "tryetgfkld"
    imageArray[2] = new Array(4);
    imageArray[2][0] = 0;
    imageArray[2][1] = destination + "IMG_195.jpg"//SRC small
    imageArray[2][2] = destination + "IMG_195.jpg"
    imageArray[2][3] = "Image 3"
    imageArray[2][4] = "....."
    imageArray[3] = new Array(4);
    imageArray[3][0] = 0;
    imageArray[3][1] = destination + "IMG_196.jpg"//SRC small
    imageArray[3][2] = destination + "IMG_196.jpg"
    imageArray[3][3] = "Image 4"
    imageArray[3][4] = "fgsfdgdf"
    imageArray[4] = new Array(4);
    imageArray[4][0] = 0;
    imageArray[4][1] = destination + "IMG_197.jpg"//SRC small
    imageArray[4][2] = destination + "IMG_197.jpg"
    imageArray[4][3] = "Image 5"
    imageArray[4][4] = "asdasdasd"
    */
}else if (imageArray.length <= 2) {
    useSlider_ = false;
    useResize_ = false;
    //alert("This tool requires atleast 3 images on the selected gallery to function properly... Reducing functionality to work with the given images...")
}
//var gallerySkin = "white";
//document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/uploads/js/FloatingDiv/floatingDiv.css\">");
//document.write("<script type=\"text/javascript\" src=\"/uploads/shared/js/FloatingDiv/floatingDiv.js\"></script>");

try {
    if (mooToolsBgColour == "white") {
        imgGalSkin_ = "white";
        bgCol_ = "#fff";
    }
} 
catch (e) {

}

if (imgGalSkin_ == "black") {
    document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + destination + "MooFlow.css\" />");
}
else 
    if (imgGalSkin_ == "white") {
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + destination + "MooFlowWhite.css\" />");
        
    }
    else {
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + destination + "MooFlow.css\" />");
        
        
    }



document.write("<script type=\"text/javascript\" src=\"" + destination + "mootools-1.2-core.js\"></script> ");
document.write("<script type=\"text/javascript\" src=\"" + destination + "mootools-1.2-more.js\"></script>");
document.write("<script type=\"text/javascript\" src=\"" + destination + "MooFlow.js\"></script>");


if (imgGalType_ == "default") {
    document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + destination + "MooFlowViewer.css\" />");
    document.write("<script type=\"text/javascript\" src=\"" + destination + "MooFlowViewer.js\"></script>");
}
else 
    if (imgGalType_ == "milkbox") {
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + destination + "milkbox.css\" />");
        document.write("<script type=\"text/javascript\" src=\"" + destination + "milkbox.js\"></script>");
        
    }


document.write("<div id=\"MooFlow\"></div>");

function initImgSetup(){
if(readyToInit){
    str = "";
    if (imgGalType_ == "default") {
    
        for (i = 0; i < imageArray.length; i++) {
            if (imageArray[i][3] == "") {
                imageArray[i][3] = " ";
            }
            //str += "<a href=\"" + imageArray[i][2] + "\" rel=\"image\"><img src=\"" + imageArray[i][1] + "\" title=\"" + imageArray[i][3] + "\" alt=\"" + imageArray[i][4] + "\" /></a>";
            str += "<a href=\"" + zoomPageURL + imageArray[i][0] + "\" rel=\"link\"><img src=\"" + imageArray[i][1] + "\" title=\"" + imageArray[i][3] + "\" " + " /></a>";
            
        }
        
    }
    else 
        if (imgGalType_ == "milkbox") {
            if (imageArray[i][4] == "") {
                imageArray[i][4] = " ";
            }
            if (imageArray[i][3] == "") {
                imageArray[i][3] = " ";
            }
            for (i = 0; i < imageArray.length; i++) {
                str += "<a href=\"" + imageArray[i][2] + "\" ><img src=\"" + imageArray[i][1] + "\" title=\"" + imageArray[i][3] + "\" alt=\"" + imageArray[i][4] + "\" /></a>";
            //str += "<a href=\"" + imageArray[i][2] + "\"><img src=\"" + imageArray[i][1] + "\" title=\"" + imageArray[i][3] + "\" " + " /></a>";
            
            }
            
            
        }
    str += "";
    document.getElementById("MooFlow").innerHTML = str;
    if (imgGalType_ == "default") {
    
        var myMooFlowPage = {
        
            start: function(){
                var mf = new MooFlow($('MooFlow'), {
                    bgColor: bgCol_,
                    useSlider: useSlider_,
                    useAutoPlay: true,
                    useCaption: true,
                    useResize: useResize_,
                    useMouseWheel: true,
                    useKeyInput: true,
                    useViewer: true
                });
                
                mf.attachViewer();
                
                $$('.loadremote').addEvent('click', function(){
                    mf.loadHTML(this.get('href'), this.get('rel'));
                    return false;
                });
                
            }
            
        };
    }
    else 
        if (imgGalType_ == "milkbox") {
        
            var myMooFlowPage = {
            
                start: function(){
                    var mf = new MooFlow($('MooFlow'), {
                        bgColor: bgCol_,
                        useSlider: useSlider_,
                        useAutoPlay: true,
                        useCaption: true,
                        useResize: useResize_,
                        useMouseWheel: true,
                        useKeyInput: true,
                        useViewer: true,
                        onClickView: function(obj){
                            Milkbox.showThisImage(obj.href, obj.title + ' - ' + obj.alt);
                        }
                    });
                    
                    
                }
                
            };
        }
    
    window.addEvent('domready', myMooFlowPage.start);
    }
}

window.onload = initImgSetup;
