﻿/// <reference path="jquery-vsdoc.js" />
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
var stillWorking = false;

$(document).ready(function() {
    var wPath = window.location.pathname.toString();
    if (wPath.indexOf("search.aspx") > -1 || wPath.indexOf("Default.aspx") > -1 || wPath.substr(wPath.length - 1, 1) == "/") {
        doFormatsDoctoring();
        if ($("#ctl00_cphBody_chkGeneral:checked").val() == null)
            $("#ctl00_cphBody_chkIncludeDescriptions").attr("disabled", "disabled");

        if (wPath.indexOf("Default.aspx") > -1 || wPath.substr(wPath.length - 1, 1) == "/") {
            if (navigator.userAgent.toLowerCase().indexOf("webkit") > -1) {
                $("#divRifImage").css("top", (+($("#divRifImage").css("top").replace("px", "")) + 10).toString() + "px");
            } else if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
                $("#divRifImage").css("top", (+($("#divRifImage").css("top").replace("px", "")) - 11).toString() + "px");
                $("#divSideBuffer").css("height", (+($("#divSideBuffer").css("height").replace("px", "")) + 11).toString() + "px");
            } else if (navigator.userAgent.toLowerCase().indexOf("safari") > -1) {
                $("#divSideBuffer").css("height", "0px");
            }
        }
    }

    var found = false;
    var targetdiv;
    if (wPath.indexOf("literatureThemes.aspx") > -1) {
        $.blockUI();
        $.get("ajxBisacBrowseLastPage.aspx", { 'dts': (new Date()).toString() }, function(data) {
            if (data.length > 0) {
                var dataHtml = data.split(')))::(((||');
                $("#ctl00_cphBody_divNavigationBar").html(dataHtml[0]);
                $("#ctl00_cphBody_divCategories").html(dataHtml[1]);
                $("#divTitles").html(dataHtml[2]);
                $("#ctl00_cphBody_spn" + dataHtml[3].toUpperCase()).css("color", "#cc0000").css("cursor", "default");
            }
        });
        $().ajaxStop($.unblockUI);
        //$.get("ajxLoadBisacPmf.aspx", { 'dts': (new Date()).toString() }, function(data) { return; });
        var expand = $.url.param("expand")
        var idTail = "_abc_" + expand;
        if ((expand) && expand != "" && !found) {
            $("#ctl00_cphBody_divCategories").children("table:first").each(function(j) {
                if (!found) {
                    $(this).children("tbody").each(function(q) {
                        if (!found) {
                            $(this).children("tr").each(function(p) {
                                if (!found) {
                                    $(this).children("td:third").each(function(k) {
                                        if (!found) {
                                            $(this).children("div").each(function(l) {
                                                if (!found) {
                                                    if (this.id.indexOf(idTail) == (this.id.length - idTail.length)) {
                                                        targetdiv = this;
                                                        found = true;
                                                    }
                                                }
                                            });
                                        }
                                    });
                                }
                            });
                        }
                    });
                }
            });
        }
        if (found)
            $(targetdiv).click();
    }

    $("#ctl00_cphBody_txtKeywords").focus();
    $("#ctl00_txtSearch").keypress(processSearch);
});

function initiateSearch() {
    goToPage("search.aspx?keywords=" + $("#ctl00_txtSearch").val());
}

function processSearch(evt) {
    var characterCode;
    if (evt && evt.which) { //if which property of event object is supported (NN4)
        evt = evt;
        characterCode = evt.which; //character code is contained in NN4's which property
    } else {
        evt = event;
        characterCode = evt.keyCode; //character code is contained in IE's keyCode property
    }
    if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
        initiateSearch();
        return false;
    }
}

function toggleNode(obj, cid, parentLevel, source, literal) {
    if (!stillWorking) {
        stillWorking = true;
        var pattern = /\(([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9])\)/;
        var literal = $(obj).text();
        literal = literal.replace(pattern, "").trim();
        literal = literal.replace("+", "").trim();
        literal = literal.replace("&", "^^**((");
        var source = obj.id.substr(0, obj.id.lastIndexOf('_'));
        source = source.substr(source.lastIndexOf('_') + 1);
        var nowtime = (new Date()).toString();
        if ($(obj).parent().children("table")[0]) {
            $.blockUI();
            collapseNode(obj);
            $.get("ajxBisacBrowse.aspx", { "Bisac": getBisacIdFromEId(obj.id), "alpha": "all", "startrecord": "0", "literal": literal, "source": source, 'dts': nowtime }, function(data) {
                if (data) {
                    $("#divTitles").html(data);
                }
            });
            $().ajaxStop($.unblockUI);
        } else {
            expandNode(obj, cid, parentLevel, source, literal);
            $.blockUI();
            var objText = $(obj).text();
            var generalOnly = (objText.substr(0, 7).toLowerCase() == "general");
            $.get("ajxBisacBrowse.aspx", { "Bisac": getBisacIdFromEId(obj.id), "alpha": "all", "startrecord": "0", "literal": literal, "generalonly": generalOnly.toString(), "source": source, 'dts': nowtime }, function(data) {
                if (data) {
                    $("#divTitles").html(data);
                }
            });
            $().ajaxStop($.unblockUI);
            collapseAllTheOtherNodes(obj);
        }
        $("#tdAlpha_1").children("span").each(function(j) {
            $(this).css("color", "#000099").css("cursor", "pointer");
        });
        $("#tdAlpha_2").children("span").each(function(j) {
            $(this).css("color", "#000099").css("cursor", "pointer");
        });
        $("#ctl00_cphBody_spnAll").css("color", "#cc0000").css("cursor", "default");
        putNavigationBar(obj);
        hiliteNode(obj);
        stillWorking = false;
    }
}

function getBisacPmfPage(bisac, alpha, startRecord, literal, source) {
    var nowtime = (new Date()).toString();
    $.blockUI();
    $.get("ajxBisacBrowse.aspx", { "Bisac": bisac, "alpha": alpha, "startrecord": startRecord, "literal": literal, "source": source, 'dts': nowtime }, function(data) {
        if (data) {
            $("#divTitles").html(data);
        }
    });
    $().ajaxStop($.unblockUI);
}

function getBisacPmfPageByAlpha(alpha, startRecord) {
    var nowtime = (new Date()).toString();
    var spnId = "spn" + alpha.toUpperCase();
    var spnControl = $("#ctl00_cphBody_" + spnId);
    if (spnControl.css("color") == "#cc0000" || $("#ctl00_cphBody_divNavigationBar").text().trim() == "")
        return;
    $.blockUI();
    $.get("ajxBisacBrowse.aspx", { "alpha": alpha, "startrecord": startRecord, "dts": nowtime }, function(data) {
        if (data) {
            $("#divTitles").html(data);
        }
    });
    $().ajaxStop($.unblockUI);
    $("#tdAlpha_1").children("span").each(function(j) {
        $(this).css("color", "#000099").css("cursor", "pointer");
    });
    $("#tdAlpha_2").children("span").each(function(j) {
        $(this).css("color", "#000099").css("cursor", "pointer");
    });
    spnControl.css("color", "#cc0000").css("cursor", "default");
}

function getBisacIdFromEId(eid) {
    return eid.substr(eid.lastIndexOf("_") + 1);
}

function getNodeBisacIds(obj) {
    var divId = obj.id;
    var bisacs = divId.substr(divId.lastIndexOf("_") + 1);
    $(obj).children("table").each(function(j) {
        $(this).children("tbody").children("tr").each(function(j) {
            $(this).children("td:third").children("div:first").each(function(i) {
                bisacs += "," + this.id.substr(this.id.lastIndexOf("_") + 1);
            });
        });
    });
    return bisacs;
}

function collapseAllTheOtherNodes(thisNode) {
    var tblParent = $(thisNode).parents("table:first");
    if (tblParent) {
        if (tblParent[0].tagName != null) {
            tblParent.children("tbody").children("tr").each(function(j) {
                $(this).children("td:third").children("div:first").each(function(i) {
                    if (this != thisNode) {
                        collapseNode(this);
                        unhiliteNode(this);
                    }
                });
            });
        }
    }
}

function expandNode(obj, cid, parentLevel, source, literal) {
    $.blockUI();
    var nowtime = (new Date()).toString();
    var objParentId = $(obj).parent().attr("id");
    $.get("ajxGetBisacSubCategories.aspx", { "objid": objParentId, "bisacid": cid, "parentlevel": parentLevel, "source": source, "objdivid": obj.id, "literal": literal, 'dts': nowtime }, function(data) {
        if (data != "") {
            $("#" + objParentId).html($("#" + objParentId).html() + data);
        }
    });
    $(obj).text($(obj).text().replace("+ ", "- "));
    $(obj).css("left", "-10px");
    $().ajaxStop($.unblockUI);
}

function collapseNode(obj) {
    var objParentId = $(obj).parent().attr("id");
    var tblDivSibling = $("#" + objParentId).children("table")[0];
    if (tblDivSibling) {
        $(tblDivSibling).remove();
        $(obj).text($(obj).text().replace("- ", "+ "));
        $(obj).css("left", "-13px");
    }
}

function hiliteNode(node) {
    var fontWeightHilite = "900";
    $(node).css("font-weight", fontWeightHilite);
}

function unhiliteNode(node) {
    $(node).css("font-weight", "normal");
}

function putNavigationBar(thisNode) {
    var navigationBarHtml = "";
    var barColor = $(thisNode).css("color");
    barColor = (barColor ? " color:" + barColor + ";" : "");
    var pattern = /\(([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9])\)/;
    $(thisNode).parents("td").each(function(i) {
        if (this.id != "tdTopContainer") {
            var ancCategory = $(this).children("div:first").text().replace("+ ", "").replace("- ", "").replace(pattern, "").trim();
            ancCategory = "<a href=\"javascript:simulateClick('" + $(this).children("div:first")[0].id + "');\" style=\"text-decoration:none;" + barColor + "\">" + ancCategory + "</a>";
            navigationBarHtml = ancCategory + " > " + navigationBarHtml;
        }
    });
    navigationBarHtml = navigationBarHtml.substr(0, navigationBarHtml.lastIndexOf(" > "));
    $("#ctl00_cphBody_divNavigationBar").html(navigationBarHtml);
}

function simulateClick(objId) {
    $("#" + objId).click();
}

function displayMonthlyLitsMenu() {
    $("#tblMonthlyLitThemes")[0].style.display = '';
}

function pageLoad()
{
	if (document.getElementById("productFormats_0").checked)
	{
		var o = document.getElementById("productFormats_1");
		var i = 1;
		while (o)
		{
			o.disabled = "disabled";
			o = document.getElementById("productFormats_" + (++i));
		}
	}
}

function categoryMouseOver(obj) {
    obj.style.backgroundColor = "#688000";
    obj.style.color = "#f0f0f0";
}

function categoryMouseOut(obj) {
    obj.style.backgroundColor = "#f0f0f0";
    obj.style.color = "#000000";
}

function MonthlyCategoryOver(obj) {
    obj.style.backgroundColor = "#688000";
    obj.style.color = "#f0f0f0";
}

function MonthlyCategoryOut(obj) {
    obj.style.backgroundColor = "#dddddd";
    obj.style.color = "#000000";
}

function categoryClick(id) {
    window.location.href = "themes.aspx?theme=" + id.toString();
}

function sectionMouseOver(obj, bgColor) {
    obj.style.backgroundColor = "#688000";
    obj.style.color = "#f0f0f0";
}

function sectionMouseOut(obj, bgColor) {
    obj.style.backgroundColor = bgColor;
    obj.style.color = "#000000";
}

function sideCategoryMouseOver(obj) {
    obj.style.backgroundColor = "#688000";
    obj.style.color = "#f0f0f0";
}

function sideCategoryMouseOut(obj) {
    obj.style.backgroundColor = "#dddddd";
    obj.style.color = "#000000";
}

function themeClick(id) {
    window.location.href = "themes.aspx?theme=" + id.toString();
    //    $.get("ajxGetThemeInfo.aspx", { "action": "theme", "id": id }, function(data) {
//        $("#ctl00_cphBody_tdThemeGraphic").css("background-image", "url('images/" + data.split('(;|;)')[2] + "')");
//        $("#ctl00_cphBody_tdBlurb").html(data.split('(;|;)')[1]);
//        $("#ctl00_cphBody_tblSections").children("tbody,thead,tfoot").children("tr").children("td").css("border", "solid 2px #f5f5f5");
//        $("#ctl00_cphBody_tdTheme").css("border", "solid 2px #b61f25");
//    });
}

function sectionClick(obj, themeid, sectionid) {
    window.location.href = "themes.aspx?theme=" + themeid.toString() + "&section=" + sectionid.toString();
    //    $.get("ajxGetThemeInfo.aspx", { "action": "section", "id": id }, function(data) {
//        $("#ctl00_cphBody_tdBlurb").html("");
//        $("#ctl00_cphBody_tblSections").children("tbody,thead,tfoot").children("tr").children("td").css("border", "solid 2px #f5f5f5");
//        $("#ctl00_cphBody_tdTitles").html(data.split("(;|;)")[1]);
//        $(obj).css("border", "solid 2px #b61f25");
//        scroll(0, 0);
//    });
}

function setBlendTop()
{
	var browser = navigator.appName;
	if (browser == "Safari")
		document.getElementById("resultsTable").style.top = "-4px";
	else
		document.getElementById("resultsTable").style.top = "-2px";
}

function textChangeEvent(o, label)
{
	if (o.value == "")
	{
		o.style.fontWeight = "bold";
		o.style.color = "#A0A0A0";
		o.style.fontSize = "11pt";
		o.value = label;
	}
	else
	{
		if (o.value == label)
		{
			o.style.fontSize = "10pt";
			o.style.fontWeight = "normal";
			o.style.color = "#000000";
			o.value = "";
		}
	}
}

function textFocusEvent(o, label)
{
	o.style.color = "#000000";
	o.style.fontWeight = "normal";
	o.style.fontSize = "10pt";
	if (o.value == label)
	{
		o.value = "";
	}
}

function textBlurEvent(o, label)
{
	if (o.value == "")
	{
		o.style.color = "#A0A0A0";
		o.style.fontWeight = "bold";
		o.style.fontSize = "10pt";
		o.value = label;
	}
}

function toggleFilters()
{
    var o = document.getElementById("ctl00_cphBody_filtersTable");
    var p = document.getElementById("ctl00_cphBody_up_dn_arrow");
    var q = document.getElementById("ctl00_cphBody_advancedFlag");
    var r = document.getElementById("divSideBuffer");
    var s = document.getElementById("divOtherLinks");
    if (o.style.display == "none") {
        q.checked = true;
        o.style.display = "";
        p.src = "images/filter_results_by_uparrow.png";
        if (r) r.style.display = "none";
        if (s) s.style.display = "none";
    }
    else {
        q.checked = false;
        o.style.display = "none";
        p.src = "images/filter_results_by_downarrow.png";
        if (r) r.style.display = "";
        if (s) s.style.display = "";
    }
}

function changePageLinks(displayFilters)
{
	/* get all the anchor (<a>) elements */
	var anchors = document.getElementsByTagName("a")
	for (i = 0; i < anchors.length; i++)
		if (anchors[i].id.indexOf("nav_") == 0)
			if (anchors[i].style.cursor == "pointer")
				anchors[i].href = newHref(anchors[i].href, displayFilters);
}

function newHref(curHref, putFiltersDisplayParam)
{
	var hrefparts = curHref.split("=");
	var navigationStr = hrefparts[0];
	separator = "^^";
	var params = hrefparts[1].split(separator);
	var tblname = params[0];
	var navPage = params[1];
	var startPage = params.length > 2 ? params[2] : 0;
	return (navigationStr + "=" + tblname + separator + navPage + separator + startPage + separator + (putFiltersDisplayParam ? "1" : "0"));
}

function evalFormatSelect()
{
    if (document.getElementById("ctl00_cphBody_productFormats_0").checked)
	{
		concatCheckedItems(true);
		var i = 0;
		var o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
		while (o != null)
		{
			o.disabled = true;
			o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
		}
	}
	else
	{
		concatCheckedItems(false);
		var i = 0;
		var o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
		while (o != null)
		{
			o.disabled = false;
			o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
		}
	}
}

function concatCheckedItems(all)
{
    var txt = document.getElementById("ctl00_cphBody_txtCheckedFormatItems");
	txt.value = "";
	var labels = document.getElementsByTagName("label");
	var i = 0;
	var o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
	while (o != null) {
	    var j = 0;
	    while (labels[++j]) {
	        if (labels[j].getAttribute("htmlFor")) {
	            if (labels[j].getAttribute("htmlFor") === o.getAttribute("id"))
	                break;
	        } else {
	            if (labels[j].getAttribute("for") === o.getAttribute("id"))
	                break;
	        }
	    }
	    if (labels[j]) {
	        if (labels[j].innerText)
	            txt.value += o.checked || all ? labels[j].innerText + "|" : "";
	        else
	            txt.value += o.checked || all ? labels[j].textContent + "|" : "";
	    }
	    o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
	}
}

function doFormatsDoctoring()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var font_size = "9pt";
		document.getElementById("ctl00_cphBody_txtAuthor").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtTranslator").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtIllustrator").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtSeries").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtPublisher").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtImprint").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtCopyright").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_txtEdition").style.fontSize = font_size;

		document.getElementById("divAdvanced").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_noteLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_authorLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_translatorLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_illustratorLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_seriesLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_publisherLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_imprintLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_copyrightLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_editionLabel").style.fontSize = font_size;
		document.getElementById("ctl00_cphBody_formatLabel").style.fontSize = font_size;
	}
	var o = document.getElementById("ctl00_cphBody_productFormats_0");
	if (o != null)
	{
		o.onclick = function() {evalFormatSelect();};
	}

	/* concatenate the text of all the "checked" checkboxes (with a delimiter, of course)
	   and put it in a hidden textbox. this is because the "selected" server side property
	   of a checkbox in the checkboxlist always returns false even if the checkbox is
	   checked. this has something to do with the way the checkboxlist is rendered to
	   a web form (checkboxes are created individually inside a table or a <span> element,
	   depending on the repeatlayout property). the checkboxes are not marked to runat="server"
	   and the way to see if they are "checked" at the server is to query the selected property
	   of the table or the <span> that represents the collection. unfortunately the collection
	   does not reflect the client side "checked" state unless it is databound, which is completely
	   useless and inappropriate here because of our 3 tier architecture. if any one finds
	   a better alternative (a trick that I missed), please let me know (jakedimano@gmail.com) */
	var i = 0;
	o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
	while (o != null)
	{
		o.onclick = function() {concatCheckedItems(false);};
		o = document.getElementById("ctl00_cphBody_productFormats_" + (++i));
	}
}

function toggleDesc(pRow, pParentRow, persistParent)
{
	var o = document.getElementById(pRow);
	var ip = document.getElementById(pRow + "ImageCellPad");
	var pr = document.getElementById(pParentRow);
	var prArrowImgRight = document.getElementById(pParentRow + "ArrowImgRight");
	var prArrowImgDown = document.getElementById(pParentRow + "ArrowImgDown");
	if (o.style.display == "none")
	{
		o.style.display = "";
		ip.style.display = "";
		if (!persistParent) {
		    pr.style.display = "none";
		} else {
		    prArrowImgRight.style.display = "none";
		    prArrowImgDown.style.display = "";
		}
	}
	else
	{
		o.style.display = "none";
		ip.style.display = "none";
		if (!persistParent) {
		    pr.style.display = "";
		} else {
		    prArrowImgRight.style.display = "";
		    prArrowImgDown.style.display = "none";
		}
	}
}

function toggleGeneral(chkBox)
{
    var chkGeneral = document.getElementById("ctl00_cphBody_chkGeneral");
    var chkTitle = document.getElementById("ctl00_cphBody_chkTitle");
    var chkSeriesTitle = document.getElementById("ctl00_cphBody_chkSeriesTitle");
    var chkAuthor = document.getElementById("ctl00_cphBody_chkAuthor");
    var chkTranslator = document.getElementById("ctl00_cphBody_chkTranslator");
    var chkIsbn = document.getElementById("ctl00_cphBody_chkIsbn");
    var chkDesc = document.getElementById("ctl00_cphBody_chkIncludeDescriptions");
    var searchTypes = document.getElementById("ctl00_cphBody_searchTypes");
	
	if (chkBox.id === chkGeneral.id)
	{
		if (chkBox.checked)
		{
			chkTitle.checked = false;
			chkSeriesTitle.checked = false;
			chkAuthor.checked = false;
			chkTranslator.checked = false;
			chkIsbn.checked = false;
			if (chkDesc.getAttribute("disabled") !== null)
				chkDesc.removeAttribute("disabled");
		}
	}
	
	if (chkBox.id === chkTitle.id || chkBox.id === chkSeriesTitle.id || chkBox.id === chkAuthor.id || chkBox.id === chkTranslator.id || chkBox.id === chkIsbn.id)
	{
		chkGeneral.checked = false;
		chkDesc.setAttribute("disabled", "disabled");
	}
	
	if (!chkTitle.checked && !chkSeriesTitle.checked && !chkAuthor.checked && !chkTranslator.checked && !chkIsbn.checked)
	{
		chkGeneral.checked = true;
		chkDesc.removeAttribute("disabled");
	}

	var searchTypeValues = (chkGeneral.checked ? "chkGeneral=true|" : "") + (chkTitle.checked ? "chkTitle=true|" : "") + (chkSeriesTitle.checked ? "chkSeriesTitle=true|" : "") + (chkAuthor.checked ? "chkAuthor=true|" : "") + (chkTranslator.checked ? "chkTranslator=true|" : "") + (chkIsbn.checked ? "chkIsbn=true|" : "") + (chkDesc.checked ? "chkIncludeDescriptions=true" : "");
	searchTypes.setAttribute("value", searchTypeValues);
}

function browseMouseOver(row)
{
	var highlightColor = "#BBBBBB";
	var forgroundColor = "#000000";
	
	document.getElementById("tdIsbn" + row).style.backgroundColor = highlightColor;
	document.getElementById("tdTitleAuthor" + row).style.backgroundColor = highlightColor;
	//document.getElementById("tdAuthor" + row).style.backgroundColor = highlightColor;
	document.getElementById("tdListPrice" + row).style.backgroundColor = highlightColor;
	document.getElementById("tdDiscountString" + row).style.backgroundColor = highlightColor;
	document.getElementById("tdAddToCart" + row).style.backgroundColor = highlightColor;
	document.getElementById("tdAddToCart" + row).style.backgroundImage = "url('images/addtocart4short.png')";
	
	document.getElementById("tdIsbn" + row).style.color = forgroundColor;
	document.getElementById("tdTitleAuthor" + row).style.color = forgroundColor;
	//document.getElementById("tdAuthor" + row).style.color = forgroundColor;
	document.getElementById("tdListPrice" + row).style.color = forgroundColor;
	document.getElementById("tdDiscountString" + row).style.color = forgroundColor;
	document.getElementById("tdAddToCart" + row).style.color = forgroundColor;
	
	//document.getElementById("tdDiscountString" + row).style.fontWeight = "bold";
	//document.getElementById("tdDiscountString" + row).style.fontSize = "9pt";
}

function browseMouseOut(row)
{
	var cellBackgroundColor = "#DDE0ED";
	var foregroundColor = "#000000";
	
	document.getElementById("tdIsbn" + row).style.backgroundColor = cellBackgroundColor;
	document.getElementById("tdTitleAuthor" + row).style.backgroundColor = cellBackgroundColor;
	//document.getElementById("tdAuthor" + row).style.backgroundColor = cellBackgroundColor;
	document.getElementById("tdListPrice" + row).style.backgroundColor = cellBackgroundColor;
	document.getElementById("tdDiscountString" + row).style.backgroundColor = cellBackgroundColor;
	document.getElementById("tdAddToCart" + row).style.backgroundColor = cellBackgroundColor;
	document.getElementById("tdAddToCart" + row).style.backgroundImage = "url('images/addtocart2words.png')";

	document.getElementById("tdIsbn" + row).style.color = foregroundColor;
	document.getElementById("tdTitleAuthor" + row).style.color = foregroundColor;
	//document.getElementById("tdAuthor" + row).style.color = foregroundColor;
	document.getElementById("tdListPrice" + row).style.color = foregroundColor;
	document.getElementById("tdDiscountString" + row).style.color = foregroundColor;
	document.getElementById("tdAddToCart" + row).style.color = foregroundColor;
	
	//document.getElementById("tdDiscountString" + row).style.fontWeight = "normal";
	//document.getElementById("tdDiscountString" + row).style.fontSize = "10pt";
}

function setBrowseLeftBufferWidth()
{
	if (navigator.appName == "Microsoft Internet Explorer")
		winW = document.body.offsetWidth;
	else
		winW = window.innerWidth;
	
	var tblWidth = document.getElementById("resultsTable").style.width;
	var setWidth = ((winH - tblWidth ) / 2);
	return setWidth + "px";
}