var bsState = "";
var wlState = "";
var bwState = "open";
var bnState = "";
var wlsState = "";
var cpiState = "";
var abState = "";
var isbnState = "";
var rcState = "";
var paState = "";
var twState = "";
var multipleUsedState = "";
var singleState = "";
var openLayers = new Array();

function MM_preloadImages() { //v3.0
	var d = document;
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
		}
	}
}
function MM_swapImgRestore() { //v3.0
	var i, x, a = document.MM_sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}
}
function MM_findObj(n, d) { //v4.01
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all) {
		x = d.all[n];
	}
	for (i = 0; !x && i < d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i = 0; !x && d.layers && i < d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}
function MM_swapImage() { //v3.0
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3) {
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc = x.src;
			}
			x.src = a[i + 2];
		}
	}
}
function MM_showHideLayers() { //v6.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i = 0; i < (args.length - 2); i += 3) {
		if ((obj = MM_findObj(args[i])) != null) {
			v = args[i + 2];
			if (obj.style) {
				obj = obj.style;
				v = (v == "show") ? "visible" : (v == "hide") ? "hidden" : v;
			}
			obj.visibility = v;
		}
	}
}
function displayIsbnMessage() {
	value = document.searchboxBook.inputData.value;
	if (value == null || value == "") {
		document.searchboxBook.inputData.value = "Enter One Or More ISBNs";
	}
}
function deleteIsbn(comp) {
	if (comp.value == "Enter One Or More ISBNs") {
		comp.value = "";
	}
}
function showCalendar() {
	var now = new Date();
	var cal17 = new CalendarPopup();
	cal17.addDisabledDates(null, formatDate(now, "yyyy-MM-dd"));
	cal17.select(document.forms["TwitterForm"].date1, "anchor1", "MM/dd/yyyy");
}
function showTwitter() {
	if (twState == "open") {
		Effect.BlindUp("TwitterForm");
		twState = "";
	} else {
		Effect.BlindDown("TwitterForm");
		twState = "open";
	}
}
function doClear(theText, otherValue) {
	if (theText.value == otherValue) {
		theText.value = "";
	}
}
function setTwit() {
	var newdiv = document.getElementById("TwitterForm");
	twitterName = document.getElementById("twitterName").value;
	isbn = document.getElementById("isbnForTwitter").value;
	name = document.getElementById("nameForTwitter").value;
	img = document.getElementById("imgForTwitter").value;
	st = document.getElementById("stForTwitter").value;
	maxUsed = document.getElementById("maxUsedTwitter").value;
	maxNew = document.getElementById("maxNewTwitter").value;
	untilDate = document.getElementById("untilDate").value;
	var url = "twitter.do?twitterName=" + twitterName + "&st=" + st + "&isbn=" + isbn + "&name=" + name + "&img=" + img + "&maxUsed=" + maxUsed + "&maxNew=" + maxNew + "&untilDate=" + untilDate;
	newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Setting the twit...<br/><br/>";
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processGetTwit;
	req.open("GET", url, true);
	req.send(null);
}
function processGetTwit() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseTwitResponse();
		} else {
			alert("Server Failure, Please try again");
		}
	}
}
function parseTwitResponse() {
	code = req.responseText;
	var newdiv = document.getElementById("TwitterForm");
	if (code.indexOf("OK") != -1) {
		newdiv.innerHTML = "Thank you! You are now following the price on Twitter and will notify you when the price will drop.";
	} else {
		newdiv.innerHTML = code;
	}
}
function showTwitsForName() {
	location.href = "twitter.do?showTwit=" + document.getElementById("twitterNameField").value;
}
function sendE (site){
	var image = new Image(1,1);
	image.src = "http://www.googleadservices.com/pagead/conversion/1054763461/imp.gif?value=1&label=lead&script=0";
	image = new Image(1,1);
	image.src = "http://www.googleadservices.com/pagead/conversion/1056387419/?label=pageview&amp;script=0";
	image = new Image(1,1);
	image.src = "http://www.googleadservices.com/pagead/conversion/1030957551/?label=-Dh4CL3CtAEQ79PM6wM&amp;guid=ON&amp;script=0";
}

function updateTwit(twitterName, isbn) {
	untilDateElement = "UntilDate_" + isbn;
	untilDate = document.getElementById(untilDateElement).value;
	var url = "twitter.do?update=" + isbn + "&twitterName=" + twitterName + "&untilDate=" + untilDate;
	location.href = url;
}
function showPriceAlert() {
	if (paState == "open") {
		Effect.BlindUp("PriceALERTform");
		paState = "";
	} else {
		mail = document.getElementById("mailForAlert").value;
		idForPriceAlert = document.getElementById("idForAlert").value;
		Effect.BlindDown("PriceALERTform");
		paState = "open";
	}
}
function showAlertsForMail() {
	mail = document.getElementById("emailField").value;
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))) {
		return;
	}
	location.href = "alert.do?showMail=" + mail;
}
function updateAlert(customerId, isbn) {
	price = document.getElementById("TargetPrice_" + isbn).value;
	var url = "alert.do?update=" + isbn + "&customerId=" + customerId + "&price=" + price;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processUpdateAlert;
	req.open("GET", url, true);
	req.send(null);
}
function processUpdateAlert() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseAlertUpdateResponse();
		} else {
			alert("Server Failure, Please try again");
		}
	}
}
function parseAlertUpdateResponse() {
	code = req.responseText;
	index = code.indexOf("zzzzz");
	isbn = code.substr(0, index);
	isbn = isbn.replace(/^\s+/g, "").replace(/\s+$/g, "");
	var newdiv = document.getElementById("AlertStatus_" + isbn);
	if (code.indexOf("OK") != -1 && newdiv.innerHTML.indexOf("updated") == -1) {
		MM_swapImage("pendingImg_" + isbn, "", "img/pending.gif", 1);
		newdiv.innerHTML = newdiv.innerHTML + "Price was updated";
	} else {
		text = newdiv.innerHTML;
		index = text.indexOf("Price was updated");
		if (index != -1) {
			text = text.substring(0, index);
		}
		newdiv.innerHTML = text + "We fail to update the price";
	}
}
function setAlert(isShopping) {

	isNew = document.getElementById("isNewForAlert").value;
	st = document.getElementById("stForAlert").value;
	price = document.getElementById("priceForAlert").value;
	mail = document.getElementById("mailForAlert").value;
	var newdiv = document.getElementById("PriceALERTform");
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))) {
		if (newdiv.innerHTML.indexOf("Please check") == -1) {
			newdiv.innerHTML = "Please check the mail address.<br/> " + newdiv.innerHTML;
		}
		return;
	}
	allowCom = document.getElementById("allowForAlert");
	if (allowCom != null) {
		allow = allowCom.checked;
	} else {
		allow = "true";
	}
	isbn = document.getElementById("isbnForAlert").value;
	name = document.getElementById("nameForAlert").value;
	img = document.getElementById("imgForAlert").value;
	isIncludes = document.getElementById("includesForAlert").checked;
	var url = "alert.do?mail=" + mail + "&st=" + st + "&price=" + price + "&isNew=" + isNew + "&isIncludes=" + isIncludes + "&isbn=" + isbn + "&allow=" + allow + "&name=" + name + "&img=" + img + "&isS=" + isShopping;
	newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Setting the price alert...<br/><br/>";
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processGetAlert;
	req.open("GET", url, true);
	req.send(null);
}
function processGetAlert() {
	

	if (req.readyState == 4) {
	
		if (req.status == 200) {
			parseAlertResponse();
		} else {
			
			alert("Server Failure, Please try again");
		}
	}
}
function parseAlertResponse() {
	code = req.responseText;
	var newdiv = document.getElementById("PriceALERTform");
	if (code.indexOf("OK") != -1) {
		newdiv.innerHTML = "Thank you! BooksPrice has set a Price Alert and will notify you when this item is available on the requested price. You will receive an email confirmation shortly. Check your junk mail folder if you do not see this email. <br/> You can always <a href='alert.do?page=alerts'>edit your alerts</a>";
	} else {
		if (code.indexOf("You already") != -1) {
			newdiv.innerHTML = code;
		} else {
			if (newdiv.innerHTML.indexOf("We could") == -1) {
				newdiv.innerHTML = "We could not set the alert. Please check all the details.<br/> " + newdiv.innerHTML;
			}
		}
	}
}
function ShowContentN(d, d1, d2, d3, valueN) {
	if (d.length < 1) {
		return;
	}
	show = document.getElementById(d);
	noShow1 = document.getElementById(d1);
	noShow2 = document.getElementById(d2);
	noShow3 = document.getElementById(d3);
	value = valueN;
	document.searchboxBook.inputData.value = document.searchbox1.inputData.value = value = document.searchbox2.inputData.value = document.searchbox3.inputData.value = value;
	show.style.display = "";
	noShow1.style.display = "none";
	noShow2.style.display = "none";
	noShow3.style.display = "none";
}
function ShowContent(d, d1, d2, d3) {
	if (d.length < 1) {
		return;
	}
	show = document.getElementById(d);
	noShow1 = document.getElementById(d1);
	noShow2 = document.getElementById(d2);
	noShow3 = document.getElementById(d3);
	value = document.searchboxBook.inputData.value;
	if (value == null || value == "") {
		value = document.searchbox1.inputData.value;
	}
	if (value == null || value == "") {
		value = document.searchbox2.inputData.value;
	}
	if (value == null || value == "") {
		value = document.searchbox3.inputData.value;
	}
	document.searchboxBook.inputData.value = document.searchbox1.inputData.value = value = document.searchbox2.inputData.value = document.searchbox3.inputData.value = value;
	show.style.display = "";
	noShow1.style.display = "none";
	noShow2.style.display = "none";
	noShow3.style.display = "none";
}
function membership() {
	if (document.getElementById("membershipPlus").src.indexOf("minus") != -1) {
		MM_swapImage("membershipPlus", "", "img/plus.gif", 1);
		document.getElementById("memberships").style.display = "none";
		return;
	}
	MM_swapImage("membershipPlus", "", "img/minus.gif", 1);
	document.getElementById("memberships").style.display = "";
}
function addbookmark() {
	url = "http://www.BooksPrice.com";
	title = "BooksPrice.com - Book Price Comparison";
	if (window.external) { // IE Favorite
		window.external.AddFavorite(url, title);
	} else {
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url, "");
		} else {
			if (window.opera && window.print) { // Opera Hotlist
				return true;
			}
		}
	}
}
function swapData(data) {
	if (data == "bestSellers") {
		bsState = twist("bestSellersData", bsState, "bsp");
	}
	if (data == "bookNews") {
		bnState = twist("bookNewsData", bnState, "bnp");
	}
	if (data == "bookWeek") {
		bwState = twist("bookOfTheWeekData", bwState, "bwp");
	}
	if (data == "mywishlist") {
		wlState = twist("myWishlistData", wlState, "mwl");
	}
	if (data == "wishListSearch") {
		wlsState = twist("WishListData", wlsState, "wls");
	}
	if (data == "comparisonPlugIn") {
		cpiState = twist("Downloadsdata", cpiState, "cpi");
	}
	if (data == "audioBooks") {
		abState = twist("AudioBooksData", abState, "ab");
	}
	if (data == "isbn13") {
		isbnState = twist("isbn13Data", isbnState, "is");
	}
	if (data == "myRecentComparisons") {
		rcState = twist("myRecentComparisonsData", rcState, "rc");
	}
	if (data == "multipleUsed") {
		multipleUsedState = twist("multipleUsedData", multipleUsedState, "multipleUsed");
	}
	if (data == "single") {
		singleState = twist("singleData", singleState, "single");
	}
}
function twist(div, state, image) {
	if (state == "open") {
		Effect.BlindUp(div);
		MM_swapImage(image, "", "img/plus.gif", 1);
		state = "";
	} else {
		Effect.BlindDown(div);
		MM_swapImage(image, "", "img/minus.gif", 1);
		state = "open";
	}
	return state;
}
function sbFocus() {
	var focusControl = document.forms["searchboxBook"].elements["inputData"];
	if (focusControl.type != "hidden") {
		focusControl.focus();
	}
}
function sdFocus() {
	var focusControl = document.forms["searchbox1"].elements["inputData"];
	if (focusControl.type != "hidden") {
		focusControl.focus();
	}
}
function smFocus() {
	var focusControl = document.forms["searchbox2"].elements["inputData"];
	if (focusControl.type != "hidden") {
		focusControl.focus();
	}
}
function sgFocus() {
	var focusControl = document.forms["searchbox3"].elements["inputData"];
	if (focusControl.type != "hidden") {
		focusControl.focus();
	}
}
function Submit_dvd() {
	value = document.searchbox1.inputData.value;
	if (document.searchbox1.searchType[1].checked) {
		location.href = "advancedSearch.do?type=DVD&director=" + urlEn(value);
	} else {
		if (document.searchbox1.searchType[2].checked) {
			location.href = "advancedSearch.do?type=DVD&actor=" + urlEn(value);
		} else {
			location.href = "compare.do?searchType=dvd&inputData=" + urlEn(value);
		}
	}
}
function Submit_sort(data, search, categoryId, sel, catId) {
	var sort;
	for (i = 0; i < sel.length; i++) {
		if (sel[i].selected == true) {
			sort = sel[i].value;
			break;
		}
	}
	if (catId == null) {
		location.href = "compare.do?searchType=" + search + "&inputData=" + data + "&sb=" + sort;
	} else {
		location.href = "getCategory.do?categoryName=" + data + "&categoryId=" + categoryId + "&sb=" + sort;
	}
}
function Submit_music() {
	value = document.searchbox2.inputData.value;
	if (document.searchbox2.searchType[1].checked) {
		location.href = "advancedSearch.do?type=Music&artist=" + urlEn(value);
	} else {
		if (document.searchbox2.searchType[2].checked) {
			location.href = "advancedSearch.do?type=Music&label=" + urlEn(value);
		} else {
			location.href = "compare.do?searchType=music&inputData=" + urlEn(value);
		}
	}
}
function Submit_getCateogry() {
	list = document.bestsellerform.listcategory;
	location.href = "getBooksForCategory.do?categoryId=" + list.options[list.selectedIndex].value;
}
function Submit_getPrice(isbn) {
	list = document.shippingform.destinationKey;
	if (!document.shippingform.checkboxshipping.checked) {
		if (document.shippingform.checkboxnew.checked) {
			location.href = "compare.do?fromPrice=true&showNew=true&st=noSt&searchType=compare&inputData=" + isbn;
		} else {
			location.href = "compare.do?showNew=false&fromPrice=true&st=noSt&searchType=compare&inputData=" + isbn;
		}
	} else {
		if (document.shippingform.checkboxnew.checked) {
			location.href = "compare.do?fromPrice=true&showNew=true&searchType=compare&inputData=" + isbn + "&st=" + list.options[list.selectedIndex].value;
		} else {
			location.href = "compare.do?showNew=false&fromPrice=true&searchType=compare&inputData=" + isbn + "&st=" + list.options[list.selectedIndex].value;
		}
	}
}
function Submit_buybackPrice(isbn) {
	if (document.buybackusegform.show.value == "new") {
		location.href = "buyback.do?l=y&showNew=true&searchType=compare&inputData=" + isbn;
	} else {
		if (document.buybackusegform.show.value == "all") {
			location.href = "buyback.do?l=y&searchType=compare&inputData=" + isbn;
		} else {
			location.href = "buyback.do?l=y&showUsed=true&searchType=compare&inputData=" + isbn;
		}
	}
}
function Submit_getPriceS(isbn) {
	list = document.shippingform.destinationKey;
	if (!document.shippingform.checkboxshipping.checked) {
		location.href = "compareS.do?fromPrice=true&st=noSt&searchType=price&inputData=" + isbn;
	} else {
		zip = document.getElementById("zipcode").value;
		location.href = "compareS.do?fromPrice=true&searchType=price&inputData=" + isbn + "&st=U.S.&zip=" + zip;
	}
}
function Submit_rentals() {
	url = location.href;
	url = url.replace("&dontShowRentals=false", "");
	url = url.replace("&dontShowRentals=true", "");
	if (document.shippingform.checkrentals.checked) {
		location.href = url + "&dontShowRentals=false";
	} else {
		location.href = url + "&dontShowRentals=true";
	}
}
function Submit_getBasketPrice() {
	list = document.shippingform.destinationKey;
	url = "";
	document.shippingform.fp.value = "true";
	if (!document.shippingform.checkboxshipping.checked) {
		document.shippingform.st.value = "noSt";
		if (document.shippingform.checkboxnew.checked) {
			document.shippingform.showNew.value = "true";
		} else {
			document.shippingform.showNew.value = "false";
		}
	} else {
		document.shippingform.st.value = list.options[list.selectedIndex].value;
		if (document.shippingform.checkboxnew.checked) {
			document.shippingform.showNew.value = "true";
		} else {
			document.shippingform.showNew.value = "false";
		}
	}
	document.shippingform.submit();
}
function getSDetails(isbn, details) {
	var url = "compareS.do?details=true&isbn=" + isbn;
	var divIdName = "Details_" + isbn;
	var divExists = document.getElementById(divIdName);
	if (divExists != null) {
		//check if this is an open layer
		for (i = 0; i < openLayers.length; i++) {
			//if the layer is already there hide it
			if (openLayers[i] == divIdName) {
				openLayers.splice(i, 1);
				twist(divIdName, "open", "bd_" + isbn);
				return;
			}
		}
		//if the layer is not shown - show it
		openLayers.push(divIdName);
		twist(divIdName, "close", "bd_" + isbn);
		return;
	} else {
		var ni = document.getElementById("bkdetails_" + isbn);
		var newdiv = document.createElement("div");
		var divIdName = "Details_" + isbn;
		newdiv.setAttribute("id", divIdName);
		newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Please wait...<br/><br/>";
		ni.appendChild(newdiv);
		openLayers.push(divIdName);
		twist(divIdName, "close", "bd_" + isbn);
	}
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processRequestDetails;
	req.open("GET", url, true);
	req.send(null);
}
function getDetails(isbn) {
	var url = "details.do?isbn=" + isbn;
	var divIdName = "Details_" + isbn;
	var divExists = document.getElementById(divIdName);
	if (divExists != null) {
		//check if this is an open layer
		for (i = 0; i < openLayers.length; i++) {
			//if the layer is already there hide it
			if (openLayers[i] == divIdName) {
				openLayers.splice(i, 1);
				twist(divIdName, "open", "bd_" + isbn);
				return;
			}
		}
		//if the layer is not shown - show it
		openLayers.push(divIdName);
		twist(divIdName, "close", "bd_" + isbn);
		return;
	} else {
		var ni = document.getElementById("bkdetails_" + isbn);
		var newdiv = document.createElement("div");
		var divIdName = "Details_" + isbn;
		newdiv.setAttribute("id", divIdName);
		newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Please wait...<br/><br/>";
		ni.appendChild(newdiv);
		openLayers.push(divIdName);
		twist(divIdName, "close", "bd_" + isbn);
	}
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processRequestDetails;
	req.open("GET", url, true);
	req.send(null);
}
function processRequestDetails() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseMessagesDetails();
		} else {
			alert("Not able to retrieve description");
		}
	}
}
function parseMessagesDetails() {
	text = req.responseText;
	index = text.indexOf("zzzzz");
	isbn = text.substr(0, index);
	isbn = isbn.replace(/^\s+/g, "").replace(/\s+$/g, "");
	text = text.substr(index + 5);
	var ni = document.getElementById("bkdetails_" + isbn);
	var detailsdiv = document.getElementById("Details_" + isbn);
	detailsdiv.innerHTML = text;
	openLayers.push(divIdName);
}
function getFormats(isbn) {
	var url = "editions.do?b=y&isbn=" + isbn;
	var divIdName = "Formats_" + isbn;
	var divExists = document.getElementById(divIdName);
	if (divExists != null) {
		//check if this is an open layer
		for (i = 0; i < openLayers.length; i++) {
			//if the layer is already there hide it
			if (openLayers[i] == divIdName) {
				openLayers.splice(i, 1);
				twist(divIdName, "open", "for_" + isbn);
				return;
			}
		}
		//if the layer is not shown - show it
		openLayers.push(divIdName);
		twist(divIdName, "close", "for_" + isbn);
		return;
	} else {
		var ni = document.getElementById("bkdetails_" + isbn);
		var newdiv = document.createElement("div");
		var divIdName = "Formats_" + isbn;
		newdiv.setAttribute("id", divIdName);
		newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Searching for other formats. Please wait...<br/><br/>";
		ni.appendChild(newdiv);
		openLayers.push(divIdName);
		twist(divIdName, "close", "for_" + isbn);
	}
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processFormatDetails;
	req.open("GET", url, true);
	req.send(null);
}
function processFormatDetails() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseFormatDetails();
		} else {
			alert("Not able to retrieve formats " + req.status);
		}
	}
}
function parseFormatDetails() {
	text = req.responseText;
	index = text.indexOf("zzzzz");
	isbn = text.substr(0, index);
	isbn = isbn.replace(/^\s+/g, "").replace(/\s+$/g, "");
	text = text.substr(index + 5);
	var ni = document.getElementById("bkdetails_" + isbn);
	var formatsDiv = document.getElementById("Formats_" + isbn);
	formatsDiv.innerHTML = text;
	openLayers.push(divIdName);
}
function getSuggestions(isbn, type) {
	var url = "suggestions.do?b=y&isbn=" + isbn + "&type=" + type;
	var divIdName = "Suggestions_" + isbn;
	var divExists = document.getElementById(divIdName);
	if (divExists != null) {
		//check if this is an open layer
		for (i = 0; i < openLayers.length; i++) {
			//if the layer is already there hide it
			if (openLayers[i] == divIdName) {
				openLayers.splice(i, 1);
				twist(divIdName, "open", "sug_" + isbn);
				return;
			}
		}
		//if the layer is not shown - show it
		openLayers.push(divIdName);
		twist(divIdName, "close", "sug_" + isbn);
		return;
	} else {
		var ni = document.getElementById("bkdetails_" + isbn);
		var newdiv = document.createElement("div");
		var divIdName = "Suggestions_" + isbn;
		newdiv.setAttribute("id", divIdName);
		newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/>&nbsp;Searching for suggestions. Please wait...<br/><br/>";
		ni.appendChild(newdiv);
		openLayers.push(divIdName);
		twist(divIdName, "close", "sug_" + isbn);
	}
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processSuggestionsDetails;
	req.open("GET", url, true);
	req.send(null);
}
function processSuggestionsDetails() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseSuggestionsDetails();
		} else {
			alert("Not able to retrieve description");
		}
	}
}
function parseSuggestionsDetails() {
	text = req.responseText;
	index = text.indexOf("zzzzz");
	isbn = text.substr(0, index);
	isbn = isbn.replace(/^\s+/g, "").replace(/\s+$/g, "");
	text = text.substr(index + 5);
	var ni = document.getElementById("bkdetails_" + isbn);
	var suggestionDiv = document.getElementById("Suggestions_" + isbn);
	suggestionDiv.innerHTML = text;
	openLayers.push(divIdName);
}
var wishListHoldContent = "";
function getWishList(id) {
	var url = "amazonWishListCompare.do?i=true&by=id&id=" + id;
	var divIdName = "myWishlistData";
	//check if this is an open layer
	for (i = 0; i < openLayers.length; i++) {
		//if the layer is already there hide it
		if (openLayers[i] == divIdName) {
			openLayers.splice(i, 1);
			twist(divIdName, "open", "mwl");
			return;
		}
		//if the layer is not shown - show it
		if (wishListHoldContent.equals("true")) {
			openLayers.push(divIdName);
			twist(divIdName, "close", "mwl");
			return;
		}
	}
	var ni = document.getElementById("mywishlist");
	var newdiv = document.getElementById("myWishlistData");
	newdiv.innerHTML = "<br/><br/><img src=\"img/loading.gif\"/><br/>Searching for your Wishlist. Please wait...<br/><br/>";
	openLayers.push(divIdName);
	twist(divIdName, "close", "mwl");
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processRequestWishList;
	req.open("GET", url, true);
	req.send(null);
}
function processRequestWishList() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseWishListDetails();
		} else {
			alert("Not able to retrieve wishlist");
		}
	}
}
function parseWishListDetails() {
	text = req.responseText;
	var ni = document.getElementById("myWishlistData");
	ni.setAttribute("class", "SBlist");
	ni.innerHTML = text;
}
function addToBasket(isbn) {
	var url = "comparePrice.do?ajax=t&searchType=basket&inputData=" + isbn;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processAddToBasket;
	req.open("GET", url, true);
	req.send(null);
}
function processAddToBasket() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseAddToBasketDetails();
		} else {
			alert("Failed on adding to cart");
		}
	}
}
function parseAddToBasketDetails() {
	text = req.responseText;
	index = text.indexOf("zzzzz");
	isbn = text.substr(0, index);
	isbn = isbn.replace(/^\s+/g, "").replace(/\s+$/g, "");
	text = text.substr(index + 5);
	var ni = document.getElementById("bkdetails_" + isbn);
	textExist = ni.innerHTML;
	if (textExist.indexOf("The item was added") == -1) {
		ni.innerHTML = textExist + "<br/><span class=\"or-titlebooks\" style=\"font-size: 90%\">The item was added to multiple items comparison</span>";
	}
	var cartHolder = document.getElementById("cartHolder");
	cartHolder.innerHTML = text;
	//location.href = "#top";
}
function saveFeedback(up, store, isbn) {
	if (up == 1) {
		data = document.getElementById("whyUp").value;
	} else {
		data = document.getElementById("whyDown").value;
	}
	var url = "rate.do?store=" + store + "&why=" + data + "&up=" + up + "&isbn=" + isbn;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processRate;
	req.open("GET", url, true);
	req.send(null);
}
function processRate() {
	document.getElementById("chartPopUp").innerHTML = "Thank you for sharing this information!";
}
function showThumbUp() {
	document.getElementById("LikedIt").style.display = "";
	var cookie_date = new Date();  // current date & time
	cookie_date.setTime(cookie_date.getTime() - 1);
	document.cookie = "last=; expires=" + cookie_date.toGMTString();
}
function showThumbDown() {
	document.getElementById("DidNotLikedIt").style.display = "";
	var cookie_date = new Date();  // current date & time
	cookie_date.setTime(cookie_date.getTime() - 1);
	document.cookie = "last=; expires=" + cookie_date.toGMTString();
}
var rssOpen = 0;
function rssWatcher(isbn, st, curr, isNew) {
	if (rssOpen == 1) {
		rssOpen = 0;
		Effect.BlindUp("rssWatcher");
		//document.getElementById('rssWatcher').style.display = "none";
		return;
	}
	rssOpen = 1;
	var url = "getCode.do?isbn=" + isbn + "&st=" + st + "&curr=" + curr + "&isNew=" + isNew;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.onreadystatechange = processGetCode;
	req.open("GET", url, true);
	req.send(null);
}
function processGetCode() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			parseGetCode();
		} else {
			alert("Server Failure, Please try again");
		}
	}
}
function parseGetCode() {
	code = req.responseText;
	var ni = document.getElementById("rssLink");
	ni.href = code;
	ni = document.getElementById("netvibes");
	ni.href = "http://www.netvibes.com/subscribe.php?url=" + urlEncodeN(code);
	code = urlEncode(code);
	ni = document.getElementById("yahoo");
	ni.href = "http://add.my.yahoo.com/rss?url=" + code;
	ni = document.getElementById("google");
	ni.href = "http://fusion.google.com/add?feedurl=" + code;
	ni = document.getElementById("bloglines");
	ni.href = "http://www.bloglines.com/sub/" + code;
	MM_swapImage("rssPlus", "", "img/minus.gif", 1);
	//document.getElementById('rssWatcher').style.display = "";
	Effect.BlindDown("rssWatcher");
}
function urlEncodeN(str) {
	str = str.replace("&", "%26");
	str = str.replace("&", "%26");
	str = str.replace("&", "%26");
	return str;
}
function urlEn(str) {
	str = str.replace("&", "%26");
	return str;
}
function urlEncode(str) {
	str = escape(str);
	str = str.replace(new RegExp("\\+", "g"), "%2B");
	return str.replace(new RegExp("%20", "g"), "+");
}

