// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	
	var myReg = new RegExp("\\b"+c+"\\b");	

	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);

		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName.toLowerCase() == 'class') {
				if(node.attributes.item(j).nodeValue.match(myReg)) {
					eval('node.style.' + p + " = '" + v + "'");
				}
			}
		}
	}
}


var myCook = new Array("braising","grilling","panfrying","potroasting","roasting","stewing","stirfrying");
var myType = new Array("appetizers","entree","pasta","sandwich","stews","soups");
var myCuts = new Array("hip","baron","ponderosa","topround","sirlointip","bottomround","eyeofround","flatround","oxtail","braisingsteaks","sirloin","sirloinbutt","sirloinsteakscenter","sirloinflap","sirloinball","sirlointritip","shortloin","striploin","striploinsteak","tenderloin","tbonesteak","butttenderloin","rib","ribroast","ribroastcoveroff","ribeyesteak","backribs","chuck","chuckroll","shoulder","diced","ground","brisket","brisket","foreshank","ossobucco","shortplate","shortribs","flank","flanksteak","skirtsteak");
var selectedCook = "none";
var selectedType = "none";
var selectedCut = "none";


	function popup(url, name, widgets)
	{
			w = window.open(url, name, widgets);
			w.focus();
			return false;
	} 

	function poprecipe(id,w,h)
	{
		obj = document.getElementById(id);
		if (h === undefined) h = 600;
		if (w === undefined) w = 800;
		return popup(obj.href,obj.target,'width='+w+',height='+h+',toolbar=no,menubar=no,status=no,location=no, directories=no, scrollbars=yes,resizable=yes,screenx=0,screeny=0');
	}

	function recipeNone()
	{

		for (x in myCook)
			setStyleByClass("li", myCook[x] , "display", "none");


		for (x in myType)
		setStyleByClass("span", myType[x] , "display", "none");

		for (x in myCuts)
			setStyleByClass("a", myCuts[x] , "display", "none");
	
	}

	function recipeChanged()
	{

		strCook = document.aspnetForm.lstCook.options[document.aspnetForm.lstCook.selectedIndex].value;
		strType = document.aspnetForm.lstType.options[document.aspnetForm.lstType.selectedIndex].value;
		strCut = document.aspnetForm.lstCut.options[document.aspnetForm.lstCut.selectedIndex].value;


		if(strCook != selectedCook)
		{

			for (x in myCook)
				setStyleByClass("li", myCook[x] , "display", "block");

			for (x in myCook)
				setStyleByClass("li", myCook[x] , "display", "none");

			setStyleByClass("li", strCook , "display", "block");
			selectedCook = strCook;
			
		}

		if(strType != selectedType)
		{
			for (x in myType)
				setStyleByClass("span", myType[x] , "display", "block");

			for (x in myType)
				setStyleByClass("span", myType[x] , "display", "none");

			setStyleByClass("span", strType , "display", "block");
			selectedType = strType;
			
		}

		if(strCut != selectedCut)
		{
			for (x in myCuts)
				setStyleByClass("a", myCuts[x] , "display", "block");

			for (x in myCuts)
				setStyleByClass("a", myCuts[x] , "display", "none");

			setStyleByClass("a", strCut , "display", "block");
			selectedCut = strCut;
			
		}
		
		return true;
	}

	function recipeSelected()
	{
		popup(document.getElementById("lstRecipe").options[document.getElementById("lstRecipe").selectedIndex].value,"Recipe",'width=800,height=600,toolbar=no,menubar=no,status=no,location=no, directories=no, scrollbars=yes,resizable=yes,screenx=0,screeny=0');
		return false;

	}