function ChangePrintColorFields_Tshirts(No_Of_Color) {
	if(document.getElementById("display10")) document.getElementById("display10").style.display=(No_Of_Color=="0")?"none":"";
	var parts = No_Of_Color.split("-");	
	if (!isNaN(parts[0])) {		
		var colTot = parseInt(parts[0]);
		for (i=1; i<=10; i++) {
			if(document.getElementById("print_color"+i)) document.getElementById("print_color"+i).style.display=(i<=colTot && colTot!=4 && colTot!=15 && colTot!=10?"":"none");		
		}
		if (document.getElementById("embroidery-imprint-positions")) {
			document.getElementById("embroidery-imprint-positions").style.display = (colTot!=10?"none":"");
			document.getElementById("color-imprint-positions").style.display = (colTot!=10?"":"none");
		}
	}	
}

function ChangePrintColorFields(){		
	if(document.form.Number_of_Colors.value == "1-Color"){
		document.form.Imprint_Colors1.disabled = false;
		if (document.form.Imprint_Colors2) document.form.Imprint_Colors2.disabled = true;
		if (document.form.Imprint_Colors3) document.form.Imprint_Colors3.disabled = true;
		if (document.form.Imprint_Colors4) document.form.Imprint_Colors4.disabled = true;
		if (document.form.Imprint_Colors2) document.form.Imprint_Colors2.value = '';
		if (document.form.Imprint_Colors3) document.form.Imprint_Colors3.value = '';
		if (document.form.Imprint_Colors4) document.form.Imprint_Colors4.value = '';
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="none";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="none";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="none";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10"))document.getElementById("display10").style.display="";
	}
	else if (document.form.Number_of_Colors.value == "2-Colors"){
		document.form.Imprint_Colors1.disabled = false;
		document.form.Imprint_Colors2.disabled = false;
		document.form.Imprint_Colors3.disabled = true;
		document.form.Imprint_Colors4.disabled = true;
		document.form.Imprint_Colors3.value = '';
		document.form.Imprint_Colors4.value = '';
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="none";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="none";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10"))document.getElementById("display10").style.display="";
	}
	else if (document.form.Number_of_Colors.value == "3-Colors"){
		document.form.Imprint_Colors1.disabled = false;
		document.form.Imprint_Colors2.disabled = false;
		document.form.Imprint_Colors3.disabled = false;
		document.form.Imprint_Colors4.disabled = true;
		document.form.Imprint_Colors4.value = '';
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="none";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10"))document.getElementById("display10").style.display="";
	}
	else if (document.form.Number_of_Colors.value == "4-Colors"){
		document.form.Imprint_Colors1.disabled = false;
		document.form.Imprint_Colors2.disabled = false;
		document.form.Imprint_Colors3.disabled = false;
		document.form.Imprint_Colors4.disabled = false;
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10"))document.getElementById("display10").style.display="";
	}
	else if (document.form.Number_of_Colors.value == "5-Colors"){
		if (document.form.Imprint_Colors1) document.form.Imprint_Colors1.disabled = true;
		if (document.form.Imprint_Colors2) document.form.Imprint_Colors2.disabled = true;
		if (document.form.Imprint_Colors3) document.form.Imprint_Colors3.disabled = true;
		if (document.form.Imprint_Colors4) document.form.Imprint_Colors4.disabled = true;
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="none";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="none";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="none";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="none";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10"))document.getElementById("display10").style.display="";
	}
	else {
		if (document.form.Imprint_Colors1) document.form.Imprint_Colors1.disabled = true;
		if (document.form.Imprint_Colors2) document.form.Imprint_Colors2.disabled = true;
		if (document.form.Imprint_Colors3) document.form.Imprint_Colors3.disabled = true;
		if (document.form.Imprint_Colors2) document.form.Imprint_Colors2.value = '';
		if (document.form.Imprint_Colors3) document.form.Imprint_Colors3.value = '';
		if (document.form.Imprint_Colors4) document.form.Imprint_Colors4.value = '';
		if(document.getElementById("print_color1"))document.getElementById("print_color1").style.display="none";
		if(document.getElementById("print_color2"))document.getElementById("print_color2").style.display="none";
		if(document.getElementById("print_color3"))document.getElementById("print_color3").style.display="none";
		if(document.getElementById("print_color4"))document.getElementById("print_color4").style.display="none";
		if(document.getElementById("metalic_imprint"))document.getElementById("metalic_imprint").style.display="";
		if(document.getElementById("mate_finish_imprint"))document.getElementById("mate_finish_imprint").style.display="";
		if(document.getElementById("display10")) {
			document.getElementById("display10").style.display=(document.form.Number_of_Colors.value != "10-Colors" && document.form.Number_of_Colors.value != "11-Colors")?"none":"";
		}
	}
	if(document.getElementById("tr_engrave_type")) {
		document.getElementById("tr_engrave_type").style.display=(document.form.Number_of_Colors.value != "11-Colors")?"none":"";
		engrave_type_change(document.form.engrave_type.value);
		if (parseInt(document.getElementById("quantity").value) < 12) 	{			
			alert('There is a 12pcs minimum for 1 or more color imprint');
			document.getElementById("quantity").style.border = "solid 3px #FFFF00";
			document.getElementById("quantity").focus();
		}		
	}	
}
function engrave_type_change(engrave_type) {
	document.getElementById("tr_individual").style.display=(engrave_type != "Individual_Names" || document.form.Number_of_Colors.value != "11-Colors")?"none":"";
}
function additem(num,assorted_amt)
{
	if(assorted_amt > 0)
	{
		var len = document.getElementById('pro_color').options.length;
		if(document.form.quantity.value >= assorted_amt)
		{
			if(len-1 == num)
			{
				var new_option= new Option("Assorted Colors","Assorted Colors");
				document.getElementById('pro_color').options[len]=new_option;
			}
		}
		else
		{    
			if(len >= num+2)
			{
				len--;
				document.form.product_color.remove(len);
			}	
		}
	}		
}
function validation()
{
    var quantity = document.form.quantity.value;
	if(quantity.search(/sample/i)!=-1 || quantity=="1s")
	{
	    document.getElementById("print").value = "sample";
		document.getElementById("impIns").value = 6;
		
		quantity = quantity.replace(/sample/i, "");
		quantity = quantity.replace(/ /, "");
		quantity = quantity.replace(/samples/i, "");
		var minQuantity = 1;
		var boxQuantity = 1;
		var maxQuantity = 12;
	}
	else
	{
	    document.getElementById("print").value = "";
		document.getElementById("impIns").value = 3;		
		if(document.form.boxQuantity.value<1)
		  var boxQuantity = 1;
		else
		  var boxQuantity =  document.form.boxQuantity.value;

		var minQuantity = document.form.minQuantity.value;		 
		if (document.form.Number_of_Colors && document.form.Number_of_Colors.value == "11-Colors") {
			minQuantity = 4;
			boxQuantity = 1;
		}
		if (document.form.quantity.value.search(/\S/) == -1){
			if (document.getElementById("section_name").value!='Tshirts')  document.form.quantity.focus();
			alert("Quantity Can not be Blank");
			return false;
		}
		if (isNaN(document.form.quantity.value)){
			if (document.getElementById("section_name").value!='Tshirts') document.form.quantity.focus();
			alert("Quantity should be numeric");		
			return false;
		}
		if (parseInt(minQuantity*1) > parseInt(document.form.quantity.value*1)){
					if (document.getElementById("section_name").value!='Tshirts') document.form.quantity.focus();
					alert("Order quantity should not be less than "+minQuantity);		
					return false;
				}
		if((document.form.quantity.value%boxQuantity)!=0)
		{
					var nextQty = parseInt(document.form.quantity.value) + parseInt(boxQuantity - (document.form.quantity.value%boxQuantity));
					if (document.getElementById("section_name").value!='Tshirts') document.form.quantity.focus();
					alert("Order quantity should be multiple of "+boxQuantity+".\n Next Quantity is "+nextQty);		
					return false;
		}
		if(document.form.maxQuantity){
				 var maxQuantity = document.form.maxQuantity.value;
				 if(parseInt(maxQuantity*1) < parseInt(document.form.quantity.value*1)){
					if (document.getElementById("section_name").value!='Tshirts') document.form.quantity.focus();
					alert("Order quantity should not be maximum 12.");		
					return false;
				 }
		}
	}
			
	if (document.form.product_color.value == "0"){
		document.form.product_color.focus();
		alert("Select Product Color");
		return false;		
	}
	if(document.getElementById("print").value != "sample"){
	if(document.form.Number_of_Colors){
		if(document.getElementById("section_name") && (document.getElementById("section_name").value=='t_mugs' || document.getElementById("section_name").value=='sports_bottles')) {
			if(document.form.Number_of_Colors && document.form.Number_of_Colors.value != "1-Color" && document.form.Number_of_Colors.value != "0" && parseInt(document.form.quantity.value*1) <50 ){
				alert("Minimum Quanity for 2 or more colors imprint is 50pcs");
			  	document.form.quantity.focus();
				return false;
			}
		}
	    if(document.form.Imprint_Colors1){
			if((document.form.Number_of_Colors.value == "1-Color") && document.form.Imprint_Colors1 && (document.form.Imprint_Colors1.value == "")){
				//document.form.Imprint_Colors1.focus();
				alert("Enter Printing Color 1");
				return false;
			}
			if((document.form.Number_of_Colors.value == "2-Colors") && document.form.Imprint_Colors1 && (document.form.Imprint_Colors1.value== "")){
				//document.form.Imprint_Colors1.focus();
				alert("Enter Printing Color 1");
				return false;
			}
			if((document.form.Number_of_Colors.value == "3-Colors") && document.form.Imprint_Colors1 && (document.form.Imprint_Colors1.value =="")){
				//document.form.Imprint_Colors1.focus();
				alert("Enter Printing Color 1");
				return false;
			}
			if((document.form.Number_of_Colors.value == "4-Colors") && document.form.Imprint_Colors1 && (document.form.Imprint_Colors1.value == "")){
				//document.form.Imprint_Colors1.focus();
				alert("Enter Printing Color 1");
				return false;
			}
		}
		if(document.form.Imprint_Colors2){	
			if((document.form.Number_of_Colors.value == "2-Colors") && document.form.Imprint_Colors2 && (document.form.Imprint_Colors2.value == "")){
				//document.form.Imprint_Colors2.focus();
				alert("Enter Printing Color 2");
				return false;
			}
			if((document.form.Number_of_Colors.value == "3-Colors") && document.form.Imprint_Colors2 && (document.form.Imprint_Colors2.value == "")){
				//document.form.Imprint_Colors2.focus();
				alert("Enter Printing Color 2");
				return false;
			}
			if((document.form.Number_of_Colors.value == "4-Colors") && document.form.Imprint_Colors2 && (document.form.Imprint_Colors2.value =="")){
				//document.form.Imprint_Colors2.focus();
				alert("Enter Printing Color 2");
				return false;
			}
		}
		if(document.form.Imprint_Colors3){	
			if((document.form.Number_of_Colors.value == "3-Colors") && document.form.Imprint_Colors3 && (document.form.Imprint_Colors3.value == "")){
				//document.form.Imprint_Colors3.focus();
				alert("Enter Printing Color 3");
				return false;
			}
			if((document.form.Number_of_Colors.value == "4-Colors") && document.form.Imprint_Colors3 && (document.form.Imprint_Colors3.value == "")){
				//document.form.Imprint_Colors3.focus();
				alert("Enter Printing Color 3");
				return false;
			}
		}
		if(document.form.Imprint_Colors4){	
			if((document.form.Number_of_Colors.value == "4-Colors") && document.form.Imprint_Colors4 && (document.form.Imprint_Colors4.value == "")){
				//document.form.Imprint_Colors4.focus();
				alert("Enter Printing Color 4");
				return false;
			}
		}
		 if(document.form.Imprint_Colors1)
		  {
		if(document.form.Imprint_Colors1.value=="Custom")
		 {
		   if(document.form.custom_color1.value.search(/\S/) == -1)
		    {
			  alert("Enter Custom Color 1");
			  return false;
			}
		 }
		 }
		 if(document.form.Imprint_Colors2)
		  {
		 if(document.form.Imprint_Colors2.value=="Custom")
		 {
		   if(document.form.custom_color2.value.search(/\S/) == -1)
		    {
			  alert("Enter Custom Color 2");
			  return false;
			}
		 }
		 }
		 if(document.form.Imprint_Colors3)
		  {
		 if(document.form.Imprint_Colors3.value=="Custom")
		 {
		   if(document.form.custom_color3.value.search(/\S/) == -1)
		    {
			  alert("Enter Custom Color 3");
			  return false;
			}
		 }
		 }
		 if(document.form.Imprint_Colors4)
		  {
		 if(document.form.Imprint_Colors4.value=="Custom")
		 {
		   if(document.form.custom_color4.value.search(/\S/) == -1)
		    {
			  alert("Enter Custom Color 4");
			  return false;
			}
		 }
		 }

		if (document.getElementById("section_name").value=='Tshirts') {
			if (document.form.Print_On.value=="" && document.form.Number_of_Colors.value != "0") {
				alert('Please Choose Imprint Positions');
				return false;
			}
		}
		else if (document.getElementById("section_name").value=='Caps') {
			if (document.form.Print_On.value=="" && document.form.Number_of_Colors.value != "0") {
				alert('Please Choose Imprint Positions');
				return false;
			}
		}
		
		if(document.form.shipping_state.value==0)	
		{
		        alert("Please select ship to state.");
				return false;
		}
		if(document.form.ship_zip && document.form.shipping_state.value=='FL'){
				if(document.form.ship_zip.value=='')	
				{
						alert("Please enter ship to Zip.");
						return false;
				}
		}
	}
	}
	return true;
}
function pageSubmit()
{
	var flag = validation();
	if(flag==true)
	{
		var quantity = document.form.quantity.value;
		quantity = quantity.replace(/sample/i, "");
		quantity = quantity.replace(/ /, "");
		quantity = quantity.replace(/samples/, "");
		document.form.quantity.value = quantity;
		document.form.mode.value ='add_cart';
		document.form.impIns.value=document.form.impIns_temp.value;
		if (document.form.Number_of_Colors && document.form.Number_of_Colors.value=="0") {
			document.form.impIns.value = 5;
			document.getElementById("print").value = 'blank';
			document.form.action = "https://secure.discountmugs.com/nc/ns-order_step1-blank.php";
		}
		else document.form.action = "https://secure.discountmugs.com/ns-order_step1.php";
		document.form.submit();
	}	
}
function pageSubmit_Bel()
{
	var flag = validation();
	if(flag==true)
	{
		var quantity = document.form.quantity.value;
		quantity = quantity.replace(/sample/i, "");
		quantity = quantity.replace(/ /, "");
		quantity = quantity.replace(/samples/, "");
		document.form.quantity.value = quantity;
		document.form.mode.value ='add_cart';
		document.form.impIns.value=document.form.impIns_temp.value;
		if (document.form.Number_of_Colors && document.form.Number_of_Colors.value=="0") {
			document.form.impIns.value = 5;
			document.getElementById("print").value = 'blank';
			document.form.action = "https://secure.discountmugs.com/nc/ns-order_step1-blank.php";
		}
		else document.form.action = "https://secure.discountmugs.com/ns-order_step1-bel.php";
		document.form.submit();
	}	
}
function edit_item(ID)
{
    var flag = validation();
	if(flag==true)
	{
		document.form.mode.value ='edit_cart';
		document.form.item_id.value = ID;
		document.form.submit();
	}	
}
