function addAdFromTemplate()
{
	var adsField = document.getElementById("ads");
	var adTemplateField = document.getElementById("adTemplate");
	
	if (adsField.value.trim())
	{
		adsField.value = adsField.value.trim() + ",";
	}
	
	adsField.value += adTemplateField.value;
}

function disableForm(theform)
{
	for (i = 0; i < theform.length; i++)
	{
		var element = theform.elements[i];
		if (element.type.toLowerCase() == "submit") {element.disabled = true;}
	}
	
	return true;
}

function leaveToPayPal()
{
	document.getElementById("checkoutButton").disabled = true;
	document.getElementById("checkoutButton2").value = "true";
	document.getElementById("payPalNotice").style.display = "block";
	
	document.getElementById("shop_CartForm").submit();
	
	return false;
}

function scrollToCenter()
{
	var contentWidth = document.body.offsetWidth;
	if (contentWidth <= 0) contentWidth = 600;
	var contentHeight = document.body.offsetHeight;
	if (contentHeight <= 0) contentHeight = 600;
	var image = document.getElementById('image');
	var imageWidth = image.width;
	var imageHeight = image.height;
	var scrollX = (imageWidth - contentWidth) / 2;
	if (scrollX < 0) scrollX = 0;
	var scrollY = (imageHeight - contentHeight) / 2;
	if (scrollY < 0) scrollY = 0;
	window.scrollTo(scrollX, scrollY);
}

function zoom(url)
{
	var width = screen.availWidth - 64;
	if (width > 1050) width = 1050;
	var height = screen.availHeight - 64;
	if (height > 1050) height = 1050;
	var left = Math.round(screen.availWidth / 2 - width / 2);
	var top = Math.round(screen.availHeight / 2 - height / 2);
	window.open(url, 'Zoom', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}
