
function SlideChangeCallback(newSlideNo) 
{
    // alert(newSlideNo);
    for (var i = 0; i <= 9; i++) 
    {
        var div = document.getElementById("chrimg" + i);
        if (div != null) 
        {
            div.style.backgroundImage = "url('/_structure/images/slide.png')";
        }
    }
    var div = document.getElementById("chrimg" + newSlideNo);
    div.style.backgroundImage = "url('/_structure/images/slidesel.png')";
}

function StickSlide(fld) {
    var slideNo = fld.id.substr(fld.id.length - 1, 1);
    //    alert(slideNo);
    ShowSlide(1, slideNo);
    StartOrStop(1, false);
}

function UnstickSlide() {
    StartOrStop(1, true);
}


function CheckRollover(e) {
    var div = document.getElementById("sldlinks");
    var x = FindPosX(div);

    var posx = 0;
    var posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX;
        posy = e.clientY;
    }


    var offsetX = posx - x - 30; //30 is padding

    var slideToShow = parseInt(offsetX / 32);
    var div = document.getElementById("chrimg" + slideToShow);
    if (div != null) {
        ShowSlide(1, slideToShow);
    }
}



function SelectTab_tabswitcher_z2_p1(id, totalrows, newtab)
{
    for (var i = 2; i < (totalrows + 2); i++)
    {
        document.getElementById("idx_z2_p" + i).style.display = "none";
    }

    document.getElementById("idx_z2_p" + (newtab + 2)).style.display = "block";
}

function SelectTab_tabswitcher_z2_p3(id, totalrows, newtab) 
{
    for (var i = 4; i < (totalrows + 4); i++) 
    {
        document.getElementById("idx_z2_p" + i).style.display = "none";
    }

    document.getElementById("idx_z2_p" + (newtab + 4)).style.display = "block";
}

function ToggleGiftAid(answer)
{
    var div = document.getElementById("giftaid");
    div.style.display = (answer == 0) ? "block" : "none";
 
    UpdateGADecAddress();
}

function UpdateGADecAddress()
{
    //Build name & address
    var theForm = document.frm5_fbdisplayform_form;
    var fname = theForm.frm5_fbdisplayform_question_22.value;
    var sname = theForm.frm5_fbdisplayform_question_23.value;
    var add1 = theForm.frm5_fbdisplayform_question_24.value;
    var add2 = theForm.frm5_fbdisplayform_question_25.value;
    var add3 = theForm.frm5_fbdisplayform_question_26.value;
    var town = theForm.frm5_fbdisplayform_question_27.value;
    var county = theForm.frm5_fbdisplayform_question_28.value;
    var pcode = theForm.frm5_fbdisplayform_question_29.value;

    var output = fname + ' ' + sname + '<br/>';
    output += AddIfPresent(add1);
    output += AddIfPresent(add2);
    output += AddIfPresent(add3);
    output += AddIfPresent(town);
    output += AddIfPresent(county);
    output += AddIfPresent(pcode);

    var dec = document.getElementById("giftaiddec");
    dec.innerHTML = output;
}

function AddIfPresent(text)
{
    if (text != '')
    {
        return (text + '<br/>');
    }
    else
    {
        return ('');
    }
}


function ToggleGiftAidDec(answer) 
{
    //var theForm = document.frm5_fbdisplayform_form;
    var div = document.getElementById("mygiftaid");
    div.style.display = (answer == 0) ? "block" : "none";
}
