﻿// JScript File

// Pop-up Window
function newWindow(productImage) {
	productWindow = window.open(productImage, 'productWin', 'directories=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0,height=480,width=750');
	productWindow.focus();
}

// Flash Pop-up Window
function newFlashPopup(url,width,height) {
	flashWindow = window.open(url, "flashWin", 'resizable=1,scrollbars=0,status=0,toolbar=0,width=' + width + ',height=' + height);
	flashWindow.focus();
}

// Info Pop-up Window
function newPopup(url) {
	infoWindow = window.open(url, "infoWin", 'resizable=1,scrollbars=1,toolbar=0,height=410,width=200');
	infoWindow.focus();
}

// Used in products_image.aspx.
function resizeScreen()
{
	if ( navigator.appName!= 'Microsoft Internet Explorer' ) 
	{ 
		window.outerHeight = document.images[0].height + 60;
		window.outerWidth = document.images[0].width + 30;
	}
	else
	{
		window.resizeTo(document.images[0].width + 30, document.images[0].height + 60);
	}
}   

// Used in Products.aspx.
function openNewWindow(pageName)
{
    productWindow = window.open(pageName, '', '');
	productWindow.focus();
}

function updateDivDisplayValue(divElementId, displayValue)
{
	document.getElementById(divElementId).style.display = displayValue;
}

// Used in /Checkout/Default.aspx when the "Place Order" button is clicked.
function disableButtonThenExecute(buttonElementId)
{
	var buttonElement = document.getElementById(buttonElementId);
	if (buttonElement != null)
		buttonElement.disabled = true;
	__doPostBack(buttonElement.name, '');
}

// Used in /Checkout/Default.aspx when the customer changes the selection in the address dropdown.
function changeAddressDisplayed(dropdownElementId, spanElementId)
{
	var spanNode = document.getElementById(spanElementId);
	var address = addresses[document.getElementById(dropdownElementId).value];
	var addressInfo = address.split("<br />");

	var thisSiblingNode, nextSiblingNode, nextChildNode;

	// 20070328 FKC: Get the first child node of the <SPAN> tag.			
	var firstChildNode = spanNode.firstChild;
	if (firstChildNode != null)
	{
		thisSiblingNode = firstChildNode.nextSibling;
		while (thisSiblingNode != null)
		{
			nextSiblingNode = thisSiblingNode.nextSibling;
			spanNode.removeChild(thisSiblingNode);
			thisSiblingNode = nextSiblingNode;
		}
	}
	
	if (addressInfo.length > 0)
	{
		firstChildNode.data = addressInfo[0];

		var i = 1;
		if (addressInfo.length > 1)
		{
			while (i < addressInfo.length)
			{
				nextChildNode = document.createElement("br");
				spanNode.appendChild(nextChildNode);

				nextChildNode = document.createTextNode(addressInfo[i]);
				spanNode.appendChild(nextChildNode);

				i++;
			}
		}
	}
}