// Variables ============================================================================
// Set different variables to customize menu

//var mouseover_menus = '#ffffff'; adds a background color to the main items in the menu
//var mouseout_menus  = '#dddddd';

//var mouseover_items = '#ffffff'; adds a background color to the secondary menu
//var mouseout_items  = '#f9f9f9';

// Write menus here
var menus = new Array ( 
                    "Beef Home|../beef.aspx",
                    "Cow/Calf|../cowcalf.aspx?menu=Cow%2FCalf",
                    "Feedlot|../feedlot.aspx?menu=Feedlot",
					"Stocker|../stocker.aspx?menu=Stocker",
					"Tips & Tools|../tools.aspx?menu=Tips%20%26%20Tools"
                    );

var items = new Array();

// Write menu Items here respectively. If any menu item don't have sub items, then leave its respective array blank

items[0] = new Array ("|"); 

items[1]  = new Array (
                    "Calf Nutrition|../cowcalf_calfnutrition.aspx?menu=Cow%2FCalf&item=Calf%20Nutrition",
                    "Breeding Bull Nutrition|../cowcalf_breedingbullnutrition.aspx?menu=Cow%2FCalf&item=Breeding%20Bull%20Nutrition",
                    "Loose Minerals|../cowcalf_looseminerals.aspx?menu=Cow%2FCalf&item=Loose%20Minerals",
                    "Low Moisture Blocks|http://www.crystalyx.com/beef/",
                    "Poured Blocks|../cowcalf_pouredblocks.aspx?menu=Cow%2FCalf&item=Poured%20Blocks",
                    "Pressed Blocks|../cowcalf_pressedblocks.aspx?menu=Cow%2FCalf&item=Pressed%20Blocks",
                    "Compressed Blocks|../cowcalf_compressedblocks.aspx?menu=Cow%2FCalf&item=Compressed%20Blocks",
                    "Range Cake & Liquid Supplements|../cowcalf_rangecake.aspx?menu=Cow%2FCalf&item=Range%20Cake%20%26%20Liquid%20Supplements",
                    "Replacement Heifer Nutrition|../cowcalf_heifernutrition.aspx?menu=Cow%2FCalf&item=Replacement%20Heifer%20Nutrition",
                    "Cow/Calf Health & Performance Products|../cowcalf_health.aspx?menu=Cow%2FCalf&item=Cow%2FCalf%20Health%20%26%20Performance%20Products"
                    );
                    
items[2]  = new Array ( 
                    "Starting Cattle|../feedlot_startingcattle.aspx?menu=Feedlot&item=Starting%20Cattle",
                    "Coproduct Feeding|../feedlot_coproductfeeding.aspx?menu=Feedlot&item=Coproduct%20Feeding",
                    "Traditional Feeding|../feedlot_traditionalfeeding.aspx?menu=Feedlot&item=Traditional%20Feeding",
                    "Self Feeding|../feedlot_selffeeding.aspx?menu=Feedlot&item=Self%20Feeding",
                    "Dairy Beef Feeding|../feedlot_dairybeeffeeding.aspx?menu=Feedlot&item=Dairy%20Beef%20Feeding",
                    "Breeding Bull Nutrition|../feedlot_breedingbullnutrition.aspx?menu=Feedlot&item=Breeding%20Bull%20Nutrition",
                    "Liquid Supplements|../feedlot_liquidsupp.aspx?menu=Feedlot&item=Liquid%20Supplements",                    
                    "Replacement Heifer Nutrition|../feedlot_heifernutrition.aspx?menu=Feedlot&item=Replacement%20Heifer%20Nutrition",
                    "Feedlot Health & Performance Products|../feedlot_health.aspx?menu=Feedlot&item=Feedlot%20Health%20%26%20Performance%20Products"
                    );

items[3]  = new Array (
                    "Loose Minerals|../stocker_looseminerals.aspx?menu=Stocker&item=Loose%20Minerals",
                    "Low Moisture Blocks|http://www.crystalyx.com/beef/",
                    "Poured Blocks|../stocker_pouredblocks.aspx?menu=Stocker&item=Poured%20Blocks",
                    "Pressed Blocks|../stocker_pressedblocks.aspx?menu=Stocker&item=Pressed%20Blocks",
                    "Compressed Blocks|../stocker_compressedblocks.aspx?menu=Stocker&item=Compressed%20Blocks",
                    "Self Feeding|../stocker_selffeeding.aspx?menu=Stocker&item=Self%20Feeding",
                    "Stocker Health & Performance Products|../stocker_health.aspx?menu=Stocker&item=Stocker%20Health%20%26%20Performance%20Products"
                    );

items[4] = new Array ("|"); 


// Functions ============================================================================
// Don't Edit Below


// Menu Title Mouse Over-Mouse Out
function menu_over(x)
    {
        if(document.getElementById||(document.all && !(document.getElementById)))
            {
                x.style.backgroundColor=mouseover_menus;
            }
     }

function menu_out(x)
    {
        if(document.getElementById||(document.all && !(document.getElementById)))
            {
                x.style.backgroundColor=mouseout_menus;
            }
    }

// Item Mouse Over-Mouse Out
function item_over(x)
    {
        if(document.getElementById||(document.all && !(document.getElementById)))
            {
                x.style.backgroundColor=mouseover_items;
            }
    }

function item_out(x)
    {
        if(document.getElementById||(document.all && !(document.getElementById)))
            {
                x.style.backgroundColor=mouseout_items;
            }
    }
 
 
 
// Statement to collapse items;
function collapse(id)
    {
        if (document.getElementById(id).style.display=="")
            {
                document.getElementById(id).style.display = "none";
                return;
            }
        for (i=0; i<menus.length; i++)
            {
                var others = document.getElementById(i+1);
                others.style.display = "none";
            }
        document.getElementById(id).style.display = "";
    }
 
// Statement to open links
function go(url)
    {
        window.location=url;
    }
    
/* Client-side access to querystring name=value pairs
Version 1.2.3
22 Jun 2005
Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
    this.params = new Object()
    this.get=Querystring_get
	
    if (qs == null)
	    qs=location.search.substring(1,location.search.length)

    if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
    qs = qs.replace(/\+/g, ' ')
    var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
    for (var i=0;i<args.length;i++) {
	    var value;
	    var pair = args[i].split('=')
	    var name = unescape(pair[0])

	    if (pair.length == 2)
		    value = unescape(pair[1])
	    else
		    value = name
		
	    this.params[name] = value
    }
}

function Querystring_get(key, default_) {
    // This silly looking line changes UNDEFINED to NULL
    if (default_ == null) default_ = null;
	
    var value=this.params[key]
    if (value==null) value=default_;
	
    return value
}       
                         
// Writes menu
function write_menu()
    {
        // Parse the current page's querystring
        var qs = new Querystring()
        var current_menu = qs.get("menu", "Beef Home")
        var current_item = qs.get("item", "Beef Home")        
            
        document.write('<div id="navigation_bar">');
        
        for(x=0; x<menus.length; x++)
            {
                // Spilts menus into array for menu name and url
                var menu_array  = menus[x].split("|");
                // If menus url is not available the just makes expand and collapse effect on menu
                if (!menu_array[1])
                    {
                        var menu  = '<div id="menu" onMouseOver=menu_over(this); onMouseOut=menu_out(this); onClick="collapse(\''+(x+1)+'\')">'+menus[x]+'</div>';
                    }
                else
                    {
                        //if (menu_array[1] == "http://www.crystalyx.com/beef/")
                        //    {                                
                        //        var menu  = '<div id="menu" onMouseOver=menu_over(this); onMouseOut=menu_out(this); onClick="collapse(\''+(x+1)+'\'); go(\'../swine/swine.aspx\')"><a href="'+menu_array[1]+'" target="_blank">'+menu_array[0]+'</a></div>';
                        //    }
                        //else
                        //    {
                                var menu  = '<div id="menu" onMouseOver=menu_over(this); onMouseOut=menu_out(this); onClick="collapse(\''+(x+1)+'\'); go(\''+menu_array[1]+'\')"><a href="'+menu_array[1]+'">'+menu_array[0]+'</a></div>';
                        //    }
                    }
                
                if (menu_array[0] == current_menu)
                {   
                    document.write('<div id="current_menu">'+menu+'</div>');
                    //document.write('<div style="color="#000000;" id="'+menu+'');
                }
                else
                {
                    document.write(menu); 
                }
                    
                // Checks if current menu has items then writes items
                if(items[x] !='')
                    {                    
                        // If menu is not current then sets its display to none
                        if (menu_array[0] != current_menu)
                            {
                                document.write('<div style="display:none" id="'+(x+1)+'">');
                            }
                        else
                            {
                                //document.write('<div style="display:" id="'+(x+1)+'">');
                            }
                                
                            // Writes Items
                            for(y=0; y<items[x].length; y++)
                                {
                                    // Splits current item into name and url
                                    var item_array   = items[x][y].split("|");
                                    
                                    if (item_array[1] == "http://www.crystalyx.com/beef/")
                                        {                                
                                            document.write('<div id="item" onMouseOver=item_over(this); onMouseOut=item_out(this); onClick="go(\''+menu_array[1]+'\')"><a href="'+item_array[1]+'" target="_blank">'+item_array[0]+'</a></div>');
                                        }
                                    
                                    else
                                        {
                                        // If item name is not current then acts with it as a ordinary item
                                        if (item_array[0] != current_item)
                                            {
                                                document.write('<div id="item" onMouseOver=item_over(this); onMouseOut=item_out(this); onClick="go(\''+item_array[1]+'\')"><a href="'+item_array[1]+'">'+item_array[0]+'</a></div>');
                                            }
                                        // Or if it current, then removes hyperlink and change it background color to current items background color
                                        else
                                            {   
                                                //document.write('<div id="current_item">'+item_array[0]+'</div>');
                                                document.write('<div id="current_item" onMouseOver=item_over(this); onMouseOut=item_out(this); onClick="go(\''+item_array[1]+'\')"><a href="'+item_array[1]+'">'+item_array[0]+'</a></div>');
                                            }
                                        }        
                                }
                    }                        
                    document.write('</div>');            
            }
            
       document.write('</div>');
    }
    
function stoperror()
    {
        return true
    }
    
window.onerror=stoperror