function placeFocus() 
{
	if (document.forms.length > 0) 
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) 
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")) 
			{
				document.forms[0].elements[i].focus();
				break;
			}
		}
	}
}

function quickEnter(keypressed)
{
	var key;
	if (document.all)
	{ 
		key=window.event.keyCode;
		//alert (key);
	}
	else
	{ 
		key=keypressed.which;
};

	if (key==13)
	{ 
		//If I use this I add an extra cycle through the Page_Init and Load event handlers:
		//document.getElementById("_ctl0:ibtnGo").click();  
		document.Form1.submit();
	}
}

// Taken from the jQuery Validation plugin
$.format = function(source, params) {
	if ( arguments.length == 1 ) 
		return function() {
			var args = $.makeArray(arguments);
			args.unshift(source);
			return $.validator.format.apply( this, args );
		};
	if ( arguments.length > 2 && params.constructor != Array  ) {
		params = $.makeArray(arguments).slice(1);
	}
	if ( params.constructor != Array ) {
		params = [ params ];
	}
	$.each(params, function(i, n) {
		source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
	});
	return source;
};

function addPaginationLinks() {
	// The cursor object has all things to do with pagination
	var cursor = ocicSearch.cursor;
	var curPage = cursor.currentPageIndex; // check what page the app is on
	$('#googleresults').append('<div class="pager"></div>');
	if (cursor.pages.length > 1) {
		for (var i = 0; i < cursor.pages.length; i++) {
			var page = cursor.pages[i];
			if (curPage == i) { // if we are on the curPage, then don't make a link
				$('#googleresults > div.pager').append($.format('<span>{0}</span>', page.label));
			} else {
				$('#googleresults > div.pager').append($.format('<a href="{0}">{1}</a>', 'javascript:ocicSearch.gotoPage(' + i + ');', page.label));
			}
		}
	}
}

