function select_all(textbox) {
	textbox.focus();
	textbox.select();
}

$(document).ready(function() {

	$('.newsbar').gsnewsbar({search: ['loans, auto loan, mortgage loan'], horizontal: false, largeResultSet: false});

	$('#main_calc_nav li a').featureList({
		output : '#output li',
		transition_interval: 0,
		start_item : 0
	}); 
	$('#calc_1').click(function() {
		select_all($(this)); 
	});
	$('#calc_1a').click(function() {
		select_all($(this)); 
	});
	$('#calc_2').click(function() {
		select_all($(this)); 
	});
	$('#calc_2a').click(function() {
		select_all($(this)); 
	});
	$('#calc_3').click(function() {
		select_all($(this)); 
	});
	$('#calc_3a').click(function() {
		select_all($(this)); 
	});
	$('#calc_4').click(function() {
		select_all($(this)); 
	});	
	$('#calc_4a').click(function() {
		select_all($(this)); 
	});
	$('#calc_5').click(function() {
		select_all($(this)); 
	});
	$('#calc_5a').click(function() {
		select_all($(this)); 
	});
	var options = { 
		target:        '#cs_content',   // target element(s) to be updated with server response 
		beforeSubmit:  showRequest,  // pre-submit callback 
		success:       showResponse  // post-submit callback 
	};
	
	$('#cs_type').change(function() {
		$('#cs').submit();
	});
	$('#cs_size').change(function() {
		$('#cs').submit();
	});
	$('#cs_theme').change(function() {
		$('#cs').submit();
	});
	
	$('#cs').submit(function() { 
		$(this).ajaxSubmit(options);
	    return false; 
	}); 

});

function showRequest(formData, jqForm, options) { 

    var queryString = $.param(formData); 
 
 
    //alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    //alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
    //    '\n\nThe output div should have already been updated with the responseText.'); 
} 

