
var i=1;

var ie4 = document.all;

var ns4 = document.layers;

var ns6 = document.getElementById && !document.all; 

function addMore(){
var theTable = document.getElementById('table_ingrd');

var row_count =   (theTable.rows.length)-1;

  var y = document.createElement('tr');
  var column1 = document.createElement('td');
    var column2 = document.createElement('td');
	  var column3 = document.createElement('td');
	    var column4 = document.createElement('td');
		
		var space = document.createTextNode("");
		
		column4.appendChild(space);
 
  var ingr1 = document.createElement('input');
  	ingr1.setAttribute("type", "text");
	ingr1.setAttribute("name", "ingr_qty_"+i);
	ingr1.name="ingr_qty_"+i;
//	ingr1.setAttribute("value", row_count);
	ingr1.setAttribute("size", "3");
	ingr1.setAttribute("maxlength", "3");
	
	  var ingr2 = document.createElement('select');
	  var  o1 = document.createElement('option');
      var  o2 = document.createElement('option');     
      var  o3 = document.createElement('option');    
      var  o4 = document.createElement('option');   
      var  o5 = document.createElement('option');     
      var  o6 = document.createElement('option');     
      var  o7 = document.createElement('option');      
      var  o8 = document.createElement('option');      
      var  o9 = document.createElement('option');       
      var  o10 = document.createElement('option');      
      var  o11 = document.createElement('option');    
	  
	  o1.appendChild(document.createTextNode('--- select ---'));
	  o2.appendChild(document.createTextNode('teaspoon'));
	  o3.appendChild(document.createTextNode('tablespoon'));
	  o4.appendChild(document.createTextNode('ounce'));
	  o5.appendChild(document.createTextNode('gram'));
	  o6.appendChild(document.createTextNode('cup'));
	  o7.appendChild(document.createTextNode('pint'));
	  o8.appendChild(document.createTextNode('quart'));
	  o9.appendChild(document.createTextNode('gallon'));
	  o10.appendChild(document.createTextNode('liter'));
	  o11.appendChild(document.createTextNode('pound'));
	  
	  o1.setAttribute("value", "");
	  o2.setAttribute("value", "tsp");
	  o3.setAttribute("value", "tbs");
	  o4.setAttribute("value", "oz");
	  o5.setAttribute("value", "gram");
	  o6.setAttribute("value", "cup");
	  o7.setAttribute("value", "pint");
	  o8.setAttribute("value", "qt");
	  o9.setAttribute("value", "gal");
	  o10.setAttribute("value", "lt");
	  o11.setAttribute("value", "lbs");
	  ingr2.setAttribute("name", "ingr_meas_"+i);
	  ingr2.name = "ingr_meas_"+i;
	  ingr2.selectedIndex= 0;
	  
	  ingr2.appendChild(o1);
	  ingr2.appendChild(o2);
	  ingr2.appendChild(o3);
	  ingr2.appendChild(o4);
	  ingr2.appendChild(o5);
	  ingr2.appendChild(o6);
	  ingr2.appendChild(o7);
	  ingr2.appendChild(o8);
	  ingr2.appendChild(o9);
	  ingr2.appendChild(o10);
	  ingr2.appendChild(o11);
	  
	
	  var ingr3 = document.createElement('input');
  	ingr3.setAttribute("type", "text");
	ingr3.setAttribute("name", "ingr_stuff_"+i);
	ingr3.name="ingr_stuff_"+i;
	//ingr3.setAttribute("value", row_count);
	ingr3.setAttribute("size", "31");
	ingr3.setAttribute("maxlength", "128");
	
	/*	  var ingr4 = document.createElement('button');
  	ingr4.setAttribute("type", "button");
	ingr4.setAttribute("id", "remove_"+i);
	ingr4.setAttribute("value", " - ");
	*/

	column1.appendChild(ingr1);
	column2.appendChild(ingr2);
	column3.appendChild(ingr3);
	//column4.appendChild(ingr4);
	
	y.setAttribute("id", i);
  
  y.appendChild(column1);
  y.appendChild(column2);
  y.appendChild(column3);
//  y.appendChild(column4);

if(ns6 || ns4) theTable.appendChild(y);
else 
{
theTable.rows[row_count].appendChild(y);

	//ingr4.onclick = alert('hell');
	

	}
	//ingr4.onclick = function (){deleteRows(this);}

i++;
}

function deleteRows(){
var table = document.getElementById('table_ingrd');
var rows = table.rows.length

		table.deleteRow(rows-1);



}

/////////////////////////////////////////////////////////////////////

function setImage(image)
{
image = document.getElementById(image);


 var path = image.value.toLowerCase();
 var passed = false
 
		 var myRegExp = /(\.jpg)/;
		 if (path.search(myRegExp) != -1){ passed = true;}
		 
		 var myRegExp = /(\.gif)/;
		 if (path.search(myRegExp) != -1){passed = true;} 
		 
		 var myRegExp = /(\.png)/;
		 if (path.search(myRegExp) != -1){passed = true;} 
		 
if(!passed) document.getElementById('image_error1').innerHTML='Image Failed to meet requirements';
else 	 document.getElementById('image_error1').innerHTML='Okay';

if(image.id == "image") document.getElementById('image_url').value='';
/*
else {

		var newFile = document.createElement('input');
		newFile.setAttribute("id", "image");
		newFile.setAttribute("name", "image");
		newFile.setAttribute("type", "file");
		newFile.setAttribute("size", "45");
		newFile.setAttribute("style", "width:385px");

		
		
		
		document.forms('form1').elements[5].parentNode.removeChild(document.forms('form1').elements[5]);
		document.getElementById('image_file').appendChild(newFile);
		

}
*/
 
}

function validate(form){

		if(document.getElementById('title').value == '')
		{
		
			document.getElementById('title_error').innerHTML = "Please enter a title";
			document.getElementById('title_error').style.color = "red";
			return;
		
		}
		else 
		{
			document.getElementById('title_error').innerHTML = "";
		}
		
		if(document.getElementById('body').value == '')
		{
		
			document.getElementById('body_error').innerHTML = "Please enter text for the body";
			document.getElementById('body_error').style.color = "red";
			return;
		
		}
		else
		{
		
		document.getElementById('body_error').innerHTML = "";
		
		}
		
		if(document.getElementById('image_error1').style.display == "none")
		{
		
		//alert(form.name);
		form.submit();
		
		}


}

function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}