function draw_mono()
{
document.write("<input type=hidden name=addto id=addtoform value='1'>");
  if (porder_code.indexOf('mono') != -1)
  {
    //this info_attr1 is for the product itself to make our field array indexes match
    document.write("<input type=hidden name=info_attr1 id=info_attr1 value=\"\">");
    document.write("<input type=hidden name=sku id=sku value=\"\">");
    document.write("<input type=hidden name=qty id=qty value=0>");
    
    //this info_attr1 is for our monogramming product
    document.write("<input type=hidden name=info_attr1 id=info_attr1 value=\"\">");

    switch(porder_code){
      case "monogen":
      mono();
      break;
      case "mono1":
      pillow();
      break;
      case "mono2":
      sweater();
      break;
      case "mono3":
      stools();
      break;
      case "mono4":
      jumper();
      break;
      case "mono5":
      bracelet();
      break;
      case "mono6":
      whatadish();
      break;
    }
  }
}
function pillow(){
	document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
	document.write("<tr><td>Name: </td><td><input type=\"text\" name=\"myname\" id=\"myname\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Weight of Baby: </td><td><input type=\"text\" name=\"myweight\" id=\"myweight\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Length of Baby: </td><td><input type=\"text\" name=\"mylength\" id=\"mylength\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Birth Date: </td><td><input type=\"text\" name=\"mybirth\" id=\"mybirth\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Christening Date: </td><td><input type=\"text\" name=\"mychristening\" id=\"mychristening\" maxlength=\"15\"></td></tr></table>");
}

function sweater(){
	if (typeof mono2_options!="undefined"){
		var split_options = mono2_options.split(",");
		document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
	//	document.write("<tr><td>Initials: </td><td><input type=\"text\" name=\"myinit1\" id=\"myinit1\" size=\"1\" maxlength=\"1\">&nbsp;<input type=\"text\" name=\"myinit2\" id=\"myinit2\" size=\"1\" maxlength=\"1\">&nbsp;<input type=\"text\" name=\"myinit3\" id=\"myinit3\" size=\"1\" maxlength=\"1\"></td></tr>");
		document.write("<tr><td>Initials: </td><td><input type=\"text\" name=\"myinit1\" id=\"myinit1\" size=\"1\" maxlength=\"1\"></td></tr>");
		if (split_options.length >= 1){
			document.write("<tr><td>Colors: </td><td><SELECT name=\"mycolor\" id=\"mycolor\" >");
			
			for (atn=0; atn<split_options.length; atn++)
			{
				if (split_options[atn]!="")
				{
					document.write("<OPTION value='"+split_options[atn]+"'>"+split_options[atn]+"</option>");
					//document.write("<OPTION value='Light Pink w/White Initial'>Light Pink w/White Initial</option><OPTION value='Light Blue w/White Initial'>Light Blue w/White Initial</option><OPTION value='Blue w/ Green Initial'>Blue w/ Green Initial</option><OPTION value='Pink w/ Green Initial'>Pink w/ Green Initial</option>");
				}
			}
			document.write("</SELECT></td></tr></table>");
		}
	}
}

function stools(){
	document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
	document.write("<tr><td>Name: </td><td><input type=\"text\" name=\"myname\" id=\"myname\" maxlength=\"15\"></td></tr>");
	document.write("</table>");
}

function jumper(){
	if (typeof mono4_options!="undefined"){
		var split_options = mono4_options.split(",");
		document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
		document.write("<tr><td>Initials: </td><td><input type=\"text\" name=\"myinit1\" id=\"myinit1\" size=\"1\" maxlength=\"1\">&nbsp;<input type=\"text\" name=\"myinit2\" id=\"myinit2\" size=\"1\" maxlength=\"1\">&nbsp;<input type=\"text\" name=\"myinit3\" id=\"myinit3\" size=\"1\" maxlength=\"1\"></td></tr>");
		if (split_options.length >= 1){
			document.write("<tr><td>Colors: </td><td><SELECT NAME=\"mycolor\" id=\"mycolor\">");
			for (atn=0; atn<split_options.length; atn++)
			{
				if (split_options[atn]!="")
				{
					document.write("<OPTION value='"+split_options[atn]+"'>"+split_options[atn]+"</option>");
					//document.write("<OPTION value='Navy'>Navy</option><OPTION value='Green'>Green</option><OPTION value='White'>White</option>");
				}
			}
			document.write("</SELECT></td></tr></table>");
		}
	}
}

function bracelet(){
	document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
	document.write("<tr><td>Name: </td><td><input type=\"text\" name=\"myname\" id=\"myname\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td colspan=2>Note: there is no extra charge unless the name is more than 10 letters ($3.00 for each additional letter).</td></tr></table>");
}

function whatadish(){
	document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
	document.write("<tr><td>First Name: </td><td><input type=\"text\" name=\"myfirstname\" id=\"myfirstname\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Middle Name: </td><td><input type=\"text\" name=\"mymiddlename\" id=\"mymiddlename\" maxlength=\"15\"></td></tr>");
	document.write("<tr><td>Birth Date: </td><td><input type=\"text\" name=\"mybirth\" id=\"mybirth\" maxlength=\"15\"></td></tr></table>");
}


function grey_this(){
document.getElementById('myname').disabled=false;
document.getElementById('myinit1').disabled=true;
document.getElementById('myinit2').disabled=true;
document.getElementById('myinit3').disabled=true;
document.getElementById('myname').style.backgroundColor="#ffffff";
document.getElementById('myinit1').style.backgroundColor="#d4d0c8";
document.getElementById('myinit2').style.backgroundColor="#d4d0c8";
document.getElementById('myinit3').style.backgroundColor="#d4d0c8";
}

function white_this(){
document.getElementById('myinit1').disabled=false;
document.getElementById('myinit2').disabled=false;
document.getElementById('myinit3').disabled=false;
document.getElementById('myname').disabled=true;
document.getElementById('myname').style.backgroundColor="#d4d0c8";
document.getElementById('myinit1').style.backgroundColor="#ffffff";
document.getElementById('myinit2').style.backgroundColor="#ffffff";
document.getElementById('myinit3').style.backgroundColor="#ffffff";
}

function mono(){
	if (typeof monogen1_options!="undefined"){
		var split_options = monogen1_options.split(",");
		var split_options2 = monogen2_options.split(",");
		document.write("<table border=0><tr><td colspan=2><input type=\"checkbox\" name=\"choosemono\" id=\"choosemono\"><b>Check box for Monogramming:</b></td></tr>");
		document.write("<tr><td><input type=\"radio\" name=\"choosename\" id=\"choosename\" onClick=\"grey_this();\" value=\"Name\" checked> Name: </td>");
		document.write("<td><input type=\"text\" name=\"myname\" id=\"myname\" maxlength=\"15\"></td></tr>");
		document.write("<tr><td><input type=\"radio\" name=\"choosename\" id=\"choosename\" onClick=\"white_this();\" value=\"Init\"> Initials: </td>");
		document.write("<td><input type=\"text\" name=\"myinit1\" id=\"myinit1\" maxlength=\"1\" size=\"1\">&nbsp;");
		document.write("<input type=\"text\" name=\"myinit2\" id=\"myinit2\" maxlength=\"1\" size=\"1\">&nbsp;");
		document.write("<input type=\"text\" name=\"myinit3\" id=\"myinit3\" maxlength=\"1\" size=\"1\"></td></tr>");
		document.write("<tr><td>Birth Date (optional): </td><td><input type=\"text\" name=\"mybdate\" id=\"mybdate\" maxlength=\"15\"></td></tr>");
		if (split_options.length >= 1){
			document.write("<tr><td>Color: </td><td>");
			document.write("<SELECT NAME=\"mycolor\" id=\"mycolor\">");
			for (atn=0; atn<split_options.length; atn++)
			{
				if (split_options[atn]!="")
				{
					document.write("<OPTION value='"+split_options[atn]+"'>"+split_options[atn]+"</option>");
				}
			}
			document.write("</SELECT></td></tr>");
		}
		if (split_options2.length >= 1){
			document.write("<tr><td>Type of text: </td><td>");
			document.write("<SELECT NAME=\"mytype\" id=\"mytype\">");
			for (atn=0; atn<split_options2.length; atn++)
			{
				if (split_options2[atn]!="")
				{
					document.write("<OPTION value='"+split_options2[atn]+"'>"+split_options2[atn]+"</option>");
				}
			}
			document.write("</SELECT>");
		}
		document.write("</td></tr></table>");
		grey_this();
	}
}

function check_mono(){
	document.getElementById("addtoform").value=addto;
	var sku_flds = document.getElementsByName("sku");
	var iattr_flds = document.getElementsByName("info_attr1");
	var qty_flds = document.getElementsByName("qty");
	//charge for monogramming or not based on porder_code
	if (porder_code=="monogen" || porder_code=="mono3" || porder_code=="mono4"){
		if (document.getElementById("choosemono").checked)
		{
		sku_flds[1].disabled = false;
		  qty_flds[0].disabled = false;
		  iattr_flds[1].disabled = false;
		 if (pf_id=="PAANICDDDHJNJGDM" || pf_id=="PAANICJDJOJIJGDM" || pf_id=="PAANACCMCJEOMBEA")
			{
			sku_flds[1].value="12";
			}else{	
			sku_flds[1].value="11";
			}
			//sku_flds[1].value="11";
			//sku_flds[1].value="PAANACFILMAJOGCO";
			qty_flds[0].value="1";
      //give the product they are viewing some text in info_attr1 to indicate that they selected monogramming
      iattr_flds[0].value = "Monogramming selected";

			if (porder_code == "monogen")
			{
			  if (document.getElementById('myname').disabled==false)
			  {
			    iattr_flds[1].value= "For " + document.getElementById('sku').value + " - name: " + document.getElementById('myname').value;
			  }else{
			    iattr_flds[1].value = "For " + document.getElementById('sku').value + " - initials: " + document.getElementById('myinit1').value + document.getElementById('myinit2').value + document.getElementById('myinit3').value;
			  }
			  if (document.getElementById('mybdate').value.length > 0){iattr_flds[1].value += " - birthdate: " + document.getElementById('mybdate').value;}
			  if (document.getElementById('mycolor').value.length > 0){iattr_flds[1].value += " - color: " + document.getElementById('mycolor').value;}
			  if (document.getElementById('mytype').value.length > 0){iattr_flds[1].value += " - type: " + document.getElementById('mytype').value;}
			}else if (porder_code == "mono3")
			{
			    iattr_flds[1].value= "For " + document.getElementById('sku').value + " - name: " + document.getElementById('myname').value;
			}else if (porder_code == "mono4")
			{
			    iattr_flds[1].value = "For " + document.getElementById('sku').value + " - initials: " + document.getElementById('myinit1').value + document.getElementById('myinit2').value + document.getElementById('myinit3').value;
			    if (document.getElementById('mycolor').value.length > 0){iattr_flds[1].value += " - color: " + document.getElementById('mycolor').value;}
			}

		}else {
		  //choose_mono not checked, monogramming is not desired
		  sku_flds[1].disabled = true;
		  qty_flds[0].disabled = true;
		  iattr_flds[1].disabled = true;
      iattr_flds[0].value = "Monogramming not selected";
		}
	}else if(porder_code=="mono1" || porder_code=="mono2" || porder_code=="mono5" || porder_code=="mono6"){
		if (document.getElementById("choosemono").checked)
		{
		sku_flds[1].disabled = false;
		  qty_flds[0].disabled = false;
		  iattr_flds[1].disabled = false;
			sku_flds[1].value="12";
			//sku_flds[1].value="PAANACFGFNALOGCO";
			qty_flds[0].value="1";
      //give the product they are viewing some text in info_attr1 to indicate that they selected monogramming
      iattr_flds[0].value = "Monogramming selected";
			//gather mono details into info_attr1

			if (porder_code == "mono1")
			{
			    iattr_flds[1].value= "For " + document.getElementById('sku').value + " - name: " + document.getElementById('myname').value;
			    if (document.getElementById('myweight').value.length > 0){iattr_flds[1].value += " - weight: " + document.getElementById('myweight').value;}
			    if (document.getElementById('mylength').value.length > 0){iattr_flds[1].value += " - length: " + document.getElementById('mylength').value;}
			    if (document.getElementById('mybirth').value.length > 0){iattr_flds[1].value += " - birthdate: " + document.getElementById('mybirth').value;}
			    if (document.getElementById('mychristening').value.length > 0){iattr_flds[1].value += " - christening: " + document.getElementById('mychristening').value;}
			}else if (porder_code == "mono2")
			{
//			    iattr_flds[1].value = "For " + document.getElementById('sku').value + " - initials: " + document.getElementById('myinit1').value + document.getElementById('myinit2').value + document.getElementById('myinit3').value;
			    iattr_flds[1].value = "For " + document.getElementById('sku').value + " - initials: " + document.getElementById('myinit1').value;
			    if (document.getElementById('mycolor').value.length > 0){iattr_flds[1].value += " - color: " + document.getElementById('mycolor').value;}
			}else if (porder_code == "mono5")
			{
			    iattr_flds[1].value= "For " + document.getElementById('sku').value + " - name: " + document.getElementById('myname').value;
			}else if (porder_code == "mono6")
			{
			    iattr_flds[1].value= "For " + document.getElementById('sku').value + " - name: " + document.getElementById('myfirstname').value;
			    if (document.getElementById('mymiddlename').value.length > 0){iattr_flds[1].value += " - middlename:" + document.getElementById('mymiddlename').value;}
			    if (document.getElementById('mybirth').value.length > 0){iattr_flds[1].value += " - birthdate:" + document.getElementById('mybirth').value;}
			}

		}else{
		  //choose_mono not checked, monogramming is not desired
		  sku_flds[1].disabled = true;
		  qty_flds[0].disabled = true;
		  iattr_flds[1].disabled = true;
      iattr_flds[0].value = "Monogramming not selected";
		}
	}
//go_alert();
}

// test function
function go_alert()
{
  for(b=0;b<document.form1.elements.length;b++)
  {
    alert(document.form1.elements[b].name+": "+document.form1.elements[b].value);
  }
}
