/* launch popups -- press articles, policies, store listings */
function popWin(url,name,w,h) {
	var win = open(url,name,'width='+w+',height='+h+',scrollbars=yes,resizable=no');
	win.focus();
}

//------------------------------------------------------------------//
// CATALOG PRODUCT PAGES //
//------------------------------------------------------------------//
function thumbCall(name){
	swapShirt(name);
	colorMenu(name);
}

var myT1 = new Array('Black','White','Navy','Chocolate','Green','Magenta','Watermelon','Pink','Red','Logo');
function swapShirt(name) {
  for(i = 0; i < myT1.length; i++) {
		if ( document.getElementById(myT1[i]) ) {
			if (name == myT1[i]) {
				document.getElementById(myT1[i]).style.display = 'block';
			} else {
				document.getElementById(myT1[i]).style.display = 'none';
			}
  		}
	}  
	return false;
}

//CHANGE THE MENU ITEM, WHEN A NEW COLOR THUMB IS SELECTED //
function colorMenu(theColorName)
{
	// Loop through all items in the menu, then set select if it matches theColorName //
	var colorSelect = document.getElementById('color'); 
	for ( var i=0; i<colorSelect.options.length; i++ )
	{
		if( colorSelect.options[i].value == theColorName )
		{
			colorSelect.options[i].selected = true;
			break;
		}
	} 
}	

function validateShirtSize() {
	
	var theSize = document.getElementById('size'); 
	for (var i=0; i<document.getElementById('size').options.length; i++ ) {
		//if (document.getElementById('size').options[i].value == "") {	
			alert('Please enter the SIZE for the item you wish to order' + i);
			return false;
		//} else {	
		//	return true;
		//}
	}
}

function validateShirtQuantity()
{
	var quantity = document.myOrder.Quantity.value;
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	if ( (quantity == "") || (quantity == "0" ) )
	{
			alert('You must order at least 1 item in order to proceed.');
			IsNumber = false;	
	}		
	else
	{
		for (i = 0; i < quantity.length && IsNumber == true; i++) 
		{ 
			Char = quantity.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				alert('You must enter a Quantity for the items you wish to order.  Please remove any spaces, commas, or other non-numeric characters.');
				IsNumber = false;
				document.myOrder.Quantity.focus();
			}
		}
	}

	if (IsNumber == false)
	{
		return false;
	}	
	else
	{
		return true;
	}
}

// Called from onSubmit //
function validate() 
{
	return validateShirtQuantity();
}

function copyAddressInfo() {
	var d = document;
	d.deliveryInfo.ShipAddress.value = d.deliveryInfo.BillAddress.value;
	d.deliveryInfo.ShipCity.value = d.deliveryInfo.BillCity.value;
	d.deliveryInfo.ShipZip.value = d.deliveryInfo.BillZip.value;
	d.deliveryInfo.ShipStateSelect.options[d.deliveryInfo.BillStateSelect.selectedIndex].selected = true;
	d.deliveryInfo.ShipFirstName.value = d.deliveryInfo.BillFirstName.value;
	d.deliveryInfo.ShipLastName.value = d.deliveryInfo.BillLastName.value;
	d.deliveryInfo.ShipEmail.value = d.deliveryInfo.BillEmail.value;
	d.deliveryInfo.ShipPhone.value = d.deliveryInfo.BillPhone.value;
}