﻿var index = 2;
var oInterval;
var totalImages = 4;
function StartSlideShow() {
    document.getElementById("ucMainPage_Image1").style.filter = 'alpha(opacity=100)';
    document.getElementById("ucMainPage_Image1").style.MozOpacity = '1';
    document.all("ucMainPage_Image5").src = document.all("ucMainPage_Image1").src;
    document.getElementById("DIVBookDescription").innerHTML = document.getElementById("ucMainPage_lbl1").value;
    
    //fixed interval.
    var tm = 7000;
    // call slideshow
    oInterval = window.setInterval("SlideShow()", tm);

}

function SlideShow() {
    if (index > totalImages) {
        index = 2;
    }

    if (index == 1) {
        opacity('ucMainPage_Image4', 100, 10, 1000);
        opacity('ucMainPage_Image1', 10, 100, 1000);
        index = index + 1;
    }
    else if (index == 2) {

        opacity('ucMainPage_Image1', 100, 10, 1000);
        opacity('ucMainPage_Image2', 10, 100, 1000);
        index = index + 1;
    }
    else if (index == 3) {
        opacity('ucMainPage_Image2', 100, 10, 1000);
        opacity('ucMainPage_Image3', 10, 100, 1000);
        index = index + 1;
    }
    else {
        opacity('ucMainPage_Image3', 100, 10, 1000);
        opacity('ucMainPage_Image4', 10, 100, 1000);
        index = 1;
    }

    var tempIndex;
    
    if (index == 1) {
        tempIndex = 4;
    }
    else {
        tempIndex = index - 1;
    }

    var imageControlName = "ucMainPage_Image" + tempIndex;
    var labelControlName = "ucMainPage_lbl" + tempIndex;
    
    document.all("ucMainPage_Image5").src = document.all(imageControlName).src;
    document.getElementById("DIVBookDescription").innerHTML = document.getElementById(labelControlName).value;

}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if (document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
}

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

    //make image transparent
    changeOpac(0, imageid);

    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for (i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')", (timer * speed));
        timer++;
    }
}

function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;

    //if the element has an opacity set, get it
    if (document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }

    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
}

var selectedDIVNumberTOP7 = 5;

function ShowHideProducts(divName,hiddenIndexValue) {
    divName = "ucMainPage_" + divName;
    
    document.getElementById("ucMainPage_ProductDivMusic").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivDVDs").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivBooks").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivABooks").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivBibles").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivSoftware").style.display = 'none';
    document.getElementById("ucMainPage_ProductDivGifts").style.display = 'none';
    
    document.getElementById(divName).style.display = 'block';
    
    selectedDIVNumberTOP7 = hiddenIndexValue;
    ResetAllValues(selectedDIVNumberTOP7);
}

function ResetAllValues(selectedDIVNumberTOP7) {

    if (selectedDIVNumberTOP7 == 1) {
        document.but1.src = '../images/gifts_b1_Over.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else if (selectedDIVNumberTOP7 == 2) {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2_Over.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else if (selectedDIVNumberTOP7 == 3) {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3_Over.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else if (selectedDIVNumberTOP7 == 4) {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4_Over.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else if (selectedDIVNumberTOP7 == 5) {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5_Over.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else if (selectedDIVNumberTOP7 == 6) {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6_Over.png';
        document.but7.src = '../images/gifts_b7.png';
    }
    else {
        document.but1.src = '../images/gifts_b1.png';
        document.but2.src = '../images/gifts_b2.png';
        document.but3.src = '../images/gifts_b3.png';
        document.but4.src = '../images/gifts_b4.png';
        document.but5.src = '../images/gifts_b5.png';
        document.but6.src = '../images/gifts_b6.png';
        document.but7.src = '../images/gifts_b7_Over.png';
    }
}

function DoOnMouseOver(mOverindex) {

    if (mOverindex == 1 && mOverindex != selectedDIVNumberTOP7) {
        document.but1.src = '../images/gifts_b1_Over.png'
    }
    else if (mOverindex == 2 && mOverindex != selectedDIVNumberTOP7) {
        document.but2.src = '../images/gifts_b2_Over.png'
    }
    else if (mOverindex == 3 && mOverindex != selectedDIVNumberTOP7) {
        document.but3.src = '../images/gifts_b3_Over.png'
    }
    else if (mOverindex == 4 && mOverindex != selectedDIVNumberTOP7) {
        document.but4.src = '../images/gifts_b4_Over.png'
    }
    else if (mOverindex == 5 && mOverindex != selectedDIVNumberTOP7) {
        document.but5.src = '../images/gifts_b5_Over.png'
    }
    else if (mOverindex == 6 && mOverindex != selectedDIVNumberTOP7) {
        document.but6.src = '../images/gifts_b6_Over.png'
    }
    else if (mOverindex == 7 && mOverindex != selectedDIVNumberTOP7) {
        document.but7.src = '../images/gifts_b7_Over.png'
    }
    else {
        // Do Nothing
    }
}

function DoOnMouseOut(mOutindex) {

    if (mOutindex == 1 && mOutindex != selectedDIVNumberTOP7) {
        document.but1.src = '../images/gifts_b1.png'
    }
    else if (mOutindex == 2 && mOutindex != selectedDIVNumberTOP7) {
        document.but2.src = '../images/gifts_b2.png'
    }
    else if (mOutindex == 3 && mOutindex != selectedDIVNumberTOP7) {
        document.but3.src = '../images/gifts_b3.png'
    }
    else if (mOutindex == 4 && mOutindex != selectedDIVNumberTOP7) {
        document.but4.src = '../images/gifts_b4.png'
    }
    else if (mOutindex == 5 && mOutindex != selectedDIVNumberTOP7) {
        document.but5.src = '../images/gifts_b5.png'
    }
    else if (mOutindex == 6 && mOutindex != selectedDIVNumberTOP7) {
        document.but6.src = '../images/gifts_b6.png'
    }
    else if (mOutindex == 7 && mOutindex != selectedDIVNumberTOP7) {
        document.but7.src = '../images/gifts_b7.png'
    }
    else {
        // Do Nothing
    }
}

