

/* useless 
function showEditor(id) {
	var container = document.getElementById(id);
	
	if ( container != null ) {
	
			//alert('found');
			
				container.className = 'containerEdit';
				container.contentEditable = true;
				container.designMode = 'on';
			
	
	} else
	{
			alert('unable to find contaioner');
	
	}

}*/
/*rewrited
function GetItems(table) {

	var lastRow = table.rows.length - 1;
	
	var ingredients = document.getElementById('ingredients');
	
	//NOW LETS LOOP OUR ITEMS
	ingredients.value = '';
	
	
	var i = 0;
	for ( i==0; i<=lastRow ;i++)	{
	
			this_row = table.rows[i];
			
			try {
					if ( i != lastRow) {
						ingredients.value = ingredients.value + this_row.cells[0].innerHTML.replace(/,/gi, " ") + ',' + this_row.cells[1].innerHTML.replace(/,/gi, " ") + '||'  ;
					}else
					{
						ingredients.value = ingredients.value + this_row.cells[0].innerHTML.replace(/,/gi, " ")+ ',' + this_row.cells[1].innerHTML.replace(/,/gi, " ") + ''  ;
					}
			} catch( err ) {
			
					//error happened here, move on... theres nothing more to see here.
			
			}
	
	}	

}

rewrited
function DeleteIngredient(index) {

	//GET THE TABLE
	var table = document.getElementById('tbl_ing');
	//Delete the row
	table.deleteRow(index) ;

	GetItems(table);

}



rewrited
function AddIngredient(e_name,e_qty) {
/*e_name.value != '' && e_qty.value != ''*/
/*
if ( 1==1  ) {

	//GET THE TABLE
	var table = document.getElementById('tbl_ing');
	//GET COUNT
	var lastRow = table.rows.length;
	//ADD ROW
	var row = table.insertRow(lastRow);
	

	
	var cell1 = row.insertCell(0);
	var cell2 = row.insertCell(1);
	var cell3 = row.insertCell(2);
	
	cell1.innerHTML = e_name.value;
	cell2.innerHTML = e_qty.value;
	cell3.innerHTML = '<div align="right"><a href="javascript:;" onclick="DeleteIngredient(this.parentElement.parentElement.parentElement.rowIndex)"><img src="/interface/images/gui/icons/trash.gif" border="0" alt="Remove Item" width="12" height="11" /></a></div>';
	
	cell1.style.width = '250px';
	cell2.style.width = '80px';
	cell3.style.width = '20px';
	
	cell1.onmouseover = function() { try { cell1.parentElement.style.color = '#0042FF';  cell1.parentElement.style.cursor = 'pointer'; } catch(err) { void(0); } }
	cell1.onmouseout = function() {  try { cell1.parentElement.style.color = '#000000';  cell1.parentElement.style.cursor = 'default'; } catch(err) { void(0); } }
	
	
	row.onclick = function(){ e_name.value = cell1.innerHTML; e_qty.value = cell2.innerHTML; DeleteIngredient(row.rowIndex); }
	
	
	e_name.value = ''; 
	e_qty.value = '';
	

	GetItems(table);
	
	e_qty.focus();
	
} else
{
	alert('You must add both Ingredient and Quantity.');
}

}
*/


function noenter() {

  if ( window.event.keyCode == 13 ) {
  		
		AddIngredient(document.getElementById('ing_name'),document.getElementById('inc_qty'));
  
  } 
  
  return !(window.event && window.event.keyCode == 13);
  
 
  
}



function checkChar(Ell) {

			Ell.value = Ell.value.replace(/1\/2/gi, '½');
			Ell.value = Ell.value.replace(/half/gi, '½');
			Ell.value = Ell.value.replace(/1\/4/gi, '¼');
			Ell.value = Ell.value.replace(/3\/4/gi, '¾');
			Ell.value = Ell.value.replace(/oC/gi, '°C');
			Ell.value = Ell.value.replace(/celsius/gi, '°C');
			Ell.value = Ell.value.replace('Â', '')
}


function selectContinent( cid ) {

	var e = document.getElementById('Cuisine');
	if ( e != null ) {
	
					e.options.length = 0;
                    
					if ( cid == '6' ) {
					
								e.options.add( new Option('  Other  ','27') , e.options.length);	
					
				   }	
				
	
				   
				   
                   if ( cid == 1 ) {
				   
				   						
								
																	
								
								e.options.add( new Option('  Africa - Central  ','39') , e.options.length);
								
								e.options.add( new Option('  Africa - East  ','35') , e.options.length);
								
								e.options.add( new Option('  Africa - North  ','31') , e.options.length);
								
								e.options.add( new Option('  Africa - Southern  ','34') , e.options.length);
								
								e.options.add( new Option('  Africa - West  ','36') , e.options.length);
								
								e.options.add( new Option('  Egyptian  ','38') , e.options.length);
								
								e.options.add( new Option('  Ghanaian  ','41') , e.options.length);
								
								e.options.add( new Option('  Kenyan  ','42') , e.options.length);
								
								e.options.add( new Option('  Moroccan  ','47') , e.options.length);
								
								e.options.add( new Option('  Nigerian  ','50') , e.options.length);
								
								e.options.add( new Option('  South African  ','55') , e.options.length);
										
											
							
							
				   }
				   
                    
	
				   
				   
                   if ( cid == 3 ) {
				   
				   						
								
																	
								
								e.options.add( new Option('  Asian - Other  ','86') , e.options.length);
								
								e.options.add( new Option('  Chinese  ','91') , e.options.length);
								
								e.options.add( new Option('  Indian  ','92') , e.options.length);
								
								e.options.add( new Option('  Indonesian  ','93') , e.options.length);
								
								e.options.add( new Option('  Japanese  ','97') , e.options.length);
								
								e.options.add( new Option('  Malaysian  ','104') , e.options.length);
								
								e.options.add( new Option('  Thai and SE Asian  ','166') , e.options.length);
								
								e.options.add( new Option('  Turkish / Middle Eastern  ','167') , e.options.length);
										
											
							
							
				   }
				   
                    
	
				   
				   
                   if ( cid == 5 ) {
				   
				   						
								
																	
								
								e.options.add( new Option('  Australian  ','153') , e.options.length);
								
								e.options.add( new Option('  Fiji  ','154') , e.options.length);
								
								e.options.add( new Option('  New Zealand  ','155') , e.options.length);
										
											
							
							
				   }
				   
                    
	
				   
				   
                   if ( cid == 4 ) {
				   
				   						
								
																	
								
								e.options.add( new Option('  Austrian  ','123') , e.options.length);
								
								e.options.add( new Option('  Belgium  ','124') , e.options.length);
								
								e.options.add( new Option('  Dutch  ','137') , e.options.length);
								
								e.options.add( new Option('  English  ','159') , e.options.length);
								
								e.options.add( new Option('  European - Other  ','128') , e.options.length);
								
								e.options.add( new Option('  French  ','129') , e.options.length);
								
								e.options.add( new Option('  German  ','130') , e.options.length);
								
								e.options.add( new Option('  Greek  ','131') , e.options.length);
								
								e.options.add( new Option('  Hungarian  ','132') , e.options.length);
								
								e.options.add( new Option('  Irish  ','161') , e.options.length);
								
								e.options.add( new Option('  Italian  ','134') , e.options.length);
								
								e.options.add( new Option('  Jewish  ','135') , e.options.length);
								
								e.options.add( new Option('  Polish  ','140') , e.options.length);
								
								e.options.add( new Option('  Portuguese  ','141') , e.options.length);
								
								e.options.add( new Option('  Romanian  ','142') , e.options.length);
								
								e.options.add( new Option('  Scandinavian  ','139') , e.options.length);
								
								e.options.add( new Option('  Scottish  ','160') , e.options.length);
								
								e.options.add( new Option('  Spanish  ','147') , e.options.length);
								
								e.options.add( new Option('  Swiss  ','149') , e.options.length);
								
								e.options.add( new Option('  Welsh  ','152') , e.options.length);
										
											
							
							
				   }
				   
                    
	
				   
				   
                   if ( cid == 2 ) {
				   
				   						
								
																	
								
								e.options.add( new Option('  America  ','83') , e.options.length);
								
								e.options.add( new Option('  Argentinian  ','63') , e.options.length);
								
								e.options.add( new Option('  Brazilian  ','66') , e.options.length);
								
								e.options.add( new Option('  Cajun/Creole  ','162') , e.options.length);
								
								e.options.add( new Option('  Canadian  ','67') , e.options.length);
								
								e.options.add( new Option('  Carribean  ','163') , e.options.length);
								
								e.options.add( new Option('  Central / South American  ','165') , e.options.length);
								
								e.options.add( new Option('  Cuban  ','71') , e.options.length);
								
								e.options.add( new Option('  Jamaican  ','77') , e.options.length);
								
								e.options.add( new Option('  Mexican  ','164') , e.options.length);
								
								e.options.add( new Option('  Puerto Rican  ','82') , e.options.length);
										
											
							
							
				   }
				   
                      
					e.options.add( new Option('  Other  ','27') , e.options.length);	 			
	
	}


}

function doValidate( aFrom ) {

	var	result = Spry.Widget.Form.validate(aFrom);
	var note = document.getElementById('errorNote');
	
	if (!result) {
	
		
		if ( note != null ) {
		
			note.innerHTML = 'There was an error with one or more inputs, <br /> please scroll through your form correcting any items and then try again.<br /><br />';
		
		}
	
	} else
	{
	
		if ( note != null ) {
		
			note.innerHTML = '';
		
		}	
	
	}
	
	return result;

}

function Processform(TheForm,Parms){
	
	var p = new String();// create our holding var
		p = String(Parms);
	var f = document.getElementById(TheForm);
	//do we have parametwers?
	if ( Parms != '' ) {
			//ok cool we do, lets run through them and updat ethe form
			var arr = Parms.split(',');
			for (i=0;i<=(arr.length - 1);i++) {			
				
				//split item
				var aItem = arr[i].split('=');
				//find element
				var e = document.getElementById(aItem[0]);
				if ( e != null ) {
					
						if ( aItem[1] != null ) {
							e.value = aItem[1];
							//alert(e.value);
						} else
						{
							e.value = '';
						}
				}
				
			}
		}
		
	if ( f != null ) {
		var r = Spry.Widget.Form.validate(f);
		if ( r ) { f.submit(); } ;
	} else {
		alert('error: unable to find form "' + TheForm + '" !'); 
	}
	
	doValidate(f);

}

/*rewrited 
function loadIngredientsFromSession(){

	var ings = '';
	if ( ings != '' ) {
		var arr	 = ings.split('||');
		for (i=0;i<=(arr.length - 1);i++) {	
			var q = (arr[i].split(',')[1]);
			var p = (arr[i].split(',')[0]);
			document.getElementById('inc_qty').value 	= q;
			document.getElementById('ing_name').value 	= p;
			AddIngredient(document.getElementById('ing_name'),document.getElementById('inc_qty'));
		}
	}

}
*/