<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Get Recipes By Nutrition" 
author="Pat Capozzi"
author_email="patc@recipenutrition.com"
author_affiliation="RecipeNutrition.com"
author_location="Point Roberts, Wa"
screenshot="http://recipenutrition.com/images/rngadget.png"
thumbnail="http://recipenutrition.com/images/rngadgettmb.png"
category="food, nutrition"
description="This great gadget is your window into finding recipes that have better nutrition.  You can search for recipes by calories or percent content of protein, carbs or fat. And all of the recipes that you find you can easily modify to your own special tastes."
title_url="http://recipenutrition.com"
width="300"
height="180" 
scaling="false">
</ModulePrefs>


<Content type="html">
<![CDATA[
<script type="text/javascript" > 

  
  
var itemList = "";  
var recsperlist = 5;  
var list = "";
var recstart = 0;
var recfinish = 5;
var listrecs = 0;
var lineLen = 40
var qtext = "";
  
function SetRecipe(obin,recid){
  
  var retMu 
  if (obin.length>lineLen ){
    retMu  = "<a href='http://recipenutrition.com/recipeFindC.aspx?version=1&recno=" + recid + "-" + obin + "' target='_blank' alt='"+ obin + "' >" + obin.substring(0,lineLen) + "...</a>"
  }  
  else{
    retMu  = "<a href='http://recipenutrition.com/recipeFindC.aspx?version=1&recno=" + recid + "-" + obin + "' target='_blank' alt='" + obin + "' >" + obin + "</a>"
  }
  return retMu
}  
  
function GetRecipes()
{ 
  var filterInt = 0;
  recstart = 0;
  recfinish = recsperlist ;
  document.getElementById('query').className='hide';
  document.getElementById('results').className='show';
  document.getElementById('footer').className='show';
  
  if (document.getElementById('br').checked){
    filterInt = document.getElementById('br').value;
    qtext = 'Breakfast';
  }
  if (document.getElementById('lu').checked){
    filterInt = document.getElementById('lu').value;
     qtext = 'Lunch' ;
  }
  if (document.getElementById('di').checked){
    filterInt = document.getElementById('di').value;
    qtext = 'Dinner';
  }
  if (document.getElementById('si').checked){
    filterInt = document.getElementById('si').value
    qtext = 'Side Dish';    
  }
  if (document.getElementById('de').checked){
    filterInt = document.getElementById('de').value;
    qtext = 'Dessert';  
  }  
  if (document.getElementById('al').checked){
    filterInt = document.getElementById('al').value;
    qtext = 'All';    
  }
 
  var url = "http://recipenutrition.com/recipeServices/RemoteServices.aspx?process=getrecipes&search=" + document.getElementById('qphrase1').value + "&filter=" + filterInt + "&qtype=" + document.getElementById('qtype').value

   _IG_FetchXmlContent(url, function (response) {
          list = response
          itemList = list.getElementsByTagName("Recipe");       
          listrecs = itemList.length
          if (itemList.length == 0){
              _gel('results').innerHTML = "<br>Sorry no records found<br><br>"; 
           }
           else{
            GenList()
          }
         
    });	   
}
 
function GenList(){

   var html = "<div class='list'>";          	
   html +="<div class='recTitle'>";     
   obin =  _gel("qtype");   
   title = _gel('qphrase1').value + "  " +  obin[obin.selectedIndex].text + " - " +  qtext ;   
   // start the markup
   html += title + "</div>";
   
   // Loop through all <Recipe> nodes
   // figure out which records to show
   if (listrecs < recfinish ){
      recfinish = listrecs 
   }
    // Loop through <Recipe> nodes
    for (var i = recstart; i < recfinish ; i++) { 
      // For each <Recipe> node, get child nodes.
      var nodeList = itemList.item(i).childNodes;
      var rec = nodeList.item(0);
      var node = nodeList.item(1);     
      var name  = SetRecipe(node.firstChild.nodeValue,rec.firstChild.nodeValue);  
      html += name +"<br>" 
     } 	
        html += "</div>";
	// Display HTML string in <div>
	_gel('results').innerHTML = html; 
        _gel('results').className = 'resDiv'; 
      if (listrecs >  recfinish){
        recstart = recstart + recsperlist 
        recfinish  = recfinish + recsperlist 
        _gel('more').className='show';
       }
       else{
         _gel('more').className='hide';
        } 	
  } 
   
  function GoBack(){
    document.getElementById('query').className='show';
    document.getElementById('results').className='hide';
    document.getElementById('footer').className='hide';
  }
  
  function ClearSet(){
    _gel('qphrase1').value = "";
    _gel('qphrase1').focus();
  
   }  
 
</script>
<style type="text/css">
.mainTable
{ 
  background-color: #FDF4B9;
  font-size:11;
}
.col1
{
  padding-left:3px;
  padding-top:3px;
  padding-top:4px;
  
  height:20px;
  font-size:13;
}
.col2
{
  
}
.titles
{
  height:30px;
  font-weight: bold;
  font-size:13
}
.hide
{
visibility: hidden;
display: none;
}
.show
{
  visibility: visible;
  display: block;
  background-color: #FDF4B9;
  font-size:13;
  vertical-align:middle;
}
.typerow{
  padding-left:5px;
}
.resDiv{
    height:135px;
    background-color: #FDF4B9;
    font-size:13;
    line-height: 20px;
}
.list{

  padding: 5px;
  background-color: #DDDDFF;
  font-family:Arial, Helvetica;
  text-align:left;
  font-size:90%
}
.recTitle{
    text-align:center;
    color:#000099;
    font-weight:bold;
    font-size:14;
  }
.footer{
  height:30px;
  fon-weight:9px;
  }
</style>
<div id='query'>
<table  border='0' class='mainTable' cellpadding=0 cellspacing=0 width='100%'  >
<tr>
<td class='titles' colspan='4' align='center' >Find Recipes by </td>
</tr>
<tr>
<td align='center' class='typerow' colspan='4' >
<select id='qtype'onchange='ClearSet()' >
<option value="3">Calories/serving</option>
<option value="6">% Calories Protein</option>
<option value="5">% Calories Carbs</option>
<option value="4">% Calories Fat</option>
<option value="1">Word or Phrase</option>
</select>
&nbsp<input id='qphrase1' size=3 ></td>
</tr>
<tr>
  <td align='center' colspan='4'>
    <table border='0'>
      <tr>
        <td class='col1' >
        &nbsp;&nbsp;Breakfast
        </td>
        <td class='col2' >
        <input id='br' type='radio' name='group' value='1'>
        </td>
        <td class='col1' >
        &nbsp;&nbsp;Lunch
        </td>
        <td class='col2' >
        <input id='lu' type='radio' name='group' value='2'>
        </td>
      <tr>
      <tr>
        <td class='col1' >
        &nbsp;&nbsp;Dinner
        </td>
        <td class='col2' >
        <input id='di' type='radio' name='group' value='3'>
        </td>
        <td class='col1' >
        &nbsp;&nbsp;Sides
        </td>
        <td class='col2' >
        <input id='si' type='radio' name='group' value='4'>
        </td>
      </tr>
      <tr>
        <td class='col1'>
        &nbsp;&nbsp;Desert
        </td>
        <td class='col2'>
        <input id='de' type='radio' name='group' value='5'>
        </td>
        <td class='col1'>
        &nbsp;&nbsp;All
        </td>
        <td class='col2'>
        <input id='al' type='radio' checked name='group' value='6'>
        </td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td colspan='4' align='center' >
    
      <input type='button' value='Get Recipes' onclick='GetRecipes()' >
     
  </td>
</tr>

<tr>
<td colspan='4' class='footer' align='center' >Powered by&nbsp;&nbsp;<a href='http://recipenutrition.com' target='_blank' >RecipeNutrition.com</a></td>
</tr>
</table>
</div>
<div class='hide' id='results'>
</div>
<div id='footer' class='hide' >
<table class='mainTable' align='center' border='0' >
  
  <tr>
    <td id='more' align='center' class='hide'>
          <input  type='button' onclick='GenList()' value='More' >  
    </td>
    <td  align='center' >   
          <input  type='button' onclick='GoBack()' value='Back' >
    </td>
  </tr>
  <tr>
    <td colspan='2' align='center' >Powered by&nbsp;&nbsp;<a href='http://recipenutrition.com' target='_blank' >RecipeNutrition.com</a><br /><br /></td>
  </tr>
  </table>
</div>
]]>
</Content>
</Module>







































