jQuery(document).ready(function(){
	jQuery.ajaxSetup ({
		cache: false
	}); 
	jQuery(function(){
    jQuery('.submit_btn').keydown(function(e){
        if (e.keyCode == 13) {
            jQuery(this).parents('form').submit();
            return false;
        }return false;
    });return false;
});
   //capture the return key
   
	jQuery("#form").submit(function() {   
		var loadUrl = "/wp-content/themes/bjg/stockgrab.php";
		var ajax_load = "<img src='/wp-content/themes/bjg/img/load.gif' alt='loading...' />";    
		var stockId = jQuery("input#stock").val();
		var exChange = jQuery("input#ex").attr('checked');
		//var dataString = 'stock=' + stockId + 'vse=' + ;  
		// alert (dataString);return false;  
		jQuery.post(
			"/wp-content/themes/bjg/stockgrab.php", 
			{ stocknum: stockId, ex: exChange },
			function(data){
				if (data) {
				jQuery('#stocks_table').append(data);
				jQuery('.main-aside').height((jQuery('.main-aside').height())+36);
				}
				else {showAlert();}
 });
		return false;
	});
	 function setEqualHeight(columns)  
  {  
  var tallestcolumn = 0;  
  columns.each(  
  function()  
  {  
  currentHeight = jQuery(this).height();  
  if(currentHeight > tallestcolumn)  
  {  
  tallestcolumn  = currentHeight;  
  }  
  }  
  );  
  columns.height(tallestcolumn);  
  }  
  setEqualHeight(jQuery(".main-aside"));  
   jQuery("#header_image").cycle({
  delay:-4000,
  fx: "fade",
  pause: 1,
  timeout:10000,
  speed: 4000
 });

}); 
   
function showAlert() {
	alert('Please enter a valid stock symbol.');
}


