/*
dependencies:
	jquery.js (http://jquery.com/)
	jquery.dimensions-1.2.js (http://plugins.jquery.com/project/dimensions)
	jquery.cluetip.js (http://plugins.learningjquery.com/cluetip/)
*/
$(document).ready(function() {
	// see if any help links are defined
	if ($('a.help').cluetip)
	{
		/* set up help links */
		// BROKEN WINDOW - this is duplicated in the pricing form view
		// (services/spam_filtering/pricing_form) for when the form loads
		// as a popup. This should probably be abstracted into a function
		// that can be called from both places.
		$(document).ready(function() {
		    $('a.help').cluetip({
		        showTitle: false,
				activation: 'click',
				closeText: '<img src="/images/b_exit.png">',
		        width: 400,
				sticky: true
		    });
		});
		// set title and alt attribute on all help images
		$(document).ready(function() {
			$('img.help').each(function() {
				$(this).attr({title: "Help", alt: "Help"});
			});
		});
	}
});

/*  button helper code */
/* commented this out because it prevents button select via tab */
/*
$(document).ready( function() {
    blurButton($('input.fancyButton'));
    blurButton($('div').find('input.formButton'));
    blurButton($('div').find('input.cautionButton'));
});
function blurButton(buttonHandle)
{
    buttonHandle.focus( function() {
        $(this).blur();
    });
}
*/
$(document).ready( function() {
    var fdButtons = $('div').find('input.formButton');
    buttonActive(fdButtons, 'formButton', 'formButtonActive');
    var fyButtons = $('input.fancyButton');
    buttonActive(fyButtons, 'fancyButton', 'fancyButtonActive');
    var cnButtons = $('div').find('input.cautionButton');
    buttonActive(cnButtons, 'cautionButton', 'cautionButtonActive');
});
function buttonActive(buttonHandle, fromClass, toClass)
{
    if ($.browser.opera) { return; }
    buttonHandle.mousedown( function() {
        var wide = $(this).width();
        $(this).attr('width', wide + 14);
        $(this).attr('class', toClass);
    });
    buttonHandle.mouseup( function() {
        $(this).attr('class', fromClass);
    });
}





