function donate_now(){
    var valid = new Validation('frmDonation1', {onSubmit:false});
    var result = valid.validate();
    if(result){
        //var form_contents = '';
        //form_contents = $('frmDonation1' + stepnumber).serialize(true);
        ////alert(form_contents);
        //new Ajax.Request('/ajx_donation_handler.php', {
        //	method: 'post',
        //	parameters: form_contents,
        //	onSuccess: function(){
        //		
        //	}
        //});
        $('frmDonation1').submit();
    }
}
function sel_other_donation(){
//    if(!radioObj)
//		return;
//	var radioLength = radioObj.length;
//	if(radioLength == undefined) {
//		radioObj.checked = (radioObj.value == newValue.toString());
//		return;
//	}
//	for(var i = 0; i < radioLength; i++) {
//		radioObj[i].checked = false;
//		if(radioObj[i].value == newValue.toString()) {
//			radioObj[i].checked = true;
//		}
//	}
    var theradio = document.frmDonation1.optDonationAmt;
    theradio[3].checked = true;
}
function show_hpp(){
    var form_contents = '';
    var valid = new Validation('frmDonation1', {onSubmit:false});
    var result = valid.validate();
    if(result){
        form_contents = $('frmDonation1').serialize(true);
        new Ajax.Request('/ajx_donation_handler.php', {
            method: 'post',
            parameters: form_contents,
            onSuccess: function(ret){
                var jsonObj = eval('(' + ret.responseText + ')');
                donation_id = jsonObj.donation_id;
                donation_amt = jsonObj.donation_amt;
                cardholder = jsonObj.cardholder;
                $('rvar_donationid').value = donation_id;
                $('charge_total').value = donation_amt;
                $('cardholder').value = cardholder;
                $('frmDonation1').submit();
                $('frmDonation1').hide();
                
                var arrayPageSize = getPageSize();
                
                $('fade').show();
                $('fade').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px', opacity: 0.7 });
                $('hpp_iframe_container').show();
                
            }
        });
    }
}

function setup_provstate(thebox, prefix){
    $(prefix + 'provinces_container').hide();
    $(prefix + 'states_container').hide();
    $(prefix + 'other_provstate_container').hide();
    switch($(thebox.id).value){
        case 'CA':{
            $(prefix + 'provinces_container').show();
            $(prefix + 'provstate_label').innerHTML = 'Province:';
        }
        break;
        case 'US':{
            $(prefix + 'states_container').show();
            $(prefix + 'provstate_label').innerHTML = 'State:';
        }
        break;
        case '0':{
            $(prefix + 'provstate_label').innerHTML = 'Province/State:';
            $(prefix + 'provinces_container').hide();
            $(prefix + 'states_container').hide();
            $(prefix + 'other_provstate_container').hide();
        }
        break;
        default:{
            $(prefix + 'provstate_label').innerHTML = 'Province/State:';
            $(prefix + 'other_provstate_container').show();
        }
    }
    
}

function framebreak()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}

function getPageSize() {
	        
    var xScroll, yScroll;
   
   if (window.innerHeight && window.scrollMaxY) {	
       xScroll = window.innerWidth + window.scrollMaxX;
       yScroll = window.innerHeight + window.scrollMaxY;
   } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
       xScroll = document.body.scrollWidth;
       yScroll = document.body.scrollHeight;
   } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
       xScroll = document.body.offsetWidth;
       yScroll = document.body.offsetHeight;
   }
   
   var windowWidth, windowHeight;
   
   if (self.innerHeight) {	// all except Explorer
       if(document.documentElement.clientWidth){
           windowWidth = document.documentElement.clientWidth; 
       } else {
           windowWidth = self.innerWidth;
       }
       windowHeight = self.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
       windowWidth = document.documentElement.clientWidth;
       windowHeight = document.documentElement.clientHeight;
   } else if (document.body) { // other Explorers
       windowWidth = document.body.clientWidth;
       windowHeight = document.body.clientHeight;
   }	
   
   // for small pages with total height less then height of the viewport
   if(yScroll < windowHeight){
       pageHeight = windowHeight;
   } else { 
       pageHeight = yScroll;
   }

   // for small pages with total width less then width of the viewport
   if(xScroll < windowWidth){	
       pageWidth = xScroll;		
   } else {
       pageWidth = windowWidth;
   }

   return [pageWidth,pageHeight];
}