/* We have to do this because browser manufacturers are lame and none of them can decide on anything except "let's screw with developers heads" */
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim = function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim = function(){return this.replace(/\s+$/,"");}
var ua = window.navigator.userAgent;
var firefox = ua.indexOf("Firefox");
var msie = ua.indexOf("MSIE");
var netscape = ua.indexOf("Netscape");
var opera = ua.indexOf("Opera");
var debugmode = false;
try
{
	if(msie > -1)
	{
	    document.getElementById("mozillastyle").disabled = true;
	}
	else
	{
	
		document.getElementById("mozillastyle").disabled = false;
	}
}
catch(e)
{
}
if(window.Event && document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

var mouseX = 0;
var mouseY = 0;
var popupmouseX = 0;
var popupmouseY = 0;
var offsetLeft = 0;
var offsetTop = 0;
var maxRight = 450 + 50;
var minTop = 150;
var winW = 630;
var winH = 460;
var maxTop = winH -150;
var adjLeft = 0;
var popup = null;
var popupwindow = null;
var lastHot;
var searching = false;
var origImage = null;
var debugWindow = null;
var indelay = false;
var holdwindow = null;
var suppresspopup = null;
function CheckAll(control)
{
	var inputControl = document.getElementById(control).getElementsByTagName("input");
	for(x = 0; x < inputControl.length; x++)
	{
		if(inputControl[x].type == "checkbox")
		{
			inputControl[x].checked = true;
		}
	}
}
function showDebug()
{
	debugWindow = window.open("", "Debug", "left=0,top=0,width=500,height=700,scrollbars=yes,status=yes,resizable=yes");
	debugWindow.opener = self;
	debugWindow.document.open();
	debugWindow.document.write("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><TITLE>Debug Window</TITLE></head><BODY><PRE>");
}
function debug(text)
{
	if(debugmode)
	{
		Stamp = new Date();
		var Hours;
		var Mins;
		var Secs;
		Hours = Stamp.getHours();
		if(Hours > 12)
		{
			Hours -= 12;
		}
		if(Hours == 0)
		{
			Hours = 12;
		}
		Mins = Stamp.getMinutes();
		if(Mins < 10)
		{
			Mins = "0" + Mins;
		}
		Secs = Stamp.getSeconds();
		if(Secs < 10)
		{
			Secs = "0" + Secs;
		}
		var TimeStamp = '' + Hours + ":" + Mins + ":" + Secs + ' ';

		if(debugWindow && ! debugWindow.closed)
		{
		}
		else
		{
			showDebug();
		}
		debugWindow.document.write(TimeStamp + text + "\r\n");
	}
}
function hideDebug()
{
	if(debugWindow && ! debugWindow.closed)
	{
		debugWindow.close();
		debugWindow = null;
	}
}
function StoreCheck(control, title)
{
	if(control.fileSize == -1)
	{
		control.parentNode.innerText = title;
	}
}
function autoEllipseText(element, height)
{
	if(msie > -1)
	{
		i = element.innerText.length;
	}
	else
	{
		i = element.innerHTML.length;
	}
	while(element.offsetHeight > height)
	{
		i--;
		while(true)
		{
			if(msie > -1)
			{
				if(element.innerText.substr(i,1) == " ")
					break;
			}
			else
			{
				if(element.innerHTML.substr(i,1) == " ")
					break;
			}
			i--; 
		}
		if(msie > -1)
		{
			element.innerText = element.innerText.substr(0,i) + '...';
		}
		else
		{
			element.innerHTML = element.innerHTML.substr(0,i) + '...';
		}
	}
}
function ShowTopHits(control, itemID, searchTerm, category)
{
    var xmlhttp = null;
	debug('in top hits');
	document.getElementById(control).className = "CRRowSel";

	var htmlArea = document.getElementById("HTMLArea");
	var parent = document.getElementById(control);
	if(popup != null)
	{
		debug('top hits .. need to clear');
		PopupGoneX();
	}
	lastHot = itemID;
	searching = true;
	var url = thissite + "AJAX/Engine.aspx?function=showtop&itemID=" + itemID + "&searchTerm=" + escape(searchTerm) + "&category=" + category + "&timestamp=" + new Date().getTime();
	if (window.XMLHttpRequest) // code for Mozilla, etc.
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) // code for IE
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp != null)
	{
		try
		{
			try
			{
				if(popupwindow != null)
				{
					window.clearTimeout(popupwindow);
				}
				if(document.getElementById("TopHits_" + control.substring(7)) != null)
				{
					popup = document.getElementById("TopHits_" + control.substring(7));
					popup.style.display = "block";
				}
				else
				{
					popup = document.createElement('div');
					popup.setAttribute('id', "TopHits_" + control.substring(7));
					popup.className = "TopHits";
					popup.control = document.getElementById(control);
					popup.onmouseout = function(){PopupGone();};
					popup.onmouseover = function(){PopupClear();};
					document.body.appendChild(popup);
					popup.setAttribute("checked", "true");
					offset = 0;
					width = document.body.clientWidth;
					if(width > 795)
					{
						offset = (width - 795)/2;
					}
					offsetTop = parent.offsetTop +105;
					if(parent.offsetTop < 50)
					{
						offsetTop += 50;
					}
					topCount = 0;
					if(topSponsor)
					{
						offsetTop += 80;
						topCount++;
					}
					if(topGoogle)
					{
						offsetTop += 120;
						topCount++;
					}
					if(topValidClick)
					{
						offsetTop += 120;
						topCount++;
					}
					if(topCount > 1)
					{
						offsetTop += 15;
					}
					offsetLeft = parent.offsetLeft + offset -200;
					if(!leftValid)
					{
						adjustLeft = 100;
					}
					else
					{
						adjustLeft = 0;
						if(twoColumn)
						{
							adjustLeft += 80;
						}
					}
					if(firefox > -1)
					{
					}
					if((offsetLeft + 470 + 400 - adjustLeft) < (width -50))
					{
						// popup on the right
						before = "<table id=TopHitTableLeft width=450 height=300 border=0>";
						before += "<tr valign=top>";
						before += "<td width=25>";
						before += "<img src='/Images/1x1clear.gif' width=25 height=1 border=0>";
						before += "</td>";
						before += "<td>";

						before += "<table width=400 height=200 border=0>";
						before += "<tr valign=top>";
						before += "<td width=363>";
						before += "</td>";
						before += "<td width=15>";
						before += "<a href='javascript:PopupGoneX();'><img src='/Images/1x1clear.gif' width=15 height=25 border=0></a>";
						before += "</td>";
						before += "</tr>";
						before += "<tr valign=middle align=center>";
						before += "<td>";

						after = "</td>";
						after += "</tr>";
						after += "</table>";
						after += "</td>";
						after += "<td width=15>";
						after += "<img src='/Images/1x1clear.gif' width=15 height=1 border=0>";
						after += "</td>";
						after += "</tr>";
						after += "</table>";

						popup.innerHTML = before + "<img class=TopHitsSwim border=0 src='/images/AS_Searching.gif' >" + after;
						popup.setAttribute("side", "left");
						popup.style.top = offsetTop + "px";
						popup.style.left = (offsetLeft +470 + 40 - adjustLeft) + "px";
					}
					else
					{
						// popup on the left
						before = "<table id=TopHitTableRight width=450 height=300>";
						before += "<tr valign=top>";
						before += "<td width=3>";
						before += "<img src='/Images/1x1clear.gif' width=3 height=1 border=0>";
						before += "</td>";
						before += "<td>";

						before += "<table width=400 height=200>";
						before += "<tr valign=top>";
						before += "<td width=363>";
						before += "</td>";
						before += "<td width=15>";
						before += "<a href='javascript:PopupGoneX();'><img src='/Images/1x1clear.gif' width=15 height=25 border=0></a>";
						before += "</td>";
						before += "</tr>";
						before += "<tr valign=middle align=center>";
						before += "<td>";

						after = "</td>";
						after += "</tr>";
						after += "</table>";
						after += "</td>";
						after += "<td width=15>";
						after += "<img src='/Images/1x1clear.gif' width=15 height=1 border=0>";
						after += "</td>";
						after += "</tr>";
						after += "</table>";

						popup.innerHTML = before + "<img class=TopHitsSwim border=0 src='/images/AS_Searching.gif' >" + after;
						popup.setAttribute("side", "right");
						popup.style.top = offsetTop + "px";
						popup.style.left = (offsetLeft - adjustLeft) + "px";
					}
					popupwindow = window.setTimeout(ShowTopHitPopup, 500);
				}
			}
			catch(e)
			{
				searching = false;
			}

			xmlhttp.onreadystatechange = function () {AjaxShowTopHitsResponse(xmlhttp)};
			xmlhttp.open("GET", url, true);
			xmlhttp.send(null);
		}
		catch(ex)
		{
			searching = false;
			alert("Your browser returned AJAX error " + ex);
		}
	}
	else
	{
		searching = false;
		alert("Your browser does not support XMLHTTP.");
	}
	debug('exit top hits');
	return false;
}
function ShowTopHitPopup()
{
	debug('showtophitpopup');
	try
	{
		popupwindow = null;
		popup.style.display = "block";
	}
	catch(e)
	{
	}
}
function GetSDCOffers(Control, UserID, itemID, searchTerm, category)
{
	var timer = window.setTimeout("GetSDCOffersAJAX('" + Control + "', " + UserID + ", '" + itemID + "', '" + searchTerm + "', '" + category + "')", 200);
}
function GetSDCOffersAJAX(Control, UserID, itemID, searchTerm, category)
{
    var xmlhttp = null;
	var url = thissite + "AJAX/Engine.aspx?function=getsdcoffers&itemID=" + itemID + "&user=" + UserID + "&searchTerm=" + escape(searchTerm) + "&category=" + category + "&timestamp=" + new Date().getTime();
	if (window.XMLHttpRequest) // code for Mozilla, etc.
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) // code for IE
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp != null)
	{
		try
		{
			xmlhttp.onreadystatechange = function () {GetSDCOffersResponse(xmlhttp, document.getElementById(Control))};
			xmlhttp.open("GET", url, true);
			xmlhttp.send(null);
		}
		catch(ex)
		{
			alert("Your browser returned AJAX error " + ex);
		}
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}
	return false;
}
function GetSDCOffersResponse(xmlhttp, control)
{
	if (checkReadyState(xmlhttp))
	{
		if(xmlhttp.responseText != "")
		{
		    var loc = xmlhttp.responseText.indexOf("<!--");
		    if(loc != -1)
		    {
		        var loc2 = xmlhttp.responseText.indexOf("-->");
		        var newURL = xmlhttp.responseText.substring(loc + 4, loc2-loc).trim();
		        if(newURL != "")
		        {
		            loc = control.id.indexOf("_");
		            var seq = control.id.substring(loc + 1);
		            document.getElementById("ItemAnchor1_" + seq).href = newURL;
		            document.getElementById("ItemAnchor1_" + seq).target = "_blank";
		            document.getElementById("ItemAnchor2_" + seq).href = newURL;
		            document.getElementById("ItemAnchor2_" + seq).target = "_blank";
		        }
		    }
		    control.innerHTML = xmlhttp.responseText;
		}
	}
}
function checkReadyState(obj)
{
	if (obj.readyState == 4)
	{
		if (obj.status == 200)
		{
	  		return true;
		}
	}
	return false;
}
function AjaxShowTopHitsResponse(xmlhttp)
{
	if (checkReadyState(xmlhttp))
	{
		debug('ajax top hit return');
		try
		{
			popupwindow = null;
			if(popup.getAttribute("side") == "left")
			{
				before = "<table id=\"TopHitTableLeft\" width=450 height=300>";
				before += "<tr valign=top>";
				before += "<td width=\"25\">";
				before += "<img src=\"/Images/1x1clear.gif\" width=25 height=1 border=0>";
				before += "</td>";
				before += "<td>";
				after = "</td></tr>";
				after += "</table>";
				if(xmlhttp.responseText == "")
				{
					PopupGoneX();
				}
				else
				{
					popup.innerHTML = before + xmlhttp.responseText + after;
				}
			}
			else
			{
				before = "<table id=\"TopHitTableRight\" width=450 height=300>";
				before += "<tr valign=top>";
				before += "<td width=\"3\">";
				before += "<img src=\"/Images/1x1clear.gif\" width=3 height=1 border=0>";
				before += "</td>";
				before += "<td>";

				after = "<td>";
				after += "<td width=\"15\">";
				after += "<img src=\"/Images/1x1clear.gif\" width=15 height=1 border=0>";
				after += "</td>";
				after += "</td></tr>";
				after += "</table>";
				if(xmlhttp.responseText == "")
				{
					PopupGoneX();
				}
				else
				{
					popup.innerHTML = before + xmlhttp.responseText + after;
				}
			}
			DivElements = document.getElementById(popup.id).getElementsByTagName('DIV');
			for(x = 0; x < DivElements.length; x++)
			{
				if(DivElements[x].getAttribute('type') == 'eBayText')
				{
					autoEllipseText(DivElements[x], 40);
				}
			}
		}
		catch(e)
		{
		}
		searching = false;
	}
}
function WordCount(control, min, max)
{
	var wordcount = control.value.split(" ");
	curwords = 0;
	for(x = 0; x < wordcount.length; x++)
	{
		if(wordcount[x].length > 2)
		{
			curwords++;
		}
	}
	errorControl = control.id + "error";
	if(curwords < min)
	{
		document.getElementById(errorControl).innerText = "You need more text";
	}
	else if(curwords > max)
	{
		document.getElementById(errorControl).innerText = "Too much text";
	}
	else
	{
		document.getElementById(errorControl).innerText = "";
	}
}
function hideInline(control)
{
	document.getElementById(control).style.display = "none";
}
function showInline(control)
{
	document.getElementById(control).style.display = "inline";
}
function ResetRecommend()
{
	SetRecommend(document.getElementById("Recommend").value);
}
function SetRecommend(value)
{
	document.getElementById("Recommend").value = value;
	if(value.toLowerCase() == 'yes')
	{
		document.getElementById("yes").src = "/Images/button_yes_ro.gif";
		document.getElementById("yes").onmouseout = function(){this.src='/Images/button_yes_ro.gif'};
		document.getElementById("yes").onmouseover = function(){this.src='/Images/button_yes_ro.gif'};
	}
	else
	{
		document.getElementById("yes").src = "/Images/button_yes.gif";
		document.getElementById("yes").onmouseout = function(){this.src='/Images/button_yes.gif'};
		document.getElementById("yes").onmouseover = function(){this.src='/Images/button_yes_ro.gif'};
	}
	if(value.toLowerCase() == 'no')
	{
		document.getElementById("no").src = "/Images/button_no_ro.gif";
		document.getElementById("no").onmouseout = function(){this.src='/Images/button_no_ro.gif'};
		document.getElementById("no").onmouseover = function(){this.src='/Images/button_no_ro.gif'};
	}
	else
	{
		document.getElementById("no").src = "/Images/button_no.gif";
		document.getElementById("no").onmouseout = function(){this.src='/Images/button_no.gif'};
		document.getElementById("no").onmouseover = function(){this.src='/Images/button_no_ro.gif'};
	}
	if(value.toLowerCase() == 'maybe')
	{
		document.getElementById("maybe").src = "/Images/button_maybe_ro.gif";
		document.getElementById("maybe").onmouseout = function(){this.src='/Images/button_maybe_ro.gif'};
		document.getElementById("maybe").onmouseover = function(){this.src='/Images/button_maybe_ro.gif'};
	}
	else
	{
		document.getElementById("maybe").src = "/Images/button_maybe.gif";
		document.getElementById("maybe").onmouseout = function(){this.src='/Images/button_maybe.gif'};
		document.getElementById("maybe").onmouseover = function(){this.src='/Images/button_maybe_ro.gif'};
	}
}
function InitialRating()
{
	if(document.getElementById("rating").value != "0")
	{
		for(x = 1; x < 6; x++)
		{
			document.getElementById("Star" + x).onmouseover = function(){};
		}
		SetRating(document.getElementById("rating").value);
	}
}
function MyRating(score)
{
	for(x = 1; x < 6; x++)
	{
		if(x <= score)
		{
			if(document.getElementById("MyStar" + x).src != "/Images/StarOn.gif")
			{
				document.getElementById("MyStar" + x).src = "/Images/StarOn.gif";
			}
		}
		else
		{
			if(document.getElementById("MyStar" + x).src != "/Images/StarOff.gif")
			{
				document.getElementById("MyStar" + x).src = "/Images/StarOff.gif";
			}
		}
	}
}
function SetRating(score)
{
	for(x = 1; x < 6; x++)
	{
		if(x <= score)
		{
			if(document.getElementById("Star" + x).src != "/Images/StarOn.gif")
			{
				document.getElementById("Star" + x).src = "/Images/StarOn.gif";
			}
		}
		else
		{
			if(document.getElementById("Star" + x).src != "/Images/StarOff.gif")
			{
				document.getElementById("Star" + x).src = "/Images/StarOff.gif";
			}
		}
	}
	document.getElementById("rating").value = score;
}
function SetPopupGone(control)
{
	try
	{
		var rows = control.childNodes;
		for(var i=0; i<rows.length; i++)
		{
			try
			{
				if(rows[i].onmouseover == null)
				{
					rows[i].onmouseover = function() {PopupClear()};
				}
				else
				{
	//				rows[i].onmouseover = rows[i].onmouseover + ";" + function() {PopupClear()};
				}
				SetPopupGone(rows[i])
			}
			catch(e)
			{
			}
		}
	}
	catch(e)
	{
	}
}
function getMouseXY(e)
{
	try
	{
		if(msie > -1)
		{
			mouseX = event.clientX + document.body.scrollLeft;
			mouseY = event.clientY + document.body.scrollTop;

			scrOfY = 0;
			scrOfX = 0;
			if( document.body && ( document.body.scrollLeft || document.body.scrollTop ))
			{
				//DOM compliant
				scrOfY = document.body.scrollTop;
				scrOfX = document.body.scrollLeft;
			}
			else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
			{
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop;
				scrOfX = document.documentElement.scrollLeft;
			}

			popupmouseX = event.clientX + scrOfX - window.event.offsetX;
			popupmouseY = event.clientY + scrOfY - window.event.offsetY;
		}
		else
		{
			mouseX = e.pageX;
			mouseY = e.pageY;
		}
	}
	catch(e)
	{
	}
}
function SetDesktop(URL)
{
	try
	{
		WshShell = new ActiveXObject("WScript.Shell");
		strDesktop = WshShell.SpecialFolders("Desktop");
		oShellLink = WshShell.CreateShortcut(strDesktop + "\\AuctionSHARK.lnk");
		oShellLink.TargetPath = URL;
		oShellLink.WindowStyle = 1;
		oShellLink.Description = "AuctionSHARK Search Results";
		oShellLink.WorkingDirectory = strDesktop;
		oShellLink.Save();
	}
	catch(e)
	{
		location.replace('/News/TrustedSite.aspx');
	}
}
function EmailItem(UserID, Site, ItemID)
{
	var Email = prompt("Who do you want to email to?", "Enter email address here:");
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if(!re.test(Email))
	{
		alert("Email Address is Invalid");
	}
	else
	{
		var url = thissite + "AJAX/Engine.aspx?function=emailitem&site=" + Site + "&ID=" + ItemID + "&user=" + UserID + "&email=" + Email + "&timestamp=" + new Date().getTime();
		if (window.XMLHttpRequest) // code for Mozilla, etc.
		{
			xmlhttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) // code for IE
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (xmlhttp != null)
		{
			try
			{
				xmlhttp.open("GET", url, true);
				xmlhttp.send(null);
				alert("Email has been sent");
			}
			catch(ex)
			{
				alert("Your browser returned AJAX error " + ex);
			}
		}
		else
		{
			alert("Your browser does not support XMLHTTP.");
		}
		return false;
	}
}
function addBookmarkObj(url, title)
{
	var isKonq=(isLikelyKonqueror3 && isLikelyKonqueror3());
	var isMac=(navigator.userAgent.toLowerCase().indexOf('mac')!=-1);
	var buttonStr = isMac?'Command/Cmd':'CTRL';

    if(window.external && (!document.createTextNode || (typeof(window.external.AddFavorite)=='unknown')))
    {
		window.external.AddFavorite(url, title);
    }
    else if(isKonq)
    {
		alert('You need to press CTRL + B to bookmark our site.');
    }
    else if((window.opera && opera.buildNumber && !isNaN(opera.buildNumber())))
    {
		void(0);
	}
	else if(window.opera)
	{
		alert('You need to press '+buttonStr+' + T to bookmark our site.');
    }
	else if(window.home)
	{
		alert('You need to press '+buttonStr+' + D to bookmark our site.');
	}
	else if(!window.print || isMac)
	{
		alert('You need to press Command/Cmd + D to bookmark our site.');    
    }
    else
    {
		alert('In order to bookmark this site you need to do so manually through your browser.');
	}
	return true;
}
function isLikelyKonqueror3()
{
	if(!document.getElementById) return false;
	if(document.defaultCharset || window.opera || !window.print) return false;
	if(window.home) return false;
	if(document.all) return true;
	var likely = 1;
	eval("try{var str=document.all[0].tagName;}catch(err){likely=0;}");
	return likely;
}
function SEOReview(ProductID, SearchTerm, SearchTitle)
{
    var xmlhttp = null;
	var url = thissite + "AJAX/Engine.aspx?function=seoreview&ProductID=" + ProductID + "&SearchTerm=" + SearchTerm + "&SearchTitle=" + SearchTitle + "&timestamp=" + new Date().getTime();
	if (window.XMLHttpRequest) // code for Mozilla, etc.
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) // code for IE
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp != null)
	{
		try
		{
			xmlhttp.onreadystatechange = function () {AjaxReviewResponse(xmlhttp)};
			xmlhttp.open("GET", url, true);
			xmlhttp.send(null);
		}
		catch(ex)
		{
			alert("Your browser returned AJAX error " + ex);
		}
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}
	return false;
}
function ItemSave(image, itemLink)
{
	var url = thissite + "AJAX/Engine.aspx?function=additem&" + itemLink + "&timestamp=" + new Date().getTime();
	if (window.XMLHttpRequest) // code for Mozilla, etc.
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) // code for IE
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp != null)
	{
		try
		{
			xmlhttp.open("GET", url, true);
			xmlhttp.send(null);
			oldURL = image.src;
			oldURL = oldURL.substring(0, oldURL.lastIndexOf("/"));
			image.src = oldURL + "/button_saved.gif";
			image.onmouseover = function(){window.status='View my Saved Items';};
			image.onmouseout = function(){window.status='';};
			image.alt = "View my Saved Items";
			image.title = "View my Saved Items";
			image.onclick = ItemWindowOpen;
		}
		catch(ex)
		{
			alert("Your browser returned AJAX error " + ex);
		}
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}
	return false;
}
function ItemWindowOpen()
{
	newURL = location.href.substring(0, location.href.lastIndexOf("/"));
	newwindow = window.open(newURL + "/Account/myItemWatch.aspx", "ItemWatch");
	newwindow.focus();
}
function RedirectWindow(link, query)
{
	newwindow = window.open(link + escape(query), "_blank");
	newwindow.focus();
}
function AjaxReviewResponse(xmlhttp)
{
	if (checkReadyState(xmlhttp))
	{
		try
		{
			document.getElementById('ReviewHTML1').innerHTML = xmlhttp.responseText;
		}
		catch(e)
		{
		}
		try
		{
			document.getElementById('ReviewHTML2').innerHTML = xmlhttp.responseText;
		}
		catch(e)
		{
		}
	}
}
function HelpPopup(control, x, y)
{
	if(suppresspopup == null)
	{
		holdwindow = window.setTimeout(ClearHold, 500);
		if(popup != null)
		{
			popup.style.display = "none";
			popup = null;
		}
		popup = document.getElementById(control);
		popup.control = null;
		if(msie > -1)
		{
			popup.style.top = (popupmouseY +y) + "px";
			popup.style.left = (popupmouseX +x -280) + "px";
		}
		else
		{
			popup.style.top = (mouseY) + "px";
			popup.style.left = (mouseX -280) + "px";
		}
		popup.style.display = "block";
	}
	else
	{
		debug("HelpPopup Suppressed");
	}
}
function HotPopup(control)
{
	if(suppresspopup == null)
	{
		holdwindow = window.setTimeout(ClearHold, 500);
		if(popup != null)
		{
			popup.style.display = "none";
			popup = null;
		}
		try
		{
			popup = document.getElementById(control);
			popup.control = null;
			if(msie > -1)
			{
				popup.style.top = (popupmouseY +20) + "px";
				popup.style.left = (popupmouseX -280) + "px";
			}
			else
			{
				popup.style.top = (mouseY +10) + "px";
				popup.style.left = (mouseX -280) + "px";
			}
			popup.style.display = "block";
		}
		catch(e)
		{
		}
	}
	else
	{
		debug("HotPopup Suppressed");
	}
}
function PopupClear()
{
	debug('PopupClear()');
	window.clearTimeout(popupwindow);
	popupwindow = null;
}
function ClearHold()
{
	debug('clear hold');
	holdwindow = null;
}
function ClearSuppress()
{
	debug('clear suppress');
	suppresspopup = null;
}
function PopupGone()
{
	debug('PopupGone()');
	if(popup != null)
	{
		popupwindow = window.setTimeout(PopupGoneX, 500);
	}
}
function PopupGoneX()
{
//	if(holdwindow == null)
	{
		debug('PopupGoneX()');
		try
		{
			if(popupwindow != null)
			{
				PopupClear();
			}
			try
			{
				if(popup.control != null)
				{
					popup.control.className = "CRRow";
				}
			}
			catch(e)
			{
			}
			lastHot = "";
			popup.style.display = "none";
			popup = null;
			searching = false;
			suppresspopup = window.setTimeout(ClearSuppress, 250);
		}
		catch(e)
		{
		}
	}
}
function HideControl(control)
{
	debug('hide control');
	control.style.display = "none";
}
function CheckImageSize(maxWidth, maxHeight, attr)
{
	var timer = window.setTimeout("CheckImageSize('" + maxWidth + "', '" + maxHeight + "', '" + attr + "')", 500);
	try
	{
		var allimages = document.getElementsByTagName("IMG");
		var counter = 0;

		for(x = 0; x < allimages.length; x++)
		{
			if(allimages[x].getAttribute(attr) == "true")
			{
				counter++;
				thisImage = allimages[x];
				if(thisImage.complete)
				{
					if(thisImage.height != 0)
					{
						thisImage.setAttribute(attr, "false");				
						if(thisImage.width > maxWidth)
						{
							Ratio = thisImage.width/maxWidth;
							HeightF = thisImage.height/Ratio;
							thisImage.height = Math.round(HeightF);
							thisImage.width = maxWidth;
						}
						if(thisImage.height > maxHeight)
						{
							Ratio = thisImage.height/maxHeight;
							WidthF = thisImage.width/Ratio;
							thisImage.width = Math.round(WidthF);
							thisImage.height = maxHeight;
						}
						counter--;
					}
				}
			}
		}
		if(counter == 0)
		{
			window.clearTimeout(timer);
			timer = null;
		}
	}
	catch(e)
	{
	}
}

function CheckAdSize(Image, Size)
{
	if(Image.width > Size)
	{
		Ratio = Image.width/Size;
		HeightF = Image.height/Ratio;
		Image.height = Math.round(HeightF);
		Image.width = Size;
	}
}
function SetCookie(cookieName,cookieValue,nDays)
{
	var today = new Date();
	var expire = new Date();
	if(nDays==null || nDays==0)
		nDays = 1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
}
function GetCookie(cookieName)
{
	var theCookie= "" + document.cookie;
	var ind = theCookie.indexOf(cookieName);
	if(ind==-1 || cookieName=="")
		return ""; 
	var ind1 = theCookie.indexOf(';',ind);
	if(ind1==-1)
		ind1 = theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
function SharkSubmit(inputControl)
{
	document.getElementById("formaction").value = inputControl.name;
	document.forms["Form1"].submit();
}
function OpenLink(Link, Target)
{
	newwindow = window.open(Link, Target);
	newwindow.focus();
}
function OpenAnchor(control, anchorid, target)
{
	var href = document.getElementById("Anchor" + anchorid);
	control.style.color = "191970";
	newwindow = window.open(href, target);
	if(window.focus)
		newwindow.focus();
}
function timeAdjust(inDiff)
{
	var timeServer = inDiff;
	var timeCurrent = new Date();
	var timeDiff = timeCurrent.getTime() - timeServer.getTime();
	var timeValues = document.getElementsByTagName("SPAN");
	for (var i = 0; i < timeValues.length; i++)
	{
		if (timeValues[i].getAttribute("type") == "auctionTime")
		{
			var endDateString = timeValues[i].getAttribute("endDate");
			var endDate = new Date(endDateString);
			endDate = new Date(endDate.getTime() + timeDiff);
			var newEndDateString = endDate.getFullYear() + "/" + (endDate.getMonth()+1) + "/" + endDate.getDate() + " " + endDate.getHours() + ":" + endDate.getMinutes() + ":" + endDate.getSeconds();
			timeValues[i].setAttribute("endDate", newEndDateString);
		}
	}
	decrementTime();
}
function initDecrementTime()
{
	window.setTimeout(decrementTime, 2000);
}
function flipRight()
{
	debug("flipcheck=" + offsetLeft + " t1=" + (winW - maxRight -15) + " t2=" + (winW - maxRight +15));
	if(offsetLeft < (winW - maxRight -15))
	{
		adjLeft = -80;
		debug("flip left of threshold");
		return true;
	}
	else
	{
		if(offsetLeft > (winW - maxRight +15))
		{
			adjLeft = 420;
			debug("flip right of threshold");
			return false;
		}
		else
		{
			adjLeft = -80;
			debug("flip middle of threshold");
			return true;
		}
	}
}
function decrementTime()
{
	var currentDate = new Date();
	var currentTime = parseInt(currentDate.getTime()/1000);
	var timeValues = document.getElementsByTagName("SPAN");
	for(var i = 0; i < timeValues.length; i++)
	{
		if(timeValues[i].getAttribute("type") == "auctionTime")
		{
			var diffString = "";
			endDate = timeValues[i].getAttribute("endDate");
			endTime = parseInt(Date.parse(endDate)/1000);
			timePeriod = endTime - currentTime;
			if (timePeriod > 0)
			{
				timeValues[i].setAttribute("period", timePeriod - 1);
				totalTime = timePeriod;
				
				diffDays = Math.floor(timePeriod/86400);
				if(diffDays > 0)
				{
					diffString += diffDays + "d ";
					timePeriod -= diffDays * 86400;
				}
				
				diffHours = Math.floor(timePeriod/3600);

				if(diffHours > 0)
				{
					diffString += diffHours + "h ";
					timePeriod -= diffHours * 3600;
				}
				
				diffMinutes = Math.floor(timePeriod/60);
				if(diffDays == 0)
				{
					if(diffMinutes > 0)
					{
						diffString += diffMinutes + "m ";
						timePeriod -= diffMinutes * 60;
					}
				}
				
				if(diffDays == 0 && diffHours == 0)
				{
					diffSeconds = timePeriod;
					if(diffSeconds > 0)
					{
						diffString += diffSeconds + "s";
					}
				}
				if(totalTime < 3600)
				{
					timeValues[i].innerHTML = "<FONT color=\"#FF0000\" >" + diffString + "</FONT>";
				}
				else
				{
					timeValues[i].innerHTML = diffString;
				}

			}
			else
			{
				timeValues[i].innerHTML = "<FONT color=\"#0000FF\" >" + "Auction Ended" + "</FONT>";
				timeValues[i+1].style.display = "none";
			}
		}
	}
	window.setTimeout(decrementTime, 1000);
}