/** (you may delete this comment).
*TreeParams = {
*
*  OPEN_MULTIPLE_MENUS  :  boolean
*                           if true, more than one menu can
*                           be open at a time. Otherwise,
*                           opening a new menu closes any
*                           open menu.
*  
*  
*  TIME_DELAY           :  int
*                           How slowly a menuNode collapses
*                           in milliseconds. (0 to 100).
*  
*  
*  OPEN_WHILE_CLOSING   :  boolean
*                           If OPEN_MULTIPLE_MENUS is false,
*                           OPEN_WHILE_CLOSING will simultaneously
*                           open a new menu while closing the
*                           currently open menu.
*                           
*                           
*  IMG_EXT              :  Object {
*                        img file nomenclature: "menuicon.gif"
*                        "<menuicon>" + "" + ".gif" 
*      
*                        "<menuicon>" may change for each image.
*                         f you don't want the image to change, 
*                         use and empty string, or "".
*      
*                        OVER       : String 
*                                      Icon appearance in mouseover state.
*                                      "<menuicon>" + IMG_EXT.OVER + ".gif" 
*      
*                        DOWN       : String 
*                                      Icon appearance in menu open state.
*                                      "<menuicon>" + IMG_EXT.DOWN + ".gif" 
*      
*                        DOWN_OVER  : String
*                                      Icon appearance in mouseover in menu
*                                      open state.
*                                        "<menuicon>" + IMG_EXT.DOWN_OVER + ".gif" 
*                        }
*   
*   
*   
*   
*   // for backwards compatibility with an older version of AnimTree.
*  ICON_TYPE_INDIVIDUAL  : boolean
*                           If false, then OPEN_MENU_ICON, OPEN_OVER_MENU_ICON,
*                           and CLOSED_OVER_MENU_ICON are used instead. 
*                           
*                           If true, each button may have a different 
*                           icn for all four states; closed, closed-over, 
*                           open, and open-over. If true, you can omit 
*                           CLOSED_OVER_MENU_ICON, OPEN_MENU_ICON, and 
*                           OPEN_OVER_MENU_ICON.
*  
*  
*  
*  CLOSED_OVER_MENU_ICON : String
*                           When ICON_TYPE_INDIVIDUAL is false, this is the
*                           src for a closed menu's icon when buttonOver is called.
*  
*  OPEN_MENU_ICON        : String
*                           When ICON_TYPE_INDIVIDUAL is false, this is the
*                           src for an open menu's icon.
*  
*  OPEN_OVER_MENU_ICON   : String
*                           When ICON_TYPE_INDIVIDUAL is false, this is the
*                           src for an open menu's icon when buttonOver is called.
* }
*/



TreeParams = { 

	OPEN_MULTIPLE_MENUS	: false,
	
	TIME_DELAY          : 10,
	OPEN_WHILE_CLOSING	: false,

	OPEN_INSTANTLY		: false,
	
	CLOSED_OVER_MENU_ICON : "/media/menuicon_over.gif",
	OPEN_MENU_ICON        : "/media/menuicon_open.gif",
	OPEN_OVER_MENU_ICON   : "/media/menuicon_open_over.gif",
	
	
	ICON_TYPE_INDIVIDUAL  : false,
	// if ICON_TYPE_INDIVIDUAL is false, then you can ignore these.
	IMG_EXT	: {
		OVER		: "_over",
		DOWN		: "_open",
		DOWN_OVER	: "_open_over"
	}
};


//-----PERSISTENCE USER PARAMS--------------
/**
 * LISTENER_SCRIPT_SRC is the supporting file for browsers that 
 * support neither addEventListener nor attachEvent.
 * Change LISTENER_SCRIPT_SRC to point to global.js on YOUR server.
 */
var LISTENER_SCRIPT_SRC  =  "/productmenu/global.js";


/**
 * PERSISTENCE_MILLIS - int 
 * How long to save the tree state between visits.
 */
var MS_PER_DAY  =  1000 * 60 * 60 * 24;
var PERSISTENCE_MILLIS  =  1 * MS_PER_DAY; // 1 day

//-----END PERSISTENCE USER PARAMS--------------
function getexpirydate( nodays){

        var UTCstring;

        Today = new Date();
        nomilli=Date.parse(Today);
        Today.setTime(nomilli+nodays*24*60*60*1000);
        UTCstring = Today.toUTCString();
        return UTCstring;
}
function setcookie(name,value,duration){

        cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
        document.cookie=cookiestring;
        if(!getCookie(name)){
                return false;
        }
        else{
                return true;
        }
}

// this function fires onload.
fireOnload( function() {
	// Change the parameter "nav" to match the id of your tree.
	// Get the cookie
	var search = "" + document.location.search;
        var pattern = "node=";
        var position = search.indexOf(pattern) + pattern.length;
	if(position > 5){
		var cookieString = unescape(search.substring(position));
		//alert(cookieString);
        	setcookie("nav",cookieString,1);
	}
	// Clear the cookie if diff category
	var search = "" + document.location.search;
        var pattern = "cat=";
        var position = search.indexOf(pattern) + pattern.length;
	if(position ==5) {
                var cat = unescape(search.substring(position));
                var nav = getCookie("nav");
                var currentmaincat = getCookie("currentmaincat");
                if(cat != currentmaincat){
                       setcookie("nav","",-1);
                       setcookie("currentmaincat",cat,1)
                }               
        }

	saveTreeOnUnload("nav");
	restoreTreeState("nav", null);
});


