window.addEvent("domready" , function(){

var myFx = new Fx.Slide('marathon_div');
myFx.hide();
$('marathon_block').addEvent('click',function() {
    
    myFx.toggle();
});
    
if ($('memorial_gift'))
{

    marathon=document.getElement("input[name=marathon]");
    marathon.addEvent('click', function(){
        if (marathon.checked) {
            document.getElement(".options").innerHTML="<label><input type='radio' name='amount_options' value='18'> $18 </label><label><input type='radio' name='amount_options' value='36'> $36 </label><label><input type='radio' name='amount_options' value='54'> $54 </label><label><input type='radio' name='amount_options' value='100'> $100 </label><label><input type='radio' name='amount_options' value='180'> $180 </label><label><input type='radio' name='amount_options' value='360'> $360 </label><label><input type='radio' name='amount_options' value='500'> $500 </label><label><input type='radio' name='amount_options' value='1000'> $1,000 </label><label><input type='radio' name='amount_options' value='5000'> $5,000 </label><label><input type='radio' name='amount_options' value='10000'> $10,000 </label><label><input type='radio' name='amount_options' value='25000'> $25,000 </label>";
            $("id_amount").value="";
        } else {
            document.getElement(".options").innerHTML="<label><input type='radio' name='amount_options' value='18'> $18: Helps buy dog food and other basic provisions</label><label><input type='radio' name='amount_options' value='36'> $36: Help feed a class of students for one day</label><label><input type='radio' name='amount_options' value='54'> $54: One day of puppy mobility training</label><label><input type='radio' name='amount_options' value='100'> $100: Surgical supplies for our clinic</label><label><input type='radio' name='amount_options' value='180'> $180: Purchase a leather harness</label><label><input type='radio' name='amount_options' value='360'> $360: Veterinary expense for one week</label><label><input type='radio' name='amount_options' value='500'> $500: SPONSOR A PUPPY</label><label><input type='radio' name='amount_options' value='1000'> $1,000: Annual cost of our Aftercare program</label><label><input type='radio' name='amount_options' value='5000'> $5,000: Annual kennel maintenance and supplies</label><label><input type='radio' name='amount_options' value='10000'> $10,000: One year supply of all dog medications</label><label><input type='radio' name='amount_options' value='25000'> $25,000: SPONSOR A PARTNERSHIP</label>";
            $("id_amount").value="";
        }
        
        options.getElements("input").addEvent("click" , function(ev){
            $("id_amount").value =ev.target.value;
        });
    });
    
    

    
    
    $("memorial_gift").setStyle("overflow","hidden").set("morph" , {"fps":200});
    
    $extend($("memorial_gift") , {"init_height":$("memorial_gift").getSize().y});
    
    if(!document.getElement("input[name=mem_gift]").checked)
        $("memorial_gift").setStyle("display", "none");
    
    document.getElement("input[name=mem_gift]").addEvent("click" , function(ev){
        if(ev.target.checked)
        {
            $("memorial_gift").setStyles({"display":"" , "height":0}).
                               set("morph",{"onComplete":$lambda(true)}).
                               morph({"height":$("memorial_gift").init_height});
        } else {
            $("memorial_gift").set("morph" , {"onComplete":function(){
                $("memorial_gift").setStyle("display","none");
            }}).morph({"height":0});
        }
    });
    
    
    var options = document.getElement(".options");
    
    $extend(options , {"init_height":options.getSize().y});
    
    options.setStyles({
        "display":"none",
        "overflow":"hidden"
    }).set("morph" , {"fps":200});
    
    $("id_amount").addEvent("focus", function(){
        if(options.getStyle("display") != "none") return;
        
        options.setStyles({"display":"" , "height":0}).
            set("morph" , {"onComplete":$lambda(true)}).
            morph({"height":options.init_height});
    }).addEvent("blur" , function(){
        options.set("morph" , {
            "onComplete":function(){
                options.setStyle("display","none");
            }
        }).morph({"height":0});
    });
    
    options.getElements("input").addEvent("click" , function(ev){
        $("id_amount").value =ev.target.value;
    });
    
    
    
    var recipt = document.getElement("input[name=receipt]");
    var recipt_from = document.getElement("select[name=recipt_src]");
    
    if(!recipt.checked)
    {
        recipt_from.disabled = true;
    }
    
    recipt.addEvent("click" , function(ev){
        recipt_from.disabled = !ev.target.checked;
    });

}    

  
  
});
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

