
function showPic(picName, width, height) {
    imageURL = "images/" + picName;
    windowProps = "width=" + width + ",height=" + height + ",toolbar=0,location=0,status=0,titlebar=0,directories=0,menubar=0";
    window.open(imageURL, "popupPic", windowProps);
}

function calculate_giftaid()
{
    var donationField    = document.getElementById("giftaid_donation");
    var donationTaxField = document.getElementById("giftaid_donation_tax");
    var totalField       = document.getElementById("giftaid_total");

    var donation = donationField.value;
    var tax      = donationTaxField.value;
    var ourClaim =  Math.round((donation/(100-tax) * tax)*100)/100;
    var total = Math.round((Number(ourClaim) + Number(donation))*100)/100;
    totalField.innerHTML = "£" + total;
}

function clear_giftaid()
{
    var donationField      = document.getElementById("giftaid_donation");
    var donationTaxField   = document.getElementById("giftaid_donation_tax");
    var totalField         = document.getElementById("giftaid_total");
    donationField.value    = "0";
    donationTaxField.value = "22";
    totalField.innerHTML   = "£0";
}


function clear_news_months(month_id)
{
    for(var i=0; i<months.length; i++)
    {
        if( month_id != months[i] )
        {
            var month_title = document.getElementById( months[i] + "_title" );
            var month_title_class = month_title.className;
            var isLastMonth = month_title_class.substring(month_title_class.length-4, month_title_class.length);            
            if( isLastMonth == "last" )
            {
                month_title.style.borderBottomWidth = "1px";
            }            
            var month = document.getElementById( months[i] );            
            month.style.display = "none";
            var month_image_sign  = document.getElementById( months[i] + "_img_sign" );
            month_image_sign.src = "images/plus.gif";
            var month_image_arrow = document.getElementById( months[i] + "_img_arrow" );
            month_image_arrow.src = "images/arrow_right.gif";
        }
    }
}
function toggle_news_month(title_div, month_id)
{
    var title_class = title_div.className;
    var isLastMonth = title_class.substring(title_class.length-4, title_class.length);
    var month = document.getElementById( month_id );
    var month_image_sign  = document.getElementById( month_id + "_img_sign");
    var month_image_arrow = document.getElementById( month_id + "_img_arrow");
    if( month.style.display == "none" )
    {
        clear_news_months( month_id );
        month.style.display   = "block";
        month_image_sign.src  = "images/minus.gif";
        month_image_arrow.src = "images/arrow_down.gif";
        if( isLastMonth == "last" )
        {
            title_div.style.borderBottomWidth = "0px";
        }
    }
    else
    {
        month.style.display   = "none";
        month_image_sign.src  = "images/plus.gif";
        month_image_arrow.src = "images/arrow_right.gif";
        if( isLastMonth == "last" )
        {
            title_div.style.borderBottomWidth = "1px";
        }
    }
}

function clear_menu_suboptions(subop)
{
    for(var i=0; i<suboptions.length; i++)
    {
        if( subop != suboptions[i] )
        {
            var so = document.getElementById( suboptions[i] );
            so.style.display = "none";
        }
    }
}
function toggle_menu_suboption(subop)
{
    var menu_suboption = document.getElementById( subop );
    if( menu_suboption.style.display == "none" )
    {
        clear_menu_suboptions( subop );
        menu_suboption.style.display = "block";
    }
    else
    {
        menu_suboption.style.display = "none";
    }
}


function clear_subtexts(subtext)
{
    for(var i=0; i<subtexts.length; i++)
    {
        if( subtext != subtexts[i] )
        {
            var st = document.getElementById( subtexts[i] );
            st.style.display = "none";
            var st_link = document.getElementById( subtexts[i] + "_link");
            st_link.innerHTML = "(read more...)"
        }
    }
}
function toggle_subtext(subtext_id, subtext_intro)
{
    var subtext = document.getElementById( subtext_id );
    if( subtext.style.display == "none" )
    {
        clear_subtexts( subtext );
        subtext.style.display = "block";
        subtext_intro.innerHTML="(done)";
    }
    else
    {
        subtext.style.display = "none";
        subtext_intro.innerHTML="(read more...)";
    }
}


function add_highlight(item)
{
    item.style.backgroundColor="#CCFF99";
}
function remove_highlight(item)
{
    item.style.backgroundColor="white";
}

function add_highlight_with_image(item, image)
{
    var image_to_highlight = document.getElementById( image );
    image_to_highlight.src = "images/" + image + "_lime.jpg";
    item.style.backgroundColor="#CCFF99";
}
function remove_highlight_with_image(item, image)
{
    var image_to_highlight = document.getElementById( image );
    image_to_highlight.src = "images/" + image + ".jpg";
    item.style.backgroundColor="white";
}
    

