
// ****** start: misc ******

function printPage()
{
    if (window.print){window.print();}
}

function hide(element)
{
	document.getElementById(element).style.display = 'none';
	return;
}
function show(element)
{
	document.getElementById(element).style.display = 'block';
	return;		
}

// ****** end: misc ******


// *** start: popup links ***

function doPopups()
{

	if (document.getElementById('my_popup_link')) //example
	{
		var my_popup_link = document.getElementById('my_popup_link');
		var my_popup_link_Href = my_popup_link.getAttribute('href');
		my_popup_link.onclick = function()
		{
			return(popuplink(my_popup_link_Href, this, 600, 400, false));
		}
	}

}

// start: popup window
// usage: popuplink(['js-only url',] this[, w[, h[, scroll[, extras]]]])
// basic usage: <a href="popup.html" target="_blank" onclick="return(popuplink(this));">new pop</a>
// advanced usage: <a href="popup_nojs.html" target="_blank" onclick="return(popuplink('popup_yesjs.html', this, 200, 100, false));">new pop</a>
// site-wide defaults:
popup_w = 400;
popup_h = 300;
popup_scroll = true;
popup_extras = 'location=0,statusbar=0,menubar=0';
function popuplink() {
	var undef, i=0, args=popuplink.arguments;
	var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
	var target = args[i++].getAttribute('target') || '_blank';
	var w = args[i++];
	var h = args[i++];
	var s = (args[i]===undef) ? popup_scroll : args[i++];
	var features = 'width=' + (w || popup_w)
				 + ',height=' + (h || popup_h)
				 + ',scrollbars=' + (s ? 'yes,' : 'no,')
				 + (args[i] || popup_extras);
	var win = window.open(url, target, features);
	win.focus();
	return false;
}


function resetDropDown(dropDownIdArray)
{
    var a = new Array();
    for(i=0; i<dropDownIdArray.length; i++) { 
        dropDownId = dropDownIdArray[i];
	    if (document.forms[0].getElementById(dropDownId)) //example
	        document.getElementById(dropDownId).options[0].selected = 0;
	    else if (document.all)
	        document.all[dropDownId].options[0].selected = 0;
    }
}

//Event.observe(window, "load", doPopups);

// *** end: popup links ***


// watches selected radio and focuses related textbox
var setRadioInput = Class.create();
    setRadioInput.prototype = {
        initialize: function() {
        
            this.paymentRadios = $$("fieldset#payment_option span.payment_type input");  // grab all payment choice radio buttons
        
            for (i=0; i<this.paymentRadios.length; i++) { 
                if (this.paymentRadios[i].checked) { // set default radio/input association onload  
                    this._setDefaultRadio([i]);                    
                }
                this.paymentRadios[i].observe('click', this._clickedMonthlyRadio.bindAsEventListener(this));
            }
    },
    
    _clickedMonthlyRadio: function(e) {
        var el = Event.findElement(e, 'span');
        el.up('span').down('input.textbox').focus();
    },    
    _setDefaultRadio: function(item) {
        $$('fieldset#payment_option input.textbox')[item].focus();
        }
}



