var clickedOnSearch = false
//clear search by ingredient field

// keep this script for search of the words
function clearSearchField(field_obj)
{
	if(!clickedOnSearch)
	{
		field_obj.value="";
		clickedOnSearch = true;
	}
}
//hash of form objects
var objectHash = new Array();

//arrays of filtering criteria for recipe search
var SearchByRecipeType = ["Quick and Easy Recipes","Recipes By Shape","Recipes By Season","Recipes By Region","Sauce Type","Vegetarian"];
var RecipesByRegion = ["Abruzzo","Basilicata","Calabria","Campania","Emilia-Romagna","Friuli Venezia Giulia","Lazio","Liguria","Lombardia","Marche","Molise","Piemonte","Puglia","Sardegna","Sicilia","Toscana","Trentino-Alto Adige","Umbria","Valle D'Aosta","Veneto"];
var RecipesByShape = ["Angel Hair","Campanelle","Cellentani","Ditalini","Elbows","Farfalle","Fettuccine","Fettuccine Rigate","Fiori","Gemelli","Jumbo Shells","Large Shells","Lasagne Oven-Ready","Linguine","Linguine Fini","Manicotti","Medium Shells","Mezzi Rigatoni","Mezze Penne","Mostaccioli","Orzo","Pastina","Penne","Pipette","Piccolini\256 Mini Farfalle","Piccolini\256 Mini Fusilli","Piccolini\256 Mini Penne","Piccolini\256 Mini Wheels","Piccolini\256 Mini Ziti", "PLUS\u2122 Angel Hair","PLUS\u2122 Elbows","PLUS\u2122 Farfalle","PLUS\u2122 Penne","PLUS\u2122 Rotini","PLUS\u2122 Spaghetti","PLUS\u2122 Thin Spaghetti","Rigatoni","Rotini","Spaghetti","Spaghetti Rigati","Thick Spaghetti","Thin Spaghetti","Tortellini","Tortelloni","Tri-Color Fiori","Tri-Color Rotini","Wavy Lasagne","Whole Grain Linguine","Whole Grain Medium Shells","Whole Grain Penne","Whole Grain Rotini","Whole Grain Spaghetti","Whole Grain Thin Spaghetti","Ziti"]
var SauceType = ["Tomato-based","Oil-based","Vegetable-based","Meat-based","Seafood-based","Dairy-based"];
var RecipesBySeason = ["Spring","Summer","Autumn","Winter"];
var NonPasta = ["Appetizer (Antipasti)","Main Course (Secondi)","Side Dish (Contorni)","Dessert (Dolci)"];
var TomatoBased = ["Garden Vegetable","Green and Black Olive","Italian Baking Sauce","Marinara","Mushroom and Garlic","Roasted Garlic and Onion", "Spicy Marinara","Sweet Peppers and Garlic","Three Cheese","Tomato and Basil","Other Tomato-Based"];
//hash of criteria arrays
var filterHash = new Array();
filterHash["Recipes By Region"] = RecipesByRegion; 
filterHash["Recipes By Shape"] = RecipesByShape;
filterHash["Sauce Type"] = SauceType;
filterHash["Recipes By Season"] = RecipesBySeason;
filterHash["Non Pasta"] = NonPasta;
filterHash["Tomato-based"] = TomatoBased;



//display left navigation based on filtering criteria 
function displayLeftNav(level2_str, level3_str)
{
	
	
		
	//counters, i for second level, j for third level navigation
	var i,j;
		
	//html code to be written
	var html = "";
	
	//go element by element on the second level
	for(i=0;i<SearchByRecipeType.length;i++)
	{
		
		
		//if the first filtering criteria found
		if (SearchByRecipeType[i] == level2_str)
		{
			
			//if there is a third level for the found criteria
			if(filterHash[level2_str])
			{
				//create button with arrow pointing down
				html += "<span class='leftnav2'><a href='javascript:displayNavHTML(displayLeftNav(\""+SearchByRecipeType[i]+"\",\"\"))' class='on'>"+ SearchByRecipeType[i] +"&nbsp;&nbsp;<img src='/PublishingImages/navarrow_down.gif' border='0' alt='more' /></a></span>";
					
				//for each element in the third navigation
				for (j=0; j<filterHash[level2_str].length;j++)
				{
				
					//if second criteria met, the highlight, if not keep as is
					if (filterHash[level2_str][j] == level3_str)
						html += "<span class='leftnav3'><a href='javascript:RecipeSearchLinks(\""+SearchByRecipeType[i]+"\",\""+filterHash[level2_str][j]+"\")' class='on'>"+ filterHash[level2_str][j] +"</a></span>";
					else	
						html += "<span class='leftnav3'><a href='javascript:RecipeSearchLinks(\""+SearchByRecipeType[i]+"\",\""+filterHash[level2_str][j]+"\")'>"+ filterHash[level2_str][j] +"</a></span>";
				}
			}
			else
				html += "<span class='leftnav2'><a href='javascript:RecipeSearchLinks(\""+SearchByRecipeType[i]+"\",\"\")' class='on'>"+ SearchByRecipeType[i] +"</a></span>";
		}
		else
		{
			//the first criteria was not found
			//if the button has third nav elements, show arrow pointing to the right
			//otherwise just display button
			
			if(filterHash[SearchByRecipeType[i]])
				html += "<span class='leftnav2'><a href='javascript:displayNavHTML(displayLeftNav(\""+SearchByRecipeType[i]+"\",\"\"))'>"+ SearchByRecipeType[i] +"&nbsp;&nbsp;<img src='/PublishingImages/navarrow_right.gif' border='0' alt='more' /></a></span>";
			else
				html += "<span class='leftnav2'><a href='javascript:RecipeSearchLinks(\""+SearchByRecipeType[i]+"\",\"\")'>"+ SearchByRecipeType[i] +"</a></span>";	
		}
	}

	return(html);
}


//display left navigation based on filtering criteria 
function displayLeftNavRecipe(level2_str, level3_str)
{
	
	
		
	//counters, i for second level, j for third level navigation
	var i,j;
		
	//html code to be written
	var html = "";
	
	//go element by element on the second level
	for(i=0;i<SearchByRecipeType.length;i++)
	{
		
		
		//if the first filtering criteria found
		if (SearchByRecipeType[i] == level2_str)
		{
			
			//if there is a third level for the found criteria
			if(filterHash[level2_str])
			{
				//create button with arrow pointing down
				html += "<span class='leftnav2'><a href='javascript:displayNavHTML(displayLeftNavRecipe(\""+SearchByRecipeType[i]+"\",\"\"))' class='on'>"+ SearchByRecipeType[i] +"&nbsp;&nbsp;<img src='/PublishingImages/navarrow_down.gif' border='0' alt='more' /></a></span>";
					
				//for each element in the third navigation
				for (j=0; j<filterHash[level2_str].length;j++)
				{
				
				   //if second criteria met, the highlight, if not keep as is
					if (filterHash[level2_str][j] == level3_str)
						html += "<span class='leftnav3'><a href='javascript:RecipeDetailLinks(\""+SearchByRecipeType[i]+"\",\""+filterHash[level2_str][j]+"\")' class='on'>"+ filterHash[level2_str][j] +"</a></span>";
					else	
						html += "<span class='leftnav3'><a href='javascript:RecipeDetailLinks(\""+SearchByRecipeType[i]+"\",\""+filterHash[level2_str][j]+"\")'>"+ filterHash[level2_str][j] +"</a></span>";
				}
			}
			else
				html += "<span class='leftnav2'><a href='javascript:RecipeDetailLinks(\""+SearchByRecipeType[i]+"\",\"\")' class='on'>"+ SearchByRecipeType[i] +"</a></span>";
		}
		else
		{
			//the first criteria was not found
			//if the button has third nav elements, show arrow pointing to the right
			//otherwise just display button
			
			if(filterHash[SearchByRecipeType[i]])
				html += "<span class='leftnav2'><a href='javascript:displayNavHTML(displayLeftNavRecipe(\""+SearchByRecipeType[i]+"\",\"\"))'>"+ SearchByRecipeType[i] +"&nbsp;&nbsp;<img src='/PublishingImages/navarrow_right.gif' border='0' alt='more' /></a></span>";
			else
				html += "<span class='leftnav2'><a href='javascript:RecipeDetailLinks(\""+SearchByRecipeType[i]+"\",\"\")'>"+ SearchByRecipeType[i] +"</a></span>";	
		}
	}

	return(html);
}



//initialize search form when onload event triggered
function makeForms()
{
	if(document.forms[0] != null)
	{
		document.forms[0].elements.drop1.selectedIndex = 0;
		document.forms[0].elements.drop2.disabled=true;
		document.forms[0].elements.drop2.style.color = "#666666";
		document.forms[0].elements.drop3.disabled=true;
		document.forms[0].elements.drop3.style.color = "#666666";
	}
			
	//instatiate form objects
//	for(i=0;i<document.forms.length;i++)
//	{
//		objectHash[document.forms[i].name] = new validator_obj(document.forms[i]);
//
//	}
}

function makeFormsHomePage()
{


if (document.getElementById("UserLabel") == null)
	{		
		return;
	}
	

if (getCookie("UserName")) 
  {
		document.getElementById("UserLabel").innerHTML = getCookie("UserName");							
		document.getElementById("loginAlert").style.display = "none";
	 	document.getElementById("LoginIDBox").style.visibility = "visible";
		document.getElementById("SignUpLabel").innerHTML = "Go To Your Recipe Box";			
		document.getElementById("newsletterButton").style.visibility = "hidden";
	
  }
else
  {  	
		document.getElementById("loginAlert").style.visibility = "visible";
	    document.getElementById("LoginIDBox").style.display = "none";
		document.getElementById("SignUpLabel").innerHTML = "Sign Up";
  }

}

// keep this form
function tomatoDropDown(selection_str)
{
		if(selection_str=="Tomato-based")
		{
				for(i=document.forms[0].elements.drop3.options.length-1;i>0;i--)
				{
					document.forms[0].elements.drop3.options[i] = null;
				}

				document.forms[0].elements.drop3.disabled=false;
				document.forms[0].elements.drop3.style.color = "#000000";
				
				document.forms[0].elements.drop3.options[0].text = "Select Tomato Sauce";
				
				for(i=0;i<TomatoBased.length;i++)
				{
					var optionToAdd = new Option(TomatoBased[i],TomatoBased[i],false,false);
					document.forms[0].elements.drop3.options[i+1] = optionToAdd;					
				}


		}
		else
		{
			document.forms[0].elements.drop3.disabled=true;
			document.forms[0].elements.drop3.style.color = "#000000";							
			
			for(i=document.forms[0].elements.drop3.options.length-1;i>0;i--)
			{
				document.forms[0].elements.drop3.options[i] = null;
			}

			document.forms[0].elements.drop3.options[0].text = "Select...";


		}
}

//drow dropdowns for second select element of the recipe search form
//keep this function
function enableDropDown(selection_str)
{
	var i;
				
	if(selection_str!="")
	{
		
		for(i=document.forms[0].elements.drop2.options.length-1;i>0;i--)
		{
			document.forms[0].elements.drop2.options[i] = null;
		}
					
		for(i=document.forms[0].elements.drop3.options.length-1;i>0;i--)
		{
			document.forms[0].elements.drop3.options[i] = null;
		}
				
		
		switch (selection_str)
		{
			//Recipes By Shape has been chosen
			case "Recipes By Shape":
				
				document.forms[0].elements.drop2.disabled=false;
				document.forms[0].elements.drop2.style.color = "#000000";							
				
				document.forms[0].elements.drop2.options[0].text = "Select Shape";
				
				for(i=0;i<RecipesByShape.length;i++)
				{
					var optionToAdd = new Option(RecipesByShape[i],RecipesByShape[i],false,false);
					document.forms[0].elements.drop2.options[i+1] = optionToAdd;										
				}
				
			break;
			
			case "Recipes By Season":
					
				document.forms[0].elements.drop2.disabled=false;
				document.forms[0].elements.drop2.style.color = "#000000";							
				
				document.forms[0].elements.drop2.options[0].text = "Select Season";
				
				for(i=0;i<RecipesBySeason.length;i++)
				{
					var optionToAdd = new Option(RecipesBySeason[i],RecipesBySeason[i],false,false);
					document.forms[0].elements.drop2.options[i+1] = optionToAdd;
				}				
				
			break;
			
			case "Recipes By Region":
				
				document.forms[0].elements.drop2.disabled=false;
				document.forms[0].elements.drop2.style.color = "#000000";
				
				document.forms[0].elements.drop2.options[0].text = "Select Region";
				
				for(i=0;i<RecipesByRegion.length;i++)
				{
					var optionToAdd = new Option(RecipesByRegion[i],RecipesByRegion[i],false,false);
					document.forms[0].elements.drop2.options[i+1] = optionToAdd;					
				}
					
			break;
			
			case "Sauce Type":				

				document.forms[0].elements.drop2.disabled=false;
				document.forms[0].elements.drop2.style.color = "#000000";
				
				document.forms[0].elements.drop2.options[0].text = "Select Sauce Type";
				
				for(i=0;i<SauceType.length;i++)
				{
					var optionToAdd = new Option(SauceType[i],SauceType[i],false,false);
					document.forms[0].elements.drop2.options[i+1] = optionToAdd;					
				}
								
			break;

			case "Non Pasta":								

				document.forms[0].elements.drop2.disabled=false;
				document.forms[0].elements.drop2.style.color = "#000000";				
				document.forms[0].elements.drop2.options[0].text = "Select Non Pasta";

				document.forms[0].elements.drop3.options[0].text = "Select...";				
				document.forms[0].elements.drop3.disabled=true;
				document.forms[0].elements.drop3.style.color = "#666666";	
				
				for(i=0;i<NonPasta.length;i++)
				{
					var optionToAdd = new Option(NonPasta[i],NonPasta[i],false,false);
					document.forms[0].elements.drop2.options[i+1] = optionToAdd;					
				}
								
			break;
			

			//kill second dropdown
			default:
				document.forms[0].elements.drop2.options[0].text = "Select...";
				
				document.forms[0].elements.drop2.disabled=true;
				document.forms[0].elements.drop2.style.color = "#666666";		

				document.forms[0].elements.drop3.options[0].text = "Select...";				
				document.forms[0].elements.drop3.disabled=true;
				document.forms[0].elements.drop3.style.color = "#666666";		

			break;
			
		}	

	}	
	else
	{
		if(!document.forms[0].elements.drop2.disabled)
		{
			for(i=1;i<document.forms[0].elements.drop2.options.length;i++)
			{
				document.forms[0].elements.drop2.options[i] = null;
			}
			document.forms[0].elements.drop2.disabled=true;
			document.forms[0].elements.drop2.style.color = "#666666";		

			for(i=1;i<document.forms[0].elements.drop3.options.length;i++)
			{
				document.forms[0].elements.drop3.options[i] = null;
			}
			document.forms[0].elements.drop3.disabled=true;
			document.forms[0].elements.drop3.style.color = "#666666";		

		}	
	}	
}


//validation object
function validator_obj(form_obj)
{
	//form to be validated, form object
	this._form = form_obj;
	
	//error message, string
	this._errorMessage="";
	
	//container for error message, window object (id)
	this._container;
}

//display message
validator_obj.prototype.displayErrorMessage = function()
{

	//insert error message
	document.getElementById(this._container).innerHTML = this._errorMessage;
	//display error message
	showLayer(gLayer(this._container));

}

//hide message and reset
validator_obj.prototype.hideErrorMessage = function()
{

	//reset error message
	this._errorMessage = "&#nbsp;"
	
	//hide error message
	hideLayer(gLayer(this._container));

}


//validate form
validator_obj.prototype.validate = function(layer_id,action_str)
{
	//set container to display error message
	this._container = layer_id;
	
	//reset/hide previous messages
	this.hideErrorMessage();
	
	//select from existing forms
	switch (this._form.name)
	{
		case "byingredient":
		
			if(this._form.elements.drop2.value=="" || !clickedOnSearch)
			{
				this._errorMessage="Please enter ingredient!";
				this.displayErrorMessage();
			}
			else
			{
				var space_re = /\s+/g;
				
				this._form.elements.drop2.value=Trim(this._form.elements.drop2.value.replace(space_re," "));
				this._form.action=action_str;
				this._form.method="Post";
				this._form.submit();
									
			}	
		break;
	
		case "bycategory":
			
			//no category selected
			if(this._form.elements.drop1.value=="")
			{
				this._errorMessage="Please make a selection!";
				this.displayErrorMessage();
			}
			else
			{
				
				//category selected but second category is enabled 
				if((this._form.elements.drop2.value=="")&&(!this._form.elements.drop2.disabled))
				{
					this._errorMessage="Please make a selection.";
					this.displayErrorMessage();
				}
				else if((this._form.elements.drop3.value=="")&&(!this._form.elements.drop3.disabled))
				{
					this._errorMessage="Please make a selection.";
					this.displayErrorMessage();
				}
				else
				{
					this._form.action=action_str;
					this._form.method="Post";
					this._form.submit();					
				}					
			}
		break;
		
		case "productsearch":
			if(this._form.elements.product.value=="")
			{
				this._errorMessage="Please make a selection.";
				this.displayErrorMessage();
			}
			else
			{
				
				if(this._form.elements.zip.value=="" || !validateInteger(this._form.elements.zip.value) || (this._form.elements.zip.value.length<5))
				{
					this._errorMessage="Please enter a valid zip code.";
					this.displayErrorMessage();
				}
				else
					popUpProductSearch("productsearch.aspx?"+this._form.elements.product.value+"&"+this._form.elements.zip.value);				
			}		
		break;
	
	}

}


var productSearch;

//open product search window
function popUpProductSearch(url_str) 
{	
	
		
	if(!detect_obj.is_mac && productSearch != null)
	{
		productSearch.close();
	}	
	
		
	productSearch = window.open(url_str,"productSearch","fullscreen=no,toolbar=np,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=no,width=600,height=400");
	productSearch.focus();
	
}

/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}


//populates recipe search fields with data and submits form(s)
//will be called from the leftnav
function RecipeSearchLinks(SearchType,Filter)
{
	//populate form
	
	var PiccoliniType = "Piccolini";	
	var newPiccoliniType = Filter.replace("Piccolini\256",PiccoliniType);	
			
	Filter = newPiccoliniType; 

	document.forms[0].elements.drop1.value=SearchType;
	enableDropDown(SearchType);
	
	if(Filter!="")
	{
		document.forms[0].elements.drop2.value=Filter;		
	}	
	
	document.forms[0].action="../../Pages/recipesearch.aspx?drop1=" +SearchType+"&drop2=" + Filter;
	document.forms[0].method="Post";
	document.forms[0].submit();		
}

function RecipeDetailLinks(SearchType,Filter)
{
	//populate form
	
	var PiccoliniType = "Piccolini";	
	var newPiccoliniType = Filter.replace("Piccolini\256",PiccoliniType);	
			
	Filter = newPiccoliniType; 

	
	document.forms[0].elements.drop1.value=SearchType;
	enableDropDown(SearchType);
	
	if(Filter!="")
	{
		document.forms[0].elements.drop2.value=Filter;		
	}	
	
	document.forms[0].action="../../Pages/recipesearch.aspx?drop1=" +SearchType+"&drop2=" + Filter;
	
	document.forms[0].method="Post";
	document.forms[0].submit();		
}

function displayNavHTML(html_str)
{
	document.getElementById("leftnavcontainer").innerHTML = html_str;
}




function validateInteger(strValue) 
{
/************************************************
DESCRIPTION: Validates that a string contains only
    valid integer number.

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
******************************************************************************/
  var objRegExp  = /(^-?\d\d*$)/;

  //check for integer characters
  return objRegExp.test(strValue);
}

// keep this script for search of the words
function recipesearchredirect()
{

	if(document.forms[0].elements.txt_ind.value!="")
	{
		//window.open("recipesearch.aspx?keyword=" + document.forms[0].elements.txt_ind.value)
		//location.href= "http://sr036047:8080/bar/Pages/recipesearch.aspx?keyword=" + document.forms[0].elements.txt_ind.value; 
		location.href = "http://www.barillaus.com/Pages/recipesearch.aspx?drop1=Ingredient&drop2=" + document.forms[0].elements.txt_ind.value; 
	}
	else
	{
	document.getElementById("searchrecipeformerror").innerHTML = "Please enter ingredient!";
	document.getElementById("searchrecipeformerror").style.visibility = "visible";
	}	
}

// keep this script for search of the words
function recipecategorysearchredirect()
{
	
		if(document.forms[0].elements.drop1.value=="All Recipes")
				{
				//document.getElementById("searchrecipeformerror").innerHTML = "Please make a selection.";
				//document.getElementById("searchrecipeformerror").style.visibility = "visible";
				location.href= "http://www.barillaus.com/Pages/recipesearch.aspx?drop1=" + document.forms[0].elements.drop1.value ; 
      			}
			else
				{
				
				//category selected but second category is enabled 
				if((document.forms[0].elements.drop2.value=="")&&(!document.forms[0].elements.drop2.disabled))
				{
					document.getElementById("searchrecipeformerror").innerHTML = "Please make a selection.";
					document.getElementById("searchrecipeformerror").style.visibility = "visible";

				}
				else if((document.forms[0].elements.drop3.value=="")&&(!document.forms[0].elements.drop3.disabled))
				{
					document.getElementById("searchrecipeformerror").innerHTML = "Please make a selection.";
					document.getElementById("searchrecipeformerror").style.visibility = "visible";

				}
				else
				{

					var PiccoliniType = "Piccolini"
					var Filter = document.forms[0].elements.drop2.value;
					var newPiccoliniType = Filter.replace("Piccolini\256",PiccoliniType);		
	    
				    
					location.href= "http://www.barillaus.com/Pages/recipesearch.aspx?drop1=" + document.forms[0].elements.drop1.value + "&drop2="+newPiccoliniType+"&drop3="+document.forms[0].elements.drop3.value; 
				
				}					
			}
	
} 

//keep this function
function productredirect()
{
		if(document.forms[0].elements.product.value=="")
			{
				document.getElementById("searchproductformerror").innerHTML = "Please make a selection.";
				document.getElementById("searchproductformerror").style.visibility = "visible";

			}
			else
			{
				
				if (document.forms[0].elements.zip.value=="" || !validateInteger(document.forms[0].elements.zip.value)  )
					
				{
					document.getElementById("searchproductformerror").innerHTML = "Please enter a valid zip code.";
					document.getElementById("searchproductformerror").style.visibility = "visible";

				}
				else
				{
					
					document.getElementById("searchproductformerror").style.visibility = "hidden";
					productSearch = window.open("http://apps.barillaus.com/productsearch.aspx?"+document.forms[0].elements.product.value+"&"+document.forms[0].elements.zip.value,"productSearch","fullscreen=no,toolbar=np,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=no,width=600,height=400");
					
				}
			}		

}
 

//keep this function
function getCookie(name) 
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


//keep this function 
function checkIframe(){ 
var url=location.href.split('?'); 
if(url.length>1){ 
//var url=location.href.split('/'); 
var iFrame="http://apps.barillaus.com/recipesearch.aspx?" + url[url.length-1]; 
//alert(iFrame);
document.getElementById('ifr').setAttribute('src',iFrame) 
} 
} 


function checkIframeunsubscribe(){ 
var url=location.href.split('?'); 
if(url.length>1){ 
//var url=location.href.split('/'); 
var iFrame="http://apps.barillaus.com/unsubscribe.aspx?" + url[url.length-1]; 
//alert(iFrame);
document.getElementById('ifr').setAttribute('src',iFrame) 
} 
} 


function checkIframeactivate(){ 
var url=location.href.split('?'); 
if(url.length>1){ 
//var url=location.href.split('/'); 
var iFrame="http://apps.barillaus.com/newsletter_activate.aspx?" + url[url.length-1]; 
//alert(iFrame);
document.getElementById('ifr').setAttribute('src',iFrame) 
} 
} 


function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=" + "; expires=" + cookie_date.toGMTString();
//  document.cookie = "UserName=" + "; expires=" + cookie_date.toGMTString();
//  document.cookie = "UserName=Kitty" + "; expires=" + cookie_date.toGMTString();

}
 

	function logoutcookie()
	{
 
//	alert( get_cookie ("UserName"));

 	delete_cookie("UserName");
// 	delete_cookie("UserName");
// 	delete_cookie("UserName");
  	
//	alert(document.cookie);
	}


function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}

function showrecipemenu()
{
	document.getElementById('recipemenu').style.visibility = 'visible';
	document.getElementById('recipemenu').style.dispay = 'block';	
		
	if (getCookie("UserName")) 
  	{	
  		document.getElementById('sendtorecipebox').style.visibility = 'visible';
		document.getElementById('sendtorecipebox').style.dispay = 'block';	
		document.getElementById("ifr2").style.height= "20px";
		document.getElementById("ifr2").style.visibility = 'visible';
	}
	else
	{
		document.getElementById('sendtorecipebox').style.visibility = 'hidden';	
		document.getElementById('sendtorecipebox').style.dispay = 'none';
		document.getElementById("ifr2").style.height= "1px";
		document.getElementById("ifr2").style.visibility = 'hidden'		
	}
		
	var style2 = document.getElementById('recipemenu').style;
	style2.display = style2.display? "":"block";	

}


function fillrecipefields(title, details, ingredients, instructions, full)
{	
    var hiddenbox = document.getElementById("recipetitle");
    hiddenbox.value = title;
    
   	var hiddendetail = document.getElementById("details");
    hiddendetail.value = details;
    
    var hiddeningredients = document.getElementById("ingredientlist");
    hiddeningredients.value = ingredients;    
    
    var hiddeninstructions = document.getElementById("directions");
    hiddeninstructions.value = instructions;    
    
   	var hiddenfull = document.getElementById("full");
    hiddenfull.value = full;    

}

