﻿function Search(searchTerm) {
	if (searchTerm.length > 0) {
		PageMethods.GetSearchUrl(searchTerm, GetSearchUrl_CallBack);
	}
}

function GetSearchUrl_CallBack(r) {
	location.href = r;
}

function SearchButtonClick(textfieldId) {
	var textField = $('#' + textfieldId);
	if (textField != null) {
		Search(textField.val());
		alert(textField.valueOf());
		e.stopImmediatePropagation();
	}
}

function OnSearchKeyPress(e) {
	if (e.keyCode == 13 || e.which == 13) {
		Search($('#txtSearch').val());

		e.stopImmediatePropagation();
	}
}

$(function () { $('#txtSearch').keydown(OnSearchKeyPress); });
