// JS For Program_info page

function popUpGiftOptions(forceSubmit){
	//var optdiv = $(strId);
	
	if(forceSubmit==true){
		$('options_form').submit();
		return false;
	}

	hideClass('options');

	if($('one_time').checked == true){
		$('one_time_box').show();
		$('one_time_amount').writeAttribute('name','amount');
		$('recurring_amount').writeAttribute('name','');
		selectIndex( $('recurring_amount'), 0 );
		$('recurring_amount').next().hide();
		$('txt_recurring').writeAttribute('name','');
		return false;
	}

	if($('recurring').checked == true){
		$('recurring_box').show();
		$('one_time_amount').writeAttribute('name','');
		selectIndex( $('one_time_amount'), 0 );
		$('one_time_amount').next().hide();
		$('txt_onetime').writeAttribute('name','');
		$('recurring_amount').writeAttribute('name','amount');
		return false;
	}

	return true;
}


// Cross-browser function to select an index from a select box (multiple or not)
function selectIndex(selectElement,index){
	var el = $(selectElement);

	for(var x=0; x < el.options.length; x++){
		if(index == x){
			try{
			$(el.options[x]).selected = true;
			} catch( e ) { ; }
		} else {
			try{
			$(el.options[x]).selected = false;
			} catch( e ) { ; }
		}
	}

	return false;
}

function getDolAmt(str){
	str = str.replace(/\D/g, "");
	return parseInt(str);
}


function showInstallmentChoices(amount)
{
	hideClass('options');
	var price = parseFloat(amount).toFixed(2);
	$('installment_choices_box').show();
	$('installment_1').checked = true;
	$('installment_amount').innerHTML = price;
	var install_price = price / 12;
	$('installment_breakdown_amount').innerHTML = install_price.toFixed(2);
	
	return true;
}

function showDedicationTextBox()
{
	hideClass('options');
	$('dedication_text').show();
}

function checkDedicationText(orig_str)
{
	if ($('dedication_text').value == orig_str){
		$('dedication_text').value = '';
	}
}