// JavaScript Document
term = '';
function setLocation(place)	{
	requestlocation = place;
}

function setTerm(sTerm)	{
	term = sTerm;
}

function setReferer(sReferer)	{
	referer = sReferer;
}

function addToCart(productID,rank)	{
	var sURL = "/cart/addProduct.cfm?productID=" + productID + "&location="+escape(requestlocation);
	if (typeof(rank) != "undefined")	{
		sURL = sURL + '&rank=' + rank;
	}
	if (term.length)	{
		sURL = sURL + '&term='+escape(term);
	}
	document.location.href = sURL;
}

function sendToColleague(productID,rank)	{
	var sURL = "/products/sendToColleague.cfm?productID=" + productID+"&location=" + escape(requestlocation) + "&toPage="+escape(document.location.href);
	if (typeof(rank) != "undefined")	{
		sURL = sURL + '&rank=' + rank;
	}
	if (term.length)	{
		sURL = sURL + '&term='+escape(term);
	}
	if (typeof(referer) != "undefined")	{
		sURL = sURL + '&referer='+escape(referer);
	}
	document.location.href = sURL;
}

function clickThru(productID, rank, type)	{
	if (typeof(type) == "undefined")	{
		type = 1;
	}
	var clickLink = '/products/clickthru.cfm?productID='+productID+'&rank='+rank+'&location=' + escape(requestlocation) + '&type=' + type;
	if ( term.length)	{
		clickLink = clickLink + '&term='+escape(term);
	}
	if (typeof(referer) != "undefined")	{
		clickLink = clickLink + '&referer='+escape(referer);
	}
	document.location.href  = clickLink;
}

function getClickThruURL(productID, rank, type)	{
	if (typeof(type) == "undefined")	{
		type = 1;
	}
	var clickLink = '/products/clickthru.cfm?productID='+productID+'&rank='+rank+'&location=' + escape(requestlocation) + '&type=' + type;
	if ( term.length)	{
		clickLink = clickLink + '&term='+escape(term);
	}
	if (typeof(referer) != "undefined")	{
		clickLink = clickLink + '&referer='+escape(referer);
	}
	return clickLink;
}

function recordActivity(productID, rank, type)	{
	if (typeof(type) == "undefined")	{
		type = 1;
	}
	var clickLink = '/products/clickthru.cfm?productID='+productID+'&rank='+rank+'&location=' + escape(requestlocation) + '&type=' + type;
	if ( term.length)	{
		clickLink = clickLink + '&term='+escape(term);
	}
	if (typeof(referer) != "undefined")	{
		clickLink = clickLink + '&referer='+escape(referer);
	}
	return clickLink;
}

function openEditWindow(productID,companyID)	{
	var url = '/vendorportal/products/edit.cfm?productID=' + productID + '&companyID=' + companyID;
	editWindow = window.open(url,"editor","scrollbars=no,status=no,width=438,height=386,screenX=150,screenY=50,top=50,left=150");
	editWindow.focus();
}

$("a.topicInfoLink").toggle(
	function(e) {
		e.preventDefault();
		var $holder = $("#more_info_holder");
		if ($holder.children().length == 0) {
			$holder.append( $("#more_info")[0] );
		}
		$holder.slideDown(); 
		$(e.target).addClass("topicInfoLinkActive");
	},
	function(e) {e.preventDefault(); $("#more_info_holder").slideUp(); $(e.target).removeClass("topicInfoLinkActive");}
);

$("#selectbox_manufacturer").bind("focus", function() {
	ETESTERS.Events.onMfgrBoxFocus.fire({el: $(this), searchText: $("#search_txt").val()});
	this.blur();
	}
);

