var jsDisabledVar
function jsDisabled(){
    if(document.getElementById('jsDisabled').style.display == 'block')
    {jsDisabledVar = true}
    else {jsDisabledVar = false}
    //alert(jsDisabledVar);
}

var whichCat
var whichOne
var activeOne
var thumbOn = "_T_on.jpg"
var thumbOff = "_T.jpg"
var stay
var stayOn
var thumbSource ="/images/RecipesTips/RecipeCards_Thumbs/"
var numFeaturedThumbs = '5'; //Total number of thumbnails
var currentCat
var currentNameCat
var currentName
var currentTitle
var currentLeftMenu
var currentFeatured
var currentFeatured1
var currentFeatured2
var currentFeatured3
var currentFeatured4
var currentFeatured5
var currentRecipe
var highlightFeature
var selectedName
var rateRecipeName
var rateRecipeTitle
var rateRecipeIndexOriginal = ''
var rateRecipeIndex
var rateRecipeURL
highlightFeature = '22';//This is the default recipe/recipesList # of the featured recipe

recipeCats = new Array()
   recipeCats[0] = "Holiday"; 
   recipeCats[1] = "Beverages"; 
   recipeCats[2] = "Salads"; 
   recipeCats[3] = "Breads"; 
   recipeCats[4] = "Sauces";
   recipeCats[5] = "Desserts";
   recipeCats[6] = "Breakfast";
   recipeCats[7] = "Entrees";
   recipeCats[8] = "Jams & Jellies";

/*  Recipe ID                         cat, nameCat,  name,    Title,  featured number */
	var recipesList = new Array();  
	recipesList[0]  = new recipesInfo('0','empty0','empty','empty','0');  
	recipesList[1]  = new recipesInfo('0','PeanutButterCookies0','PeanutButterCookies','Peanut Butter Cookies','0');  
	recipesList[2]  = new recipesInfo('0','ZucchiniBread0','ZucchiniBread','Autumn Zucchini Bread','0');  
	recipesList[3]  = new recipesInfo('0','ChocolateMousse0','ChocolateMousse','Chocolate Mousse','0');  
	recipesList[4]  = new recipesInfo('0','MuffinTops0','MuffinTops','Morning Muffin Tops','0');  
	recipesList[5]  = new recipesInfo('1','ChaiTea1','ChaiTea','Himalayan Chai Tea','0'); 
	recipesList[6]  = new recipesInfo('1','MochaFrappe1','MochaFrappe','Mocha Soymilk Frappe','0'); 
	recipesList[7]  = new recipesInfo('1','BerryEnergyShake1','BerryEnergyShake','Berry Energy Shake','0');
	recipesList[8]  = new recipesInfo('1','GingerAle1','GingerAle','Low Cal Ginger Ale','3');
	recipesList[9]  = new recipesInfo('1','CreamSoda1','CreamSoda','Low Cal Cream Soda','0');
	recipesList[10] = new recipesInfo('2','RoastedPears2','RoastedPears','Roasted Pear Salad','0');  
	recipesList[11] = new recipesInfo('2','PanSearedAhiTuna2','PanSearedAhiTuna','Pan Seared Ahi Tuna','0');  
	recipesList[12] = new recipesInfo('2','GreenAppleSalad2','GreenAppleSalad','Green Apple Salad','4');  
	recipesList[13] = new recipesInfo('3','MuffinTops3','MuffinTops','Morning Muffin Tops','0');  
	recipesList[14] = new recipesInfo('3','ZucchiniBread3','ZucchiniBread','Autumn Zucchini Bread','0');  
	recipesList[15] = new recipesInfo('3','IrishSodaBread3','IrishSodaBread','Irish Soda Bread','0');  
	recipesList[16] = new recipesInfo('4','SteviaHoneyAioli4','SteviaHoneyAioli','Stevia Honey Aioli','0');  
	recipesList[17] = new recipesInfo('5','PeanutButterCookies5','PeanutButterCookies','Peanut Butter Cookies','0');  
	recipesList[18] = new recipesInfo('5','ChocolateMousse5','ChocolateMousse','Chocolate Mousse','0');  
	recipesList[19] = new recipesInfo('5','StrawberrySwirlCheesecake5','StrawberrySwirlCheesecake','Swirl Cheesecake','0');  
	recipesList[20] = new recipesInfo('5','RedVelvetCupcakes5','RedVelvetCupcakes','Red Velvet Cupcakes','5');  
	recipesList[21] = new recipesInfo('6','ChaiTea6','ChaiTea','Himalayan Chai Tea','0'); 
	recipesList[22] = new recipesInfo('6','Muesli6','Muesli','German-Style Muesli','0');  
	recipesList[23] = new recipesInfo('6','MochaFrappe6','MochaFrappe','Mocha Soymilk Frappe','0'); 
	recipesList[24] = new recipesInfo('6','BerryEnergyShake6','BerryEnergyShake','Berry Energy Shake','0');
	recipesList[25] = new recipesInfo('0','RoastedPears0','RoastedPears','Roasted Pear Salad','0');  
	recipesList[26] = new recipesInfo('0','SteviaHoneyAioli0','SteviaHoneyAioli','Stevia Honey Aioli','0');  
	recipesList[27] = new recipesInfo('5','GingerCookie5','GingerCookie','Ginger Cookies','0');
	recipesList[28] = new recipesInfo('5','PumpkinPie5','PumpkinPie','Awesome Pumpkin Pie','0');
	recipesList[29] = new recipesInfo('0','PumpkinPie0','PumpkinPie','Awesome Pumpkin Pie','0');  
	recipesList[30] = new recipesInfo('5','ChocolateChipBrownies5','ChocolateChipBrownies','Chocolate Chip Brownies','0');  
	recipesList[31] = new recipesInfo('0','ChocolateChipBrownies0','ChocolateChipBrownies','Chocolate Chip Brownies','0');  
	recipesList[32] = new recipesInfo('5','PearTart5','PearTart','Pear Tart','0');  
	recipesList[33] = new recipesInfo('0','PearTart0','PearTart','Pear Tart','0');  
	recipesList[34] = new recipesInfo('5','AlmondMacaroons5','AlmondMacaroons','Almond Macaroons','0');  
	recipesList[35] = new recipesInfo('5','Pinwheelcookies5','Pinwheelcookies','Pinwheel Cookies','0');  
	recipesList[36] = new recipesInfo('5','Vanillaspritzcookies5','Vanillaspritzcookies','Vanilla Spritz Cookies','0');  
	recipesList[37] = new recipesInfo('0','GingerCookie0','GingerCookie','Ginger Cookies','0');
	recipesList[38] = new recipesInfo('0','StrawberrySwirlCheesecake0','StrawberrySwirlCheesecake','Swirl Cheesecake','0');  
	recipesList[39] = new recipesInfo('0','ChaiTea0','ChaiTea','Himalayan Chai Tea','0'); 
    recipesList[40] = new recipesInfo('0','RedVelvetCupcakes0','RedVelvetCupcakes','Red Velvet Cupcakes','0');  
	recipesList[41] = new recipesInfo('1','Lemonade1','Lemonade','Lemonade','0');  
	recipesList[42] = new recipesInfo('5','CremeBrulee6','CremeBrulee','Creme Brulee','0');  
	recipesList[43] = new recipesInfo('5','FourthOfJulyCelebrationCake5','FourthOfJulyCelebrationCake','Fourth of July Celebration Cake','0');  
	recipesList[44] = new recipesInfo('5','FrozenFruitPops5','FrozenFruitPops','Frozen Fruit Pops','0');  
	recipesList[45] = new recipesInfo('4','SweetNTangyBBQSauce4','SweetNTangyBBQSauce','Sweet \'N Tangy BBQ','0');  
	recipesList[46] = new recipesInfo('1','IcedTeaCocktail1','IcedTeaCocktail','Iced Tea Cocktail','0');  
	recipesList[47] = new recipesInfo('2','RockinBroccoli2','RockinBroccoli','Rockin\' Broccoli ','0');  
	recipesList[48] = new recipesInfo('1','SpicedIcedCoffeeChiller1','SpicedIcedCoffeeChiller','Spiced Iced Coffee&nbsp;Chiller','0');  
	recipesList[49] = new recipesInfo('2','BlackberryBalsamicSaladDressing2','BlackberryBalsamicSaladDressing','Blackberry Balsamic Salad Dressing','0');  
	recipesList[50] = new recipesInfo('5','FrozenStrawberryPecanSquares5','FrozenStrawberryPecanSquares','Frozen Strawberry Pecan&nbsp;Squares','0');  
    recipesList[51] = new recipesInfo('5','ChocolateTruffles5','ChocolateTruffles','Chocolate Truffles','0'); 
    recipesList[52] = new recipesInfo('7','CocktailMeatballs7','CocktailMeatballs','Cocktail Meatballs','2'); 
    recipesList[53] = new recipesInfo('5','CranberryApplePie5','CranberryApplePie','Cranberry Apple&nbsp;Pie','0'); 
    recipesList[54] = new recipesInfo('1','DoubleHotChocolate1','DoubleHotChocolate','Double Hot Chocolate','0'); 
    recipesList[55] = new recipesInfo('6','FrenchToastWithFreshBerrySalsa6','FrenchToastWithFreshBerrySalsa','French Toast With Fresh Berry&nbsp;Salsa','0'); 
    recipesList[56] = new recipesInfo('5','GingerbreadCupcakes5','GingerbreadCupcakes','Gingerbread Cupcakes','0'); 
    recipesList[57] = new recipesInfo('5','GingerPearCrisp5','GingerPearCrisp','Ginger Pear Crisp','0'); 
    recipesList[58] = new recipesInfo('1','HolidayEggNog1','HolidayEggNog','Holiday Egg Nog','1'); 
    recipesList[59] = new recipesInfo('7','PorkChopsInRosemaryApricotSauce7','PorkChopsInRosemaryApricotSauce','Pork Chops in Rosemary Apricot Sauce','0'); 
    recipesList[60] = new recipesInfo('5','VanillaCreamCheeseFrosting5','VanillaCreamCheeseFrosting','Vanilla Cream Cheese Frosting','0'); 
    recipesList[61] = new recipesInfo('8','OrangeBlueberryPreserves8','OrangeBlueberryPreserves','Orange-Blueberry Preserves','0'); 
    recipesList[62] = new recipesInfo('8','ApricotPearPreserves8','ApricotPearPreserves','Apricot-Pear Preserves','0'); 
    recipesList[63] = new recipesInfo('8','SpicedAppleButter8','SpicedAppleButter','Spiced Apple Butter','0'); 
    recipesList[64] = new recipesInfo('8','FreezerStrawberryPreserves8','FreezerStrawberryPreserves','Freezer Strawberry Preserves','0'); 



function checkThumbs(){
     for (var i=1;i<=5;i++){
            //alert(i);
            turnOnThumb = document.getElementById('featuredImg' + i).src;
            if (turnOnThumb.search(selectedName) != -1){
                document.getElementById('featuredImg' + i).src=thumbSource + selectedName + '_T_on.jpg';
                }
        }
} 

function recipesInfo( cat, nameCat, name, Title, featured ) {  
    this.cat = cat;
    this.nameCat = nameCat;
    this.name = name;
    this.title = Title;
    this.featured = featured;
}

function changeCat(category){
//if(document.location.href.search('Recipes-and-Tips') != -1)
//{
    whichCat=category;
    //alert(whichCat);
    /* If the category is 'already' opened, close it */
    if(document.getElementById(whichCat).style.display == "block")
        {//alert('was it already block?');
        document.getElementById(whichCat + '_Link').style.color='#547F09';
        for (var i=0;i<=recipeCats.length-1;i++)
            {  
                if (whichCat.search([i]) != -1){
                    document.getElementById(whichCat + '_Link').innerHTML=recipeCats[i];
                    document.getElementById(whichCat).style.display = "none";
                    }
             }
        }
    /* Else close all unselected categories, open up the new selected category */
    else {//alert('in the else');
            for (var i=0;i<=recipeCats.length-1;i++)
            {   
                //alert(recipeCats[i]);
                /* Close all unselected CATEGORIES */   
                if ('Cat' + [i] != whichCat){
                    document.getElementById('Cat' + [i] + '_Link').innerHTML=recipeCats[i];
                    document.getElementById('Cat' + [i] + '_Link').style.color='#547F09';
                    document.getElementById('Cat' + [i]).style.display = "none";
                    document.getElementById('Cat' + [i] + '_Link').onmouseover = function()
                        {this.style.color = '#FE9F2B';};
                    document.getElementById('Cat' + [i] + '_Link').onmouseout = function()
                        {this.style.color = '#547F09';};
                    document.getElementById(whichCat).style.display = "none";
                } 
                
                else if ('Cat' + [i] == whichCat){
                    document.getElementById(whichCat + '_Link').style.onmouseover = function()
                        {document.getElementById(whichCat + '_Link').style.color = '#FF6600';};
                    document.getElementById(whichCat + '_Link').style.onmouseout = function()
                        {document.getElementById(whichCat + '_Link').style.color = '#FF6600';};
                    document.getElementById(whichCat + '_Link').style.color='#FF6600';
                    // FOR IE FIX //
                    //alert(document.getElementById(whichCat + '_Link').innerHTML);
                    document.getElementById(whichCat + '_Link').innerHTML='<span style="color:#FF6600;">' + recipeCats[i] + '</span>'; 
                }
             }
             document.getElementById(whichCat + '_Link').className="catHeadOn";
             document.getElementById(whichCat).style.display='block';
             document.getElementById(whichCat + '_Link').style.color='#FF6600';
       }  
    //}  
    //else{alert('Not the recipe page')}
}

function rolloverRecipe(thisOne){
    //alert(selectedName);
    //alert(thisOne.id);
    
    if(document.location.href.search('Recipes') != -1){
        if (thisOne.id.search(selectedName) == -1){
            //alert('over');
            thisOne.style.color='#FE9F2B';
            //alert(thisOne.id);
            //put up recipe image on rollover
                for (var i=recipesList.length-1;i>=0;i--){
                    if (thisOne.id.search(recipesList[i].name) != -1){
                        currentName=recipesList[i].name;
                        document.getElementById('featuredFrame').src=thumbSource + currentName + ".jpg";
                        //alert(recipesList[i].name);
                        break;
                    }
                }
            }
        }
    else {thisOne.style.color='#FE9F2B';
            
         }
}

function rolloutRecipe(thisOne){
        //alert(selectedName);
        //alert(thisOne.id);
    if(document.location.href.search('Recipes') != -1){
        if (thisOne.id.search(selectedName) == -1){
            //alert('out');
            thisOne.style.color='#547F09';
            //alert(selectedName + " selectedName");
            document.getElementById('featuredFrame').src=thumbSource + selectedName + ".jpg";
            //alert(selectedName);
            /*
            if (currentName == 'empty')
            {
                stay=recipesList[highlightFeature].name;//alert(stay);
            }
                else 
            {stay=currentName;alert(stay + " stay")}
            */

            //take down recipe image on rollout
                //document.getElementById('featuredFrame').src=thumbSource + currentName + ".jpg";
            //alert(thisOne);
            }
        }
    else {thisOne.style.color='#547F09';}
}

function rateRecipe(){
	for (var i=recipesList.length-1;i>=0;i--){
		if (recipesList[i].name.search(selectedName)!= -1){
			rateRecipeName = recipesList[i].name;
			rateRecipeTitle = recipesList[i].title;
			rateRecipeIndex = [i];
			rateRecipeURL='/RecipeRating.aspx?name=' + rateRecipeName + '&index=' + rateRecipeIndex +'&KeepThis=true&TB_iframe=true&height=342&amp;width=344&modal=true';
			showRateBox(rateRecipeURL);
			break;
		}
	}
}


var recipeRating
function recipeRating(){
		for (var i=recipesList.length-1;i>=0;i--)
		{
			//alert(document.location.href);
			//alert('index=' + i);
			if(document.location.href.search('index=' + i)!= -1){
				//alert('matched');
				recipeRating=[i];
				rateRecipeIndex=[i];
				//alert(rateRecipeIndex);
				rateRecipeTitle = recipesList[i].title;
				//alert(rateRecipeTitle);
				document.getElementById('recipeTitle').innerHTML = rateRecipeTitle;
				break;
			}
		}
}
var starNum
function starClick(rating){
	starNum = rating;
	//alert(starNum);
	for (var i=5;i<=5;i--){
		if (i > 0){
		    //alert('star_' + i);
			document.getElementById('star_' + i).src="/images/thickbox/RecipeRatings/star_noRate.gif";
		}
		else {break}
	}
	for (var i=rating;i<=rating;i--){
	    //alert(rating);
	    if (i > 0){
			//alert(rating);
			//alert('star_' + i);
			document.getElementById('star_' + i).src="/images/thickbox/RecipeRatings/star_rate.gif";
		}
		else{break}
	}
}

/* !!!!!!!!!!!!!! RECIPE RATING STUFF !!!!!!!!!!!!!!!! */
function ratingThanks(){
    var rateRecipeList = "";
    //alert(rateRecipeIndex);
    for (var i=recipesList.length-1;i>=0;i--){
        if (rateRecipeIndex == i){
            rateRecipeName = recipesList[i].name;
            rateRecipeIndexOriginal = i;
            //alert('rateRecipeIndexOriginal is ' + rateRecipeIndexOriginal);
            //alert('rateRecipeIndex is ' + rateRecipeIndex);
            //alert(rateRecipeName);
        }
        else{}
    }
    /*  
        The following for loop will pull all index values used for the rateRecipeName (from above for loop)
        and then will change the rateRecipeIndex to the lowest value for insert into db
    */
    for (var i=recipesList.length-1;i>=0;i--){
        //alert('rateRecipeName = ' + recipesList[i].name + ' and rateRecipeIndex = ' + recipesList[i].index);
        if (rateRecipeName == recipesList[i].name){
            rateRecipeList = rateRecipeList + rateRecipeName + [i];
            //alert(rateRecipeList);
            rateRecipeIndex=i;
            //alert(rateRecipeIndex);
            //alert([i]);
            //alert('MATCHED = ' + recipesList[i].name);
        }   
    }
    //alert('/Recipe-Rating-Thanks.aspx?rate=' + starNum + '&index=' + rateRecipeIndex);
	self.location.href='/Recipe-Rating-Thanks.aspx?rate=' + starNum + '&index=' + rateRecipeIndex;
}

function refreshRating(){
    //alert(rateRecipeIndex);
    //alert(rateRecipeIndexOriginal);
    //alert('/Recipes-and-Tips.aspx?whichOne=' + rateRecipeIndexOriginal + '#featuredJump');
    var thisRatingURL
    thisRatingURL = '/Recipes-and-Tips.aspx?whichOne=' + rateRecipeIndex + '#featuredJump';
    //alert(thisRatingURL);
    self.parent.tb_remove();
    top.window.top.location.href=thisRatingURL;
}
/* end */

function showRateBox(rateRecipeURL){
		$(document).ready(function(){
		tb_show('Thickbox Title', rateRecipeURL, null);
		});
			
}


function setupRecipes()
{
        doLeftNav();
        if (document.location.href.search('whichOne') != -1)
        {   
            for (var i=recipesList.length-1;i>=0;i--){
                //alert(i);
                
                currentCat=recipesList[i].cat;
                currentNameCat=recipesList[i].nameCat;
                currentName=recipesList[i].name;
                currentLocation=recipesList[i].title;
                currentFeatured=recipesList[i].featured;
                
                if (document.location.href.search('whichOne=' + [i]) != -1)
                    {
                        //Define [i] as selectedName
                        selectedName = recipesList[i].name;
                        //This changes the default highlightFeature variable
                        highlightFeature = i;
                        //This turns on the big feature image
                        document.getElementById('featuredFrame').src=thumbSource + selectedName + ".jpg";
                        //This turns on the highlightFeatured left menu
                        //alert(whichOne);
                        //alert(currentName);
                        //alert(recipesList[i].nameCat);
                        
                            document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
                        
                        //document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
                        /* This would open the category but...cannot open the category here if it is a featured, 
                           otherwise if it is opened will open then toggle closed later down in this function */
                        if (recipesList[i].featured == '0')
                            {
                                //alert('changing category now');
                                //currentCat=recipesList[i].cat;
                                //changeCat('Cat' + currentCat);
                            }
                            
                        //alert('Recipe' + i);
                        //document.getElementById('Recipe' + i).style.display='none';
                        if (i == highlightFeature){
                            //alert(selectedName);
                            currentRecipe='/ssi/recipes/' + selectedName + '.html';
							//alert(rateRecipe);
							//alert(currentRecipe);
                            ajaxpage(currentRecipe,'Recipe');
                        }
                        break;
                    }//End of If
                }//End of for loop
        }//End of If
        
        else if (document.location.href.search('whichOne') == -1)
            {
                selectedName=recipesList[highlightFeature].name;
                for (var i=recipesList.length-1;i>=0;i--){
                    if (recipesList[i].nameCat.search(selectedName) != -1){
                        document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
                    }//End if
                }//End for
            }//End else if 
            //alert(highlightFeature);  
        
                  
        for (var i=recipesList.length-1;i>=0;i--)
        {
            //alert(i);
            currentCat=recipesList[i].cat;
            currentName=recipesList[i].name;
            currentTitle=recipesList[i].title;
            currentFeatured=recipesList[i].featured;
            if (recipesList[i].nameCat.search(selectedName) != -1){
                //alert(recipesList[i].nameCat);
                document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
            }
            /* BOC to setup featured thumbnails */
            var thisFeatured = recipesList[i].featured;
            //if (thisFeatured != '0'){
                //document.getElementById('featuredImg' + thisFeatured).src=thumbSource + currentName + "_T.jpg";
                if (thisFeatured == '1'){currentFeatured1 = recipesList[i]};
                if (thisFeatured == '2'){currentFeatured2 = recipesList[i]};
                if (thisFeatured == '3'){currentFeatured3 = recipesList[i]};
                if (thisFeatured == '4'){currentFeatured4 = recipesList[i]};
                if (thisFeatured == '5'){currentFeatured5 = recipesList[i]};
                
                /* These conditions check to make sure the thumbs do not go beyond length which is currently 5 */
                var featuredObject;
	            if (document.getElementById('featuredImg' + thisFeatured) != null)
	                 {featuredObject='true';}
                else {featuredObject='false';}
	            if (featuredObject == 'true'){
	                document.getElementById('featuredImg' + thisFeatured).src=thumbSource + currentName + "_T.jpg";}
	    	    
                if (highlightFeature != 'false'){
                    /* Turn on 'default' highlightFeature, open left nav category and color active recipe */
                    if (i == highlightFeature){
                        //alert('i == highlightFeature: ' + highlightFeature);
                        if (thisFeatured != '0'){
                            //alert('thisFeatured != 0: ' + thisFeatured);
                            //This turns on the highlightFeature thumbnail
                            //alert(currentName);
                            document.getElementById('featuredImg' + thisFeatured).src=thumbSource + currentName + "_T_on.jpg";
                            }
                         //This turns on the big feature image
                        document.getElementById('featuredFrame').src=thumbSource + currentName + ".jpg";
                        //This turns on the highlightFeatured left menu
                        document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
                         //This opens left menu the category
                        currentCat=recipesList[i].cat;
                        changeCat('Cat' + currentCat);
                        //This turns on the recipe
                        if (i == highlightFeature){
                            recipesList[highlightFeature].name;
                            selectedName=recipesList[highlightFeature].name;
                            //alert(highlightFeature);
                            //alert(selectedName);
                            currentRecipe='/ssi/recipes/' + selectedName + '.html';
                            //alert(currentRecipe);
                            ajaxpage(currentRecipe,'Recipe');
                        }//end highlight feature if #2                            
              }  //}end highlight feature if #1
        }//End for loop
    checkThumbs();       
   }//End function
   
  
   var thumb1 = document.getElementById('featuredImg1');
   var thumb2 = document.getElementById('featuredImg2');
   var thumb3 = document.getElementById('featuredImg3');
   var thumb4 = document.getElementById('featuredImg4');
   var thumb5 = document.getElementById('featuredImg5');
   
   function thumbOver(whichThumb,whichFeatured){
        //alert(selectedName);
        whichThumb.src=thumbSource + whichFeatured.name + thumbOn;
        document.getElementById('featuredFrame').src=thumbSource + whichFeatured.name + ".jpg";
   }
   function thumbClick(whichFeatured){
        var thisCat='Cat' + whichFeatured.cat;
        for (var i=recipeCats.length-1;i>=0;i--){
            document.getElementById('Cat' + [i]).style.display = "none";    
        } 
        changeRecipe(whichFeatured.nameCat + '_LM');
        selectedName=whichFeatured.name;
        //alert(selectedName + ' is selectedName');
        //alert(currentName + ' is currentName');
        var thisCat='Cat' + whichFeatured.cat;
        changeCat(thisCat);
   }
    function thumbOut(whichThumb,whichFeatured){
        //alert('currentName= '+ currentName);
        //alert('selectedName= '+ selectedName);
        //alert('stay= '+ stay);
        /* ~~~~~~~~~~~~~ PROBLEM APPEARED TO BE HERE ~~~~~~~~~~~~~ */
        /* currentName seems to be the issue */
        if (currentName == 'empty')
            {stay=recipesList[highlightFeature].name;//alert(stay);
            }
        else 
            {stay=currentName;//alert(stay)
            }
        /* 
        if (whichFeatured.name != stay){
            whichThumb.src=thumbSource + whichFeatured.name + thumbOff;
            document.getElementById('featuredFrame').src=thumbSource + stay + ".jpg";
            }
      */
       if (whichFeatured.name != selectedName){
            whichThumb.src=thumbSource + whichFeatured.name + thumbOff;
            document.getElementById('featuredFrame').src=thumbSource + selectedName + ".jpg";
            }
   }
   
   thumb1.onmouseover=function(){thumbOver(thumb1,currentFeatured1)}
   thumb2.onmouseover=function(){thumbOver(thumb2,currentFeatured2)}
   thumb3.onmouseover=function(){thumbOver(thumb3,currentFeatured3)}
   thumb4.onmouseover=function(){thumbOver(thumb4,currentFeatured4)}
   thumb5.onmouseover=function(){thumbOver(thumb5,currentFeatured5)}
   thumb1.onmouseout=function(){thumbOut(thumb1,currentFeatured1)}
   thumb2.onmouseout=function(){thumbOut(thumb2,currentFeatured2)}
   thumb3.onmouseout=function(){thumbOut(thumb3,currentFeatured3)}
   thumb4.onmouseout=function(){thumbOut(thumb4,currentFeatured4)}
   thumb5.onmouseout=function(){thumbOut(thumb5,currentFeatured5)}
   thumb1.onclick=function(){thumbClick(currentFeatured1)}
   thumb2.onclick=function(){thumbClick(currentFeatured2)}
   thumb3.onclick=function(){thumbClick(currentFeatured3)}
   thumb4.onclick=function(){thumbClick(currentFeatured4)}
   thumb5.onclick=function(){thumbClick(currentFeatured5)}
   
}//End function

/* The "whatID" is the id of the recipe which comes from "this" on click */
function changeRecipe(whatID) {
    //alert(whatID);
    if (document.location.href.search('Recipes-and-Tips') != -1){
	    var input = whatID;        
	    for (var i=recipesList.length-1;i>=0;i--) {
	        //boc turn off all left menu recipes, color green
	        var leftMenuID;
	        if (document.getElementById(recipesList[i].nameCat + '_LM') != null)
	             {leftMenuID='true';}
            else {leftMenuID='false';}
	        if (leftMenuID == 'true'){
	            document.getElementById(recipesList[i].nameCat + '_LM').style.color='#547F09';
	            
	        }
	    	//eoc turn off all left menu recipes, color green
	    	
	    	/* This 'if' changes all variables to match the active recipe */
	    	if (input.search(recipesList[i].name) != -1) { 
	    	    currentCat=[i];
		        currentName=recipesList[i].name;
		        currentNameCat=recipesList[i].nameCat
		        currentFeatured=recipesList[i].featured;
		        currentTitle=recipesList[i].title;
		        currentLeftMenu=currentNameCat + '_LM';
		        //selectedName is being changed to current active recipe selection
		        selectedName=currentName;
		        //this changes all occurrences of the nameCat to orange which match the selectedName
		        if (recipesList[i].nameCat.search(selectedName) != -1){
                //alert(recipesList[i].nameCat);
                document.getElementById(recipesList[i].nameCat + '_LM').style.color='#FF6600';
                //alert(document.getElementById(recipesList[i].nameCat + '_LM').style.color + " " + recipesList[i].nameCat);
                }
		   }
	    } //end for loop  
	    
        if (i == recipesList.length) {
	    	//code can go here for beyond the array's length if reason;
	    }
	    
	    //change left menu to make it orange
	    changeLeftMenu();
	    
	    //change all associated image, featured, etc.
	    //alert(currentCat);
	    //alert(currentName);
		clickThumb(currentCat,currentName);	
}
} 
//end changeRecipe()

// function makes current left menu orange
function changeLeftMenu(){
    document.getElementById(currentLeftMenu).style.color = '#FF6600';
}

/* whichOne is currentCat, imgRoll is currentName */
function clickThumb(whichOne,imgRoll){
    if (document.location.href.search('Recipes-and-Tips') != -1)
        {            
            /* This turns all thumbs off */
            document.getElementById('featuredImg1').src=thumbSource + currentFeatured1.name + '_T.jpg';
            document.getElementById('featuredImg2').src=thumbSource + currentFeatured2.name + '_T.jpg';
            document.getElementById('featuredImg3').src=thumbSource + currentFeatured3.name + '_T.jpg';
            document.getElementById('featuredImg4').src=thumbSource + currentFeatured4.name + '_T.jpg';
            document.getElementById('featuredImg5').src=thumbSource + currentFeatured5.name + '_T.jpg';
            
            /* This opens up actual recipe content */
            for (var i=recipesList.length-1;i>0;i--){
                if (i == whichOne){
				   //alert(selectedName);
                   currentRecipe='/ssi/recipes/' + selectedName + '.html';
                   //document.getElementById('Recipe' + i).style.display='block';
                   ajaxpage(currentRecipe,'Recipe');
                   document.getElementById('featuredFrame').src=thumbSource + currentName + ".jpg";
                    }
                //var thisFeatured = recipesList[i].featured;
            }
            /*
            alert(whichOne);
            alert(imgRoll);
            
            alert(document.getElementById('featuredImg1').src);
            alert(document.getElementById('featuredImg2').src);   
            alert(document.getElementById('featuredImg3').src);
            alert(document.getElementById('featuredImg4').src);
            alert(document.getElementById('featuredImg5').src);
            */
           
           /* New code to turn on thumb (no bugs encountered to date) */
           for (var i=1;i<=5;i++){
                turnOnThumb = document.getElementById('featuredImg' + i).src;
                if (turnOnThumb.search(imgRoll) != -1){
                    document.getElementById('featuredImg' + i).src=thumbSource + imgRoll + '_T_on.jpg';
                    }
                }
           /* New code to turn on thumb ends */

            /* THE CODE BELOW WAS USED TO TURN ON THUMB AND WORKED OKAY BUT HAD SLIGHT BUG */
            /*if ((currentFeatured) != '0'){
                document.getElementById('featuredImg' + recipesList[whichOne].featured).src=thumbSource + recipesList[whichOne].name + '_T_on.jpg';
               }
            */ 
             
        stay=whichOne;
        stayOn=imgRoll;
       }
    else {
         alert('Is this else necessary?');
         //document.location.href='Recipes-and-Tips.aspx?whichOne=' + whichOne + '&imgRoll=' + imgRoll;
        }
    
    /* else{alert('Not recipes page');}*/
    
}


function goToRecipe(whichRecipe){
    //alert(whichRecipe);
    for (var i=recipesList.length-1;i>=0;i--) {
        if (whichRecipe.search(recipesList[i].nameCat) != -1){
            //alert(recipesList[i].name);
            window.location.href="/Recipes-and-Tips.aspx?whichOne=" + i + "#featuredJump";
        }
    }
}

function doLeftNav(){
    var wrapCat0 ="<!-- Category 0 -->";
    var wrapCat1 ="<!-- Category 1 -->";
    var wrapCat2 ="<!-- Category 2 -->";
    var wrapCat3 ="<!-- Category 3 -->";
    var wrapCat4 ="<!-- Category 4 -->";
    var wrapCat5 ="<!-- Category 5 -->";
    var wrapCat6 ="<!-- Category 6 -->";
    var wrapCat7 ="<!-- Category 7 -->";
    var wrapCat8 ="<!-- Category 8 -->";
    var wrapCat9 ="<!-- Category 9 -->";
    if (document.location.href.search('Recipes-and-Tips') != -1){
        for (var i=recipesList.length-1;i>0;i--) {
            var thisName = recipesList[i].name;
            var thisTitle = recipesList[i].title;
            var thisCat = recipesList[i].cat;
            var thisNameCat = recipesList[i].nameCat;
            var thisFeatured = recipesList[i].featured;
            var wrapperCode = "<div class='recipeName' style='display:block;margin-left:6px;text-indent:-6px;line-height:14px;padding-bottom:3px;padding-top:3px;' id='" + thisNameCat + "_LM' onclick='changeRecipe(this.id)'  onmouseover='rolloverRecipe(this)' onmouseout='rolloutRecipe(this)'>" + thisTitle + "</div>";
            if(recipesList[i].cat == '0'){wrapCat0 += wrapperCode}
            if(recipesList[i].cat == '1'){wrapCat1 += wrapperCode}
            if(recipesList[i].cat == '2'){wrapCat2 += wrapperCode}
            if(recipesList[i].cat == '3'){wrapCat3 += wrapperCode}
            if(recipesList[i].cat == '4'){wrapCat4 += wrapperCode}
            if(recipesList[i].cat == '5'){wrapCat5 += wrapperCode}
            if(recipesList[i].cat == '6'){wrapCat6 += wrapperCode}
            if(recipesList[i].cat == '7'){wrapCat7 += wrapperCode}
            if(recipesList[i].cat == '8'){wrapCat8 += wrapperCode}
            if(recipesList[i].cat == '9'){wrapCat9 += wrapperCode}
        }//End of for
    }//end first if
    else{
        for (var i=recipesList.length-1;i>0;i--) {
            //alert(recipesList.length);
            var thisName = recipesList[i].name;
            var thisTitle = recipesList[i].title;
            var thisCat = recipesList[i].cat;
            var thisNameCat = recipesList[i].nameCat;
            var thisFeatured = recipesList[i].featured;
            var wrapperCode = "<div class='recipeName'><a style='display:block;margin-left:6px;text-indent:-6px;line-height:14px;0px;padding-bottom:3px;padding-top:3px;' id='" + thisNameCat + "_LM' class='leftMenu' onclick='goToRecipe(this.id)' onmouseover='rolloverRecipe(this)' onmouseout='rolloutRecipe(this)'>" + thisTitle + "</a></div>";
            if(recipesList[i].cat == '0'){wrapCat0 += wrapperCode}
            if(recipesList[i].cat == '1'){wrapCat1 += wrapperCode}
            if(recipesList[i].cat == '2'){wrapCat2 += wrapperCode}
            if(recipesList[i].cat == '3'){wrapCat3 += wrapperCode}
            if(recipesList[i].cat == '4'){wrapCat4 += wrapperCode}
            if(recipesList[i].cat == '5'){wrapCat5 += wrapperCode}
            if(recipesList[i].cat == '6'){wrapCat6 += wrapperCode}
            if(recipesList[i].cat == '7'){wrapCat7 += wrapperCode}
            if(recipesList[i].cat == '8'){wrapCat8 += wrapperCode}
            if(recipesList[i].cat == '9'){wrapCat9 += wrapperCode}
            //break;
        }//End of for
    }   
    for (var i = recipeCats.length-1;i>=0;i--){
        document.getElementById('Cat' + i + '_Link').innerHTML=recipeCats[i];
    }     
    document.getElementById('Cat0').innerHTML = wrapCat0;
    document.getElementById('Cat1').innerHTML = wrapCat1;
    document.getElementById('Cat2').innerHTML = wrapCat2;
    document.getElementById('Cat3').innerHTML = wrapCat3;
    document.getElementById('Cat4').innerHTML = wrapCat4;
    document.getElementById('Cat5').innerHTML = wrapCat5;
    document.getElementById('Cat6').innerHTML = wrapCat6;
    document.getElementById('Cat7').innerHTML = wrapCat7;
    document.getElementById('Cat8').innerHTML = wrapCat8;
    /* !!!!!! NOTE: UNCOMMENT THESE CATEGORIES AS NEW CATEGORIES ARE ADDED !!!!!! */
    //document.getElementById('Cat9').innerHTML = wrapCat9;
    
}//End of doLeftNav function

window.onload=function(){
    if (document.location.href.search('Chart') != -1){
        //alert('Chart');
        document.getElementById('SubChart').style.color='#FF6600';
        document.getElementById('Usage').className='leftMenuHead';
    }

    if (document.location.href.search('Useage-Tips') != -1){
        //alert('Tips');
        document.getElementById('Usage').style.color='#FF6600';
        document.getElementById('SubChart').className='leftMenuHead';
    }
}

/* Changes top nav for each page */
function doNav(){
   document.getElementById(whichOne).className="topNav_On"; 
}


/* Function to add any flash to page */
function addFlash(thisfile, width, height){
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ');
document.write('width="' +width+ '" height="' +height+ '" hspace="0" vspace="0" align="top" border="0"> ');
document.write('<param name="movie" value="/flash/'+thisfile+ '.swf" />');
document.write('<param name="quality" value="high" /> ');
document.write('<param NAME="wmode" VALUE="transparent"> ');
document.write('<embed src="/flash/' +thisfile+ '.swf"');
document.write('width="' +width+ '" height="' +height+ '" hspace="0" vspace="0" '); 
document.write('autostart="True" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  ');
document.write('type="application/x-shockwave-flash"></embed> '); 
document.write('</object> '); 
}

/* Popup window script */
function OpenWin(url,windowName, width, height) {
agent = navigator.userAgent;
params  = "";
params += "toolbar=0,";
params += "location=0,";
params += "directories=0,";
params += "status=0,";
params += "menubar=0,";
params += "scrollbars=0,";
params += "resizable=0,";
params += "width="+width+",";
params += "top=0,";
params +="left=0,";
params += "height="+height+",";
win = window.open(url, windowName , params);
win.focus();
}

/* BOC FOR OLD INTRO PAGE FUNCTIONS -- CAN BE ELIMINATED */
function delayer(){
    document.getElementById('mainContentHome').style.visibility='visible';
    document.getElementById('bottom').style.visibility='visible';
    //alert('display changed');
}

function FlashEnd(){
    document.getElementById("mainContentFlash").style.display='none';
    //document.getElementById("mainContentHome").style.display='block';
}

/* Following SCRIPT IS TURNED OFF NOT RUNNING (per client request)
This is a single session cookie that is set
after intro flash has been played. If visitor
clicks on banner logo to go back to default.aspx,
flash intro will not play if cookie is present
 ++++++++++++++++++++++++++++++++++++++++++ */
var key_value = "introCookie=true"; 
var foundCookie = 0; 

// Get all the cookies from this site and store in an array 
var cookieArray = document.cookie.split(';'); 

function checkIntroCookie(){
    // Walk through the array 
    for(var i=0;i < cookieArray.length;i++) 
        { 
               var checkCookie = cookieArray[i]; 
        // Remove any leading spaces 
               while (checkCookie.charAt(0)==' ') 
               { 
                 checkCookie = checkCookie.substring(1,checkCookie.length); 
               } 
        
        // Look for cookie set by key_value 
                if (checkCookie.indexOf(key_value) == 0) 
               { 
                  //alert("Found Cookie "); 
            // The cookie was found so set the variable 
                   foundCookie = 1; 
               } 
    } 
    // Check if a cookie has been found 
    if ( foundCookie == 0) 
    { 
        // The key_value cookie was not found so set it now 
        document.cookie = key_value; 
        //alert("Setting Cookie");
        //addFlash('stevia_intro5', '924', '733'); 
    }  
}
/* EOC FOR OLD INTRO PAGE FUNCTIONS */

/* Ajax functions needed for all pages */
var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){

/* !!!!!!! Recipes Rating Prep here !!!!!!! */
rateRecipeName = selectedName;
var rateRecipeList = "";
//alert(rateRecipeIndex);
    
for (var i=recipesList.length-1;i>=0;i--){
		//alert(rateRecipeName);
		if (recipesList[i].name.search(rateRecipeName)!= -1){
			rateRecipeIndex = [i];
			//alert('this is the rateRecipeIndex ' + rateRecipeIndex);
			break;
		}
		for (var i=recipesList.length-1;i>=0;i--)
		{
            //alert('rateRecipeName = ' + recipesList[i].name + ' and rateRecipeIndex = ' + recipesList[i].index);
            if (rateRecipeName == recipesList[i].name)
                {
                    rateRecipeList = rateRecipeList + rateRecipeName + [i];
                    //alert(rateRecipeList);
                    rateRecipeIndex=i;
                    //alert(rateRecipeIndex);
                    //alert([i]);
                    //alert('MATCHED = ' + recipesList[i].name);
                }
        } 
	}
//alert(rateRecipeName);
//alert(rateRecipeIndex);
/* !!!!!!! Recipes Rating Prep ends !!!!!!! */

var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		document.getElementById(containerid).innerHTML=page_request.responseText

		/* THIS IS WHERE THE RATING STARS GET ADDED TO THE RECIPE */
		for(i=0;i<aryRatings.length; i++){
			//alert(rateRecipeIndex);
			//This tests if recipe index is a match
			if(aryRatings[i][0] == rateRecipeIndex){
				//alert(aryRatings[i][1]);//this is the recipe rating
				//alert('Rate' + aryRatings[i][1]);//this is the id of the star image
				var rateStar
				rateStar=aryRatings[i][1];
				//alert('rateStar is ' + rateStar); 
				for (i=1;i<=rateStar;i++){
					if (i >=1){
						//alert(i);
						//alert('Rate' + i);
						document.getElementById('Rate' + i).src='/images/thickbox/RecipeRatings/starResult_rate.gif';
					}
				}
				break
			}
		} 
		/* END */
	}
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}

}

//alert(document.referrer);

/* This was all for free sample to avoid free sites */
function checkRefer(){
  //alert(isPostBack);
  //if (isPostBack != true){}
  //alert('referrer is ' + document.referrer);
	var referString
	referString = document.referrer;
	referString = referString.toLowerCase();
	//alert(referString);
	/* Allow non-referrer sites */
		if (referString == ""){}
	/* This is for 'doubleclick' referrer */
		else if (document.referrer.search('double') != -1){}
	/* Allow testing sites below */
		else if (document.referrer.search('local') != -1){}
		//else if (document.referrer.search('stg') != -1){}
	/* Allow these email clients below */
		else if (document.referrer.search('yahoo') != -1){}
		else if (document.referrer.search('hot') != -1){}
		else if (document.referrer.search('aol') != -1){}
		else if (document.referrer.search('verizon') != -1){}
		else if (document.referrer.search('opt') != -1){}
		else if (document.referrer.search('mail') != -1){}
		else if (document.referrer.search('comcast') != -1){}
    /* Reject 'freebee' sites below */
		else if (document.referrer.search('sweetfreestuff') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('hip2save') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('wisegeek') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freestufftimes') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('heyitsfree') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('slickdeals') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freesamplefreak') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('mojosavings') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('fatwallet') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('gofreebies') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('soompi') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('commonsensewithmoney') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freestuffheadquarters') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('dogpile') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freebiesave') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('smarter') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('coupongeek') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('pocketyourdollars') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('thefreebieblogger') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('buxr') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('amidthemany') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('cafemom') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freestuffcrazy') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freebie.es') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('freestuffchannel') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('spoofee') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('swagbucks') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('thefreebiefinders') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('huntforfreebies') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('mydallasmommy') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('thedailyplate') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('couponingtodisney') != -1){
			self.location.href="/noInvite.aspx";
		}
		else if (document.referrer.search('sweetfreestuff') != -1){
			self.location.href="/noInvite.aspx";
		}
	/* This is a catch all for none of the above */
		else {self.location.href="/noInvite.aspx"}
}

function pop(popWhat) {
    window.open(popWhat,'Official', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=475,height=600,left = 0,top = 0');
}
