function ChangePrintColorFields_Tshirts(No_Of_Color) {
	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?"":"none");		
		}
	}
}

function ChangePrintColorFields(){		
	if(document.form.Number_of_Colors.value == "1-Color"){
		document.form.Imprint_Colors1.disabled = false;
		document.form.Imprint_Colors2.disabled = true;
		document.form.Imprint_Colors3.disabled = true;
		document.form.Imprint_Colors4.disabled = true;
		document.form.Imprint_Colors2.value = '';
		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="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="";
	}
	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="";
	}
	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="";
	}
	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="";
	}
	else if (document.form.Number_of_Colors.value == "5-Colors"){
		document.form.Imprint_Colors1.disabled = true;
		document.form.Imprint_Colors2.disabled = true;
		document.form.Imprint_Colors3.disabled = true;
		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="";
	}
	else{
		document.form.Imprint_Colors1.disabled = false;
		document.form.Imprint_Colors2.disabled = true;
		document.form.Imprint_Colors3.disabled = true;
		document.form.Imprint_Colors2.value = '';
		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="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="";
	}
}
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;		
		var minQuantity = document.form.minQuantity.value;
		if(document.form.boxQuantity.value<1)
		  var boxQuantity = 1;
		else
		  var boxQuantity =  document.form.boxQuantity.value;
		if (document.form.quantity.value.search(/\S/) == -1){
			document.form.quantity.focus();
			alert("Quantity Can not be Blank");
			return false;
		}
		if (isNaN(document.form.quantity.value)){
			document.form.quantity.focus();
			alert("Quantity should be numeric");		
			return false;
		}
		if (parseInt(minQuantity*1) > parseInt(document.form.quantity.value*1)){
					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));
					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)){
					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" && parseInt(document.form.quantity.value*1) <50 ){
				alert("Minumum 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.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;
		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();
	}	
}