var s = window.parent; function open_website(url,title) { if (url) { s.display_dialog( 'url', 'http://' + url, title, 850); } } function opacity(id, opacStart, opacEnd, millisec, doaction) { var check_id = document.getElementById(id); if (check_id != null) { //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 + "','" + doaction + "')",(timer * speed)); timer++; } } else if(opacStart < opacEnd) { for(i = opacStart; i <= opacEnd; i++) { setTimeout("changeOpac(" + i + ",'" + id + "','" + doaction + "')",(timer * speed)); timer++; } } } } //change the opacity for different browsers function changeOpac(opacity, id, doaction) { var check_id = document.getElementById(id); try { var object = check_id.style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; if (opacity == 0 && doaction == 'remove') { var initial_div = document.getElementById('initial_allocation_pane'); var add_to = document.getElementById('allocation_pane'); add_to.removeChild(check_id); var div_prefix = 'added_'; var amount_divs = document.getElementsByTagName('DIV'); var i = 0; var count = 0; while (el = amount_divs.item(i++)) { if (el.id.substr(0,div_prefix.length) == div_prefix) { count++; } } if (count == 0) { initial_div.style.display = ''; } } } catch(err) { } } function collapse_expand(div_id, direction) { var divh = document.getElementById(div_id); var heightvar = divh.offsetHeight; var speed = Math.round(1000 / 100); var timer = 0; if (direction == 'shrink' && 0) { for (x=heightvar; x>=0; x--) { setTimeout("reduce_div(" + div_id + "," + x + ")",(timer * speed)); timer++; } } } function reduce_div(div_id,x) { if (x <= 0) { var divh = document.getElementById(div_id); divh.style.display = 'none'; } else { var check_id = document.getElementById(div_id); check_id.style.height = x + 'px'; } } function count_divs(div_prefix) { var allDIVS = document.getElementsByTagName('DIV'); var el, i = 0, howmany = 0; while (el = allDIVS.item(i++)) if (el.id.substr(0,div_prefix.length) == div_prefix) howmany++; return howmany; } function sum_allocations(div_prefix) { var allInputs = document.getElementsByTagName('INPUT'); var el, i = 0, subtotal = 0, empty_count = 0; var result_check = []; while (el = allInputs.item(i++)) { if (el.id.substr(0,div_prefix.length) == div_prefix) { if (el.value != parseInt(el.value)) { el.value = ''; empty_count++; } if (isNaN(parseInt(el.value)) || el.value == '' || el.value == '0') { subtotal += 0; empty_count++; } else { subtotal += parseInt(el.value); } } } result_check['empty'] = empty_count; result_check['total'] = subtotal; return result_check; } function display_totals(div_id) { var target_div = document.getElementById(div_id); var header_div = document.getElementById('allocation_header'); var charity_count = count_divs('added_'); var allocation = sum_allocations('amount_'); var sum_of_allocations = allocation['total']; var empty_allocations = allocation['empty']; var diff_amount = - sum_of_allocations; if (isNaN(diff_amount)) { diff_amount = 0; } var curr_status = ''; var curr_difference = Math.abs(diff_amount); if (charity_count == 0) { curr_status = 'Please add charities below to allocate your remaining $.'; } else { if (empty_allocations > 0) { curr_status = 'Every charity needs an allocation amount.'; } else { if (diff_amount < 0) { curr_status = 'Please remove $' + curr_difference + ' from the allocations below.'; } else if (diff_amount > 0) { curr_status = 'Please add $' + curr_difference + ' from the allocations below.'; } else if (diff_amount == 0) { curr_status = 'Perfect, you are done!'; } } } var overlib_msg = "'Click this button to allocate your remaining balance of $" + curr_difference + " evenly across your " + charity_count + " charities.',CAPTION,'ALLOCATE REMAINING $" + curr_difference + "'"; if (charity_count == 0) { overlib_msg = "'You must add at least one charity.',CAPTION,'NO CHARITIES ADDED',BGCOLOR,'#990000'"; } else { if (curr_difference == 0) { overlib_msg = "'You have no remaining balance left to allocate.',CAPTION,'NO BALANCE REMAINING',BGCOLOR,'#990000'"; } } header_div.innerHTML = '' + '' + ' ' + '' + '' + ' ' + '' + '
ALLOCATE $ TO THE CHARITIES
YOU HAVE ADDED BELOW.
' + curr_status + '
'; target_div.innerHTML = '' + '' + ' ' + ' ' + ' ' + '' + '' + ' ' + ' ' + '' + '' + ' ' + ' ' + '' + '
' + charity_count + ' CHARITIES ADDED
ALLOCATION TOTAL:$' + sum_of_allocations + '
TOTAL AMOUNT:$
REMAINING:$' + curr_difference + '
'; } function distribute_evenly(diff) { var div_prefix = 'amount_'; var allInputs = document.getElementsByTagName('INPUT'); var el; var i = 0; var subtotal = 0; var count = 0; var divided = 0; var whole_remainder = 0; var amount_fields = []; while (el = allInputs.item(i++)) { if (el.id.substr(0,div_prefix.length) == div_prefix) { count++; var field_value = returnNumber(el.value); var field_id = el.id; var info_array = [field_value, field_id]; amount_fields[count] = info_array; } } divided = parseInt(diff/count); whole_remainder = diff - divided * count; for (i=1;i<=count;i++) { a = amount_fields[i][0]; field = document.getElementById(amount_fields[i][1]); field.value = a + divided; } if (whole_remainder > 0) { for (i=1;i<=whole_remainder;i++) { field = document.getElementById(amount_fields[i][1]); field.value = returnNumber(field.value) + i; } } //alert('integer divided:' + divided + ' whole number remainder:' + whole_remainder); } function returnNumber(input_num) { numvar = Number(input_num.replace(/[^0-9-.]/g, "")); return numvar; } function isNumericKey(e) { var k = document.all ? e.keyCode : e.which; return ((k > 47 && k < 58) || k == 8 || k == 0); } function extractNumeric(str) { return str.replace(/\D/g,""); }