//template 2 functions


function template2script() {
    var oSection = 'section'+ (inSection+1);
    var oSlide = 'slide' + (inSlide +1);
    console.log("function template2script(); oSection=" +oSection + "; oSlide=" +oSlide);
    
    var image1 = doContent[oSection][oSlide]['images']['image1'];
    var image2 = doContent[oSection][oSlide]['images']['image2'];
    var image3 = doContent[oSection][oSlide]['images']['image3'];
    var image4 = doContent[oSection][oSlide]['images']['image4'];
    $('#' + oSection+oSlide).append('<div id="' +oSection+oSlide+'image1">' +image1+'</div>');
    $('#' + oSection+oSlide).append('<div id="' +oSection+oSlide+'image2">' +image2+'</div>');
    $('#' + oSection+oSlide).append('<div id="' +oSection+oSlide+'image3">' +image3+'</div>');
    $('#' + oSection+oSlide).append('<div id="' +oSection+oSlide+'image4">' +image4+'</div>');
    $('#' + oSection+oSlide).append('<div class="control" id="' +oSection+oSlide+'uncover"></div>');
    $('#' + oSection + oSlide + 'uncover')
        .css({
            "position":"absolute",
            "display":"block",
            "width":"65px",
            "height":"65px",
            "top":"460px",
            "left":"31px",
            "background":" url(img/uncover.png) no-repeat 50% 50%",   
            "z-index": "2"
        })
        .bind('click', function(){ template2scriptShowImage(); });
}

var template2ImageShown = 1;
var uncoverPosition = 284;
function template2scriptShowImage() {
    console.log("function template2scriptShowImage()");
    var oSection = 'section'+ (inSection+1);
    var oSlide = 'slide' + (inSlide+1);
    $('#' + oSection + oSlide + 'uncover').animate(
	{'marginLeft' : uncoverPosition},
	500,
	function() {// Animation complete.
	}
    );
    if (template2ImageShown ==1) {
        $('#' + oSection+oSlide+'image1')
        .css({
            "position":"absolute",
            "top":"460px",
            "left":"-284px",
            "z-index": "2"
        });
        $('#' + oSection+oSlide+'image1').animate(
            {'marginLeft' : uncoverPosition+31},
            500,
            function() {// Animation complete.
            }
        );
    }
    if (template2ImageShown ==2) {
        $('#' + oSection+oSlide+'image2')
        .css({
            "position":"absolute",
            "top":"460px",
            "left":"-284px",
            "z-index": "3"
        });
        $('#' + oSection+oSlide+'image2').animate(
            {'marginLeft' : uncoverPosition+31},
            750,
            function() {// Animation complete.
            }
        );
    }
    if (template2ImageShown ==3) {
        $('#' + oSection+oSlide+'image3')
        .css({
            "position":"absolute",
            "top":"460px",
            "left":"-284px",
            "z-index": "4"
        });
        $('#' + oSection+oSlide+'image3').animate(
            {'marginLeft' : uncoverPosition+31},
            1000,
            function() {// Animation complete.
            }
        );
    }
    
    if (template2ImageShown ==4) {
        $('#' + oSection+oSlide+'image4')
        .css({
            "position":"absolute",
            "top":"460px",
            "left":"-284px",
            "z-index": "5"
        });
        $('#' + oSection+oSlide+'image4').animate(
            {'marginLeft' : uncoverPosition+31},
            1250,
            function() {// Animation complete.
                // remove the uncover control
                $('#' + oSection + oSlide + 'uncover').remove();
            }
        );
        
    }
    
    
        template2ImageShown++;
        console.log("template2ImageShown="+template2ImageShown)
        uncoverPosition = uncoverPosition +284;
}
