function CatalogSearch( pSearchTextBoxId, pAppUrl )
{   
    var searchTextBox = document.getElementById(pSearchTextBoxId);
    var searchText = trim(searchTextBox.value);
    var searchUrl = pAppUrl + "&query=" + escape(searchText);
    window.location.href = searchUrl;
}

function CatalogFolderSelect( pFolderId )
{
	var folderUrl = "catalog.aspx?folder_id=" + pFolderId;
	window.location.href=folderUrl;
}

function CatalogProductSelect( pProductId, pNodeId )
{
	var productUrl = "addToCart.aspx?product_id=" + pProductId + "&node_id=" + pNodeId;
	window.location.href=productUrl;
}

function trim(strMessage) {
    var strResult;
    var charTemp;
    var i;
    strResult = "";
    //remove the left space
    for (i = 0; i < strMessage.length; i++) {
        charTemp = strMessage.charAt(i);
        if (charTemp != " ") {
            strResult = strMessage.substring(i);
            break;
        }
    }
    //remove the right space
    for (i = strResult.length - 1; i >= 0; i = i - 1) {
        charTemp = strResult.charAt(i);
        if (charTemp != " ") {
            strResult = strResult.substring(0, i + 1);
            break;
        }
    }
    return (strResult);

}

