﻿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
highlightFeature = '26';//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";

/*  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','5');  
	recipesList[3]  = new recipesInfo('0','ChocolateMousse0','ChocolateMousse','Chocolate Mousse','4');  
	recipesList[4]  = new recipesInfo('0','MuffinTops0','MuffinTops','Morning Muffin Tops','3');  
	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','0');
	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','0');  
	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','0');  
	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','2');  
	recipesList[26] = new recipesInfo('0','SteviaHoneyAioli0','SteviaHoneyAioli','Stevia Honey Aioli','1');  
	recipesList[27] = new recipesInfo('5','GingerCookie5','GingerCookie','Ginger Cookies','0');  

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 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;
                        //alert(selectedName + " is selectedName");
                        //This changes the default highlightFeature variable
                        highlightFeature = i;
                        //This turns on the big feature image
                        document.getElementById('featuredFrame').src=thumbSource + currentName + ".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(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 thisFeatured If
   }//End for
   
   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){
        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');
        var thisCat='Cat' + whichFeatured.cat;
        changeCat(thisCat);
   }
    function thumbOut(whichThumb,whichFeatured){
        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";
            }
   }
   
   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){
                   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' id='" + thisNameCat + "_LM' onclick='changeRecipe(this.id)'>" + 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 id='" + thisNameCat + "_LM' class='leftMenu' onclick='goToRecipe(this.id)'>" + 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;
    /* !!!!!! NOTE: UNCOMMENT THESE CATEGORIES AS NEW CATEGORIES ARE ADDED !!!!!! */
    //document.getElementById('Cat7').innerHTML = wrapCat7;
    //document.getElementById('Cat8').innerHTML = wrapCat8;
    //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';
}

/* 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){
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
}

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
}
}
}