﻿function ButtonDown(button)
{
	Element.addClassName(button, "LinkButton_clicked");

	button.buttonUpEvent = ButtonUp.bindAsEventListener(this, button);
	
	Event.observe(document, "mouseup", button.buttonUpEvent);
	Event.observe(document, "mouseout", button.buttonUpEvent);
}
function ButtonUp(evt, button)
{
	Element.removeClassName(button, "LinkButton_clicked");
	Event.stopObserving(document, "mouseup", button.buttonUpEvent);
	Event.stopObserving(document, "mouseout", button.buttonUpEvent);
}

function SwapBigThumb(targetImg, newImagePath)
{
	$(targetImg).src = newImagePath;
}

function OpenDetails(itemId, photoId)
{
	window.open('/itemdetails.aspx?itemId=' + itemId + '&photoId=' + photoId,'Item' + itemId,'width=650,height=560,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=yes,resizable=yes');
}

function TextCounter(field,cntfield,maxlimit)
{
	cntfield.innerHTML = maxlimit - field.value.length;
	if (field.value.length > maxlimit)
		cntfield.style.color = "red";
	else
		cntfield.style.color = "";
}

function FindTargetLocation(targetObj)
{
	var x = 0;
	var y = 0;
	var tempObj = targetObj;
	while(tempObj && tempObj != document.body) {
		x += tempObj.offsetLeft;
		y += tempObj.offsetTop;
		tempObj = tempObj.offsetParent;
	}
	if(navigator.appVersion.indexOf("MSIE")>0){ x-=228; y++;}

	return {x:x, y:y};
}

