function popupwin(thehref, win, xwidth, yheight, attrib )
	{
	//figure out the center position
	var scrW = screen.availWidth;
	var scrH = screen.availHeight;
	if (xwidth > scrW)
		{
		pW = scrW - 10;
		}
	else
		{
		pW = xwidth;
		}
	if (yheight > scrH)
		{
		pH = scrH - 40;
		}
	else
		{
		pH = yheight;
		}
	scrX = (scrW - pW - 10) * .5;
	scrY = (scrH - pH - 30) * .5; 
	
	var windowatts = "width=" + xwidth + ",height=" + yheight + ",left=" + scrX + ",top=" + scrY + ",screenX=" + scrX + ",screenY=" + scrY;
  windowatts += "," + attrib;
	window.open( thehref, win, windowatts);
	return false;
	}
	
$(document).ready(function()
	{
		
	$("a.popup").click( function()
		{
			var address = this.href;
			popupwin(address, '', 700, 600, 'statusbar=1,status=1,toolbar=1,scrollbars=1,resizable=1,location=1,address=1,directories=1,menubar=1' );
			return false;
		});	

	$('#marketwatch').load( "stock_quote.php?action=incices");
	
	$('input#stock-lookup').click(function()
			{
			scrollOpen();
			return false;
			});
//	$("#closelink").click(function()
//			{
//			alert( "in handler" );
//			$('#quote').slideToggle("slow");
//			return false;
//			});
	});	

function scrollOpen()
	{
	ajax_url_param	= "action=single&q=" + $('input#symbol').val();
	$.ajax({	type: "POST",
						async: false,
						url: "stock_quote.php",
						data: ajax_url_param,
						success: function(html){$('#quote').html(html).fadeIn("slow");}
				});
	if( $('#quote').css("display").toLowerCase() != "block" )
		{
		$('#quote').slideToggle("slow");
		}

	}
