function validateQuickDesign(form)
{
	with(form)
	{
		if(shirtType.value == '')
		{
			alert("You must select a shirt type");
			shirtType.focus();
			return false;
		}
		if(shirtStyle.value == '')
		{
			alert("You must select a shirt style");
			shirtStyle.focus();
			return false;
		}
		if(color.value == '')
		{
			alert("You must select a shirt color");
			color.focus();
			return false;
		}
		
		return true;
	}
}

function submitToDesign(sku)
{
	document.forms[0].sku.value = sku;
	document.forms[0].submit();	
}

function submitToQuote(sku)
{
	document.forms[0].sku.value = sku;
	document.forms[0].action = "quote.jsp";
	document.forms[0].submit();	
}


function toggleShirtDetails(textarea)
{	
	var dtlDiv;
	if(textarea.name == 'shirtFrontText')
	{
		dtlDiv = document.getElementById("frontTxtDtl");
	}
	else if(textarea.name == 'shirtBackText')
	{
		dtlDiv = document.getElementById("backTxtDtl");
	}
	
	if(dtlDiv)
	{
		if(textarea.value.length > 0)
		{			
			dtlDiv.style.display = 'block';
			dtlDiv.style.position == 'relative';
		}
		else
		{
			dtlDiv.style.display = 'none';
			dtlDiv.style.position == 'absolute';
		}
	}
}

function toggleShirtDetailsNew(textarea)
{	
	var textExDiv = document.getElementById("textEx");
	var dtlDiv;
	if(textarea.name == 'shirtFrontText')
	{
		dtlDiv = document.getElementById("frontTxtDtl");
		//textExDiv.style.fontFamily = "'" + document.forms[0].shirtFrontTextFont[document.forms[0].shirtFrontTextFont.selectedIndex].text + "'";
		//textExDiv.style.fontSize = document.forms[0].shirtFrontTextSize[document.forms[0].shirtFrontTextSize.selectedIndex].text;
	}
	else if(textarea.name == 'shirtBackText')
	{
		dtlDiv = document.getElementById("backTxtDtl");
		//textExDiv.style.fontFamily = document.forms[0].shirtFrontBackFont[document.forms[0].shirtBackTextFont.selectedIndex].text;
		//textExDiv.style.fontSize = document.forms[0].shirtBackTextSize[document.forms[0].shirtBackTextSize.selectedIndex].text;
	}
	
	if(dtlDiv)
	{
		if(textarea.value.length > 0)
		{			
			dtlDiv.style.display = 'block';
			dtlDiv.style.position == 'relative';
		}
		else
		{
			dtlDiv.style.display = 'none';
			dtlDiv.style.position == 'absolute';
		}
	}
	
	//alert(textExDiv.style.fontFamily);
	//alert(textExDiv.style.fontSize);
	//textExDiv.innerHTML = textarea.value;	
}

function changeFont(fontBox)
{
	var textExDiv = document.getElementById("textEx");
	var dtlDiv;
	if(fontBox.name == 'shirtFrontTextFont')
	{
		dtlDiv = document.getElementById("frontTxtDtl");
		textExDiv.style.fontFamily = "'" + fontBox[fontBox.selectedIndex].text + "'";
	}
	else if(fontBox.name == 'shirtBackTextFont')
	{
		dtlDiv = document.getElementById("backTxtDtl");
		textExDiv.style.fontFamily = fontBox[fontBox.selectedIndex].text;
	}
}

function showColor(selectBox)
{
	var colorDiv = document.getElementById("colorEx");
	var color = selectBox[selectBox.selectedIndex].getAttribute("color");
	if(color == '#')
	{
		colorDiv.innerHTML = "Color Example Not Found";
		colorDiv.style.backgroundColor = "#EDF5FF";
	}
	else
	{
		colorDiv.innerHTML = "";		
		colorDiv.style.backgroundColor = color;
	}
}

function checkFile(file)
{
	var fileDiv;
	if(file.name == 'shirtFrontImage')
	{
		fileDiv = document.getElementById("frontFileDtl");
	}
	else
	{
		fileDiv = document.getElementById("backFileDtl");
	}
	
	if(file.value.length > 0)
	{
		fileDiv.style.display = 'block';
		fileDiv.style.position == 'relative';
	}
	else
	{
		fileDiv.style.display = 'none';
		fileDiv.style.position == 'absolute';
	}
}

function addToCart(page)
{
	var form = document.forms[0];
	var totalQuantity = 0;
	for(i=0;i<form.elements.length;i++)		
	{
		if(form.elements[i].name.substring(0,8) == 'quantity')
		{
			if(!isNaN(form.elements[i].value) && form.elements[i].value > 0)
			{
				totalQuantity += form.elements[i].value
			}
		}
	}
	
	if(totalQuantity == 0)
	{
		alert("You must enter a quantity");
		return false;
	}
	
	if(page == 'print')
	{
		if(totalQuantity <= 12)
		{
			alert("You must have a quantity of 13 or more for screen printing. "
				+ "If you require a quantity of 12 or less please use our digital transfer product.");
			return false;
		}
	}
	else if(page == 'digital')
	{
		if(totalQuantity > 12)
		{
			alert("Digital Transfers are for a quantity of 12 or less.  "
				+ "Please use our traditional printing product for your quantity");
			return false;
		}
	}
	
	with(form)
	{
		if(shirtColor.value == '')
		{
			alert("You must select a shirt color");
			shirtColor.focus();
			return false;
		}
	}
	
	form.submit();
	return true;
}

function validateDesignForm(form)
{
	with(form)
	{
		if(shirtFrontText.length > 0)
		{
			if(shirtFrontTextColor == '')
			{
				alert("You must choose a text color for the shirt front text");
				return false;
			}
			if(shirtFrontTextFont == '')
			{
				alert("You must choose a text font for the shirt front text");
				return false;
			}
			if(shirtFrontTextSize.selectedIndex <= 0)
			{
				alert("You must choose a text size for the shirt front text");
				return false;
			}
		}
		if(shirtBackText.length > 0)
		{
			if(shirtBackTextColor == '')
			{
				alert("You must choose a text color for the shirt back text");
				return false;
			}
			if(shirtBackTextFont == '')
			{
				alert("You must choose a text font for the shirt back text");
				return false;
			}
			if(shirtBackTextSize.selectedIndex <= 0)
			{
				alert("You must choose a text size for the shirt back text");
				return false;
			}
		}
	}
	
	return true;
}

function submitDesign(button,sku)
{
	if(button.name == 'digital')
	{
		//window.location = "digitaltransferdesign.jsp?sku="+sku;
		window.location = "design_tabs.jsp?sku="+sku+"&orderType=digital";
	}
	else if(button.name == 'print')
	{
		//window.location = "printdesign.jsp?sku="+sku;
		window.location = "design_tabs.jsp?sku="+sku+"&orderType=print";
	}
}

function gotoDesignFromQuote()
{
	document.forms[0].action="submitQuote.jsp";
	document.forms[0].submit();
}