/******************** rotate object **********************/
/*
	The rotate object controls the rotating content found on some department
	home pages and the mu home page.  It displays one of several <div>s located
	in the body of the document for 10 seconds at a time.  Additional
	code needs to be included in the head tag of the document to implement
	the rotate object see the mu home page for an example.
*/
var Rotate = function() {
	var that = this; // for scoping issues
	this._construct = function() {
		that.f = 0;
		that.size = $("#events").find("div.event").length;
		that.seconds = 10000;
		that.old = 0;
	}
	this.init = function() {
		var current = ++that.f % that.size;
		els = $("div.event");
		lis = $("ul#events_list li");
		for(var i = 0; i < that.size; i++) {
			el = els.get(i);
			li = lis.get(i);
			if(i == current) {
				$(el).fadeIn("slow");
				$(li).addClass("selected");
				$(els.get(that.old)).hide();
				$(lis.get(that.old)).removeClass();
				that.old = i;
			}
		}
	}
	this.start = function() {
		that.interval = setInterval(that.init, that.seconds)
	}
	this._stop = function() {
		clearInterval(that.interval);
		that.f = 0;
	}
	this.restart = function(i) {
		that._stop();
		that.f = --i;
		that.init();
		that.start();
	}

	// create the object
	this._construct();
}
/******************** end rotate object *******************/


/************************ menu object *********************/
/*
	The menu object controls the top and left hand navigation bars
	all menus for all pages are defined in the menus array within the 
	menu object.  Menu needs to be instantiated in the head of all pages
	and the .show() function must also be called in the head to display
	the top menu when the page loads.
	
	todo: factor out the menu definitions
*/
var Menu = function() {
	//Used in the timer function
	initMenu = function (){};
	var timer=0;
	var timerEnabled=0; //0=Off  1=Open  -1=CloseAll
	var tmpObj = new Object();
	
	var that = this; //scoping issues
	this._construct = function() {
		that.baseHref = "http://"+document.location.hostname+"/mu/";
		if (that.baseHref == "https://webdev.uui.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		if (that.baseHref == "http://webdev.uui.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		if (that.baseHref == "http://usiwebqa.usi.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		if (that.baseHref == "http://www.vpsa.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		if (that.baseHref == "http://secure.vpsa.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		if (that.baseHref == "https://secure.vpsa.asu.edu/mu/") that.baseHref = "http://www.asu.edu/mu/";
		that.section = "";
		
		/*
		// factor out the menu definitions, not working yet
		 that.menus = $.ajax({   type: "GET",
					url: that.baseHref +"script/menu_definition.js",
					dataType: "json",
					async: "false",
					success: function(menu_def){
						 return that.menus;
   					}
				}); 
		alert(that.menus);
		*/
		 
		/*
		*	decalare menues
		*	edit the following section to add remove or change menu items
		*/
		
		that.menus = {
			"menu root" : {
				"Student Resources" : "student_resources.htm",
				"Student Involvement" : "sdic/index.htm",
				"Event \&amp\; Meeting Services" : "events/index.htm",
				"MU Services" : "mu_services.htm",
				"Memorial Union" : "index.htm"
			},
			"resources" : {
				"name" : "Student Resources",
				"section" : "menu root",
				"Adult Learners " : "http://www.asu.edu/studentaffairs/reslife/occss/Adult_Learner_Resources.htm",
				"Student Legal Assistance" : "legal/index.htm",
				"Safety Escort Service" : "http://www.asuusg.com/?page_id=1226" ,
				"New Student Orientation" : "http://students.asu.edu/orientation"
			},
			"involvement" : {
				"name" : "Student Involvement",
				"section" : "menu root",			
				"Student Organizations" : "clubs/index.htm",
				"Campus Activities" : "mupa",
				"Community Service Program" : "community/index.html",
				"Student Government ASASU" : "http://asasu.net",
				"Canon Leadership Program" : "http://students.asu.edu/canon",
				"Fraternities \&amp\; Sororities" : "greeklife/index.htm",
				"LGBTQA Services" : "lgbtq/index.htm",				
				"Student Coalitions" : "http://www.asu.edu/studentaffairs/mss/mcc/studentinvolvement.htm"
				
			},
			"ems" : {
				"name" : "Event \&amp\; Meeting Services",
				"section" : "menu root",
				"Home" : "events/index.htm",
				"Reservations" : "events/reservations.htm",
				"Meeting Rooms" : "events/meeting_rooms.htm",
				"Rates \&amp\; Fees" : "events/fees.htm",
				"Outdoor Event Requests" : "events/outdoor_event_requests.htm",
				"Sales and Solicitation" : "events/sales_solicitation.htm",
				"Catering" : "events/catering.htm",
				"Contact Us" : "contact.htm#ems"
			},
			"services" : {
				"name" : "MU Services",
				"section" : "menu root",
				"Dining" : "dining.htm",
				"Meal Plans" : "http://sundevildining.asu.edu/",
				"Businesses, Banks/ATMs" : "businesses.htm",
				"Sparky's Den" : "sparkys_den.htm",
				"Information Desk, Lost \&amp\; Found" : "information_desk.htm",
				"Marketing" : "advertising_banners.htm",
				"Air Pump Station" : "air_pump_station.htm"
			},
			"mu" : {
				"name" : "Memorial Union",
				"section" : "menu root",
				"About the MU" : "about.htm",
				"MU Advisory Board" : "muab",
				"Mission, Staff" : "staff.htm",
				"MU News & Specials" : "news.htm",
				"Art Cafe" : "art_cafe.htm",
				"Comedy Troupes" : "comedy_troupes.htm",
				"Art Collection" : "art_collection.htm",
				"After Dark" : "afterdark/index.html",
				"Employment" : "student_employment.htm",
				"Policies" : "http://www.asu.edu/aad/manuals/ssm/index.html#800",
				"MU Maps & Hours" : "http://www.asu.edu/studentaffairs/mu/mu_map.htm",
				"Contact Us" : "contact.htm"
			},
			"muab" : {
				"name" : "Memorial Union Advisory Board",
				"Home" : "muab/index.htm",
				"Members" : "muab/members.htm",
				"Window Painting Contest" : "muab/windowContest.html",
				//"Blog" : "https://muab.blog.asu.edu",
				"Become a member" : "muab/application.htm",
				"Contact Us" : "muab/contact.htm"
			},
			"muab_ichange" : {
				"name" : "muab",
				"section" : "muab",
				"About iChange" : "muab/ichange_info.htm",
				"Application" : "muab/ichange_apply.htm"
			},
			"community" : {
				"name" : "Community Service Program",
				"section" : "involvement",
				"Student Involvement Home" : "http://www.asu.edu/studentaffairs/mu/student_involvement.htm",
				"Home" : "community/index.html",
				"Where do I Start" : "community/howtostart.htm",
				"Student Resources" : "!csp_student",
				"Agency Resources" : "!csp_agency",
				"Leadership Through Service" : "!csp_leadership",
                "Log your community service hours" : "community/logservicehours.html",
				"Community Service Verification Form" : "community/docs/ServiceVerificationForm.pdf",
				"ASU Campus Challenge" : "community/asu_campus_challenge.htm",
				"About Us" : "community/aboutcsp.htm",
				"Find More Volunteer Opportunities" : "http://www.asu.edu/studentaffairs/mu/community/links.htm"
			},
			"sundevilstars" : {
				"name" : "Sun Devil Stars",
				"Home" : "sundevilstars/index.htm",
				"Past Recipients" : "sundevilstars/recipients.htm",
				"Nominate" : "sundevilstars/nominate.htm"
			},
			"calendar_service" : {
				"name" : "Calendar of Service Opportunities",
				"Monthly Service Opportunities" : "community/monthly_service.htm"
			},
			"csp_student" : {
	
	"name" : "Student Resources",
				"Planning a Service Event" : "community/manual.htm",
				"CSP Listserv" : "community/listserv.htm",
				"On-Campus Service" : "community/campus.htm",
				"Service Within Walking Distance" : "community/local",
				"Nonprofit Internships" : "community/internships.htm",
				"Additional Service Links" : "community/links.htm",
				"Frequently Asked Questions" : "community/faq.htm"
			},
			"csp_agency" : {
				"name" : "Agency Resources",
				"Access Volunteers" : "community/access_volunteers.htm"
			},
			"csp_leadership" : {
				"name" : "Leadership Through Service",
				"CSP Team Leaders" : "community/team.htm",
				"Community Service Coalition" : "community/coalition.htm"
			},
			"holiday_coffee" : {
				"name" : "Holiday Coffee",
				"Home" : "holidaycoffee/index.htm",
				"About Holiday Coffee" : "holidaycoffee/about.htm",
				"Feedback" : "contact.htm#mu"
			},
			"sorc" : {
				"name" : "Student Organizations",
				"section" : "involvement",
				"Student Involvement Home" : "http://www.asu.edu/studentaffairs/mu/student_involvement.htm",                        
				"Search for an Organization" : "http://asu.orgsync.com/search",
				"Registration" : "http://asu.orgsync.com/home",
				"For Advisors" : "http://www.asu.edu/studentaffairs/mu/clubs/advisors/",
				"Policies" : "!sorc_policies",
				"Resources" : "!sorc_resources",
				"FAQs" : "clubs/sorc-faq.html",
				"OrgSync" : "clubs/orgsync.html",
				"Forms" : "clubs/resources.htm",
				"Calendar" : "http://asu.orgsync.com/Calendar", 
				"Hall of Fame" : "!sorc_hall",
				"Student Risk Management" : "clubs/risk/index.htm",
				"Passport to ASU" : "!sorc_passport",
				 "LGBTQA Services" : "http://www.asu.edu/studentaffairs/mu/lgbtq/index.htm",
				"About SORC" : "clubs/team.htm"
			},
			"sorc_passport" : {
				"name" : "Passport to ASU",
				"section" : "sorc",
				"About Passport to ASU": "clubs/passport.htm",
				"Vendor Expo" : "http://expo.asu.edu/ "
			},
			"sorc_policies" : {
				"name" : "Policies",
				"section" : "sorc",
				"Policy Links" : "clubs/policies.htm",
				//"Handbook" : "clubs/docs/Tempe_SORC_Handbook_2010-2011.pdf",
				"Sales \&amp\; Solicitation" : "clubs/sales.htm",
				"Advertising \&amp\; Posting" : "clubs/advertising.htm",
				"Student Risk Management" : "clubs/studentriskmanagement.htm",
				"Trademark" : "clubs/trademark.htm"
			},
			"sorc_resources" : {
				"name" : "Resources",
				"section" : "sorc",
				//"Best Practices" : "bestpractices/index.htm",
				"Copies \&amp\; Posters" : "clubs/copies.htm",
				"Mail Boxes" : "clubs/storage.htm",
				"Funding Options" : "clubs/funding.htm",
				"University Facility Use" : "clubs/facility.htm",
				"Mall \&amp\; Vendor Information" : "clubs/mall.htm",
				"Web \&amp\; Email" : "clubs/webspace.htm",
				"T-shirts \&amp\; Apparel" : "http://www.BrandXtshirts.com",
				"SORC HandBook" : "clubs/docs/Tempe_SORC_Handbook_2011-2012.pdf",
				"Nonprofit Status" : "http://lodestar.asu.edu/organizational_assistance/ask-the-nonprofit-specialists"
				
			},
			"sorc_hall" : {
				"name" : "Hall of Fame",
				"section" : "sorc",
				"Hall of Fame Awards" : "clubs/hall.htm",
				"Past Recipients" : "clubs/hallawards.htm"
			},
			"best_practices" : {
				"name" : "Best Practices",
				"section" : "sorc_resources",
				"New Student Resources" : "bestpractices/new_orgs.htm",
				"Leadership" : "bestpractices/org_leaders.htm",
				"Group Dynamics" : "bestpractices/all_orgs.htm",
				"Public Relations &amp; Community Service" : "bestpractices/public.htm",
				"Event Planning" : "bestpractices/planning.htm",
				"Funding & Money Management" : "bestpractices/money.htm"
			},
			"greeklife" : {
				"name" : "Fraternities \&amp\; Sororities",
				"section" : "involvement",
				"Student Involvement Home" : "http://www.asu.edu/studentaffairs/mu/student_involvement.htm",
				"Reserve Alpha Drive Fields": "greeklife/alphadrive.htm",
				"How to Join" : "!greek_join",
				"Councils" : "!greek_councils",
				"Chapters at ASU" : "greeklife/chapters_asu.htm",
				"Current Members" : "!greek_members",
				"Policies, Procedures \&amp\; Forms" : "greeklife/policies_and_procedures.htm",
				"Academic Report" : "greeklife/reports.htm",
				"Disciplinary Report" : "greeklife/violations.htm",
				"View Presentations": "!greek_presentations",
				"Advisors" : "greeklife/advisors.htm",
				"Alumni" : "http://www.asu.edu/alumni/",
				"Parents" : "!greek_parents",
				"Wellness Resources" : "http://students.asu.edu/wellness/help",
				"Greek Awards" : "!greek_awards",				
				"Contact Us" : "!greek_contact"
			},
			"greek_join" : {
				"Recruitment" : "greeklife/recruitment.htm",
				"Housing" : "greeklife/housing.htm",
				"Glossary" : "greeklife/glossary.htm"
			},
			"greek_councils" : {
				"section" : "greeklife",
				"Interfraternity Council" : "greeklife/ifc.htm",
				"Multicultural Greek Council" : "greeklife/mgc.htm",
				"National Pan-Hellenic Council" : "greeklife/nphc.htm",
				"National Association of Latino Fraternal Organizations" : "greeklife/nalfo.htm",
				"Panhellenic Council" : "greeklife/pan.htm"
			},
			"greek_members" : {
				"Housing" : "greeklife/housing.htm",
				"Greek Life Classes" : "greeklife/greek_life_classes.htm",
				"Scholarships" : "greeklife/scholarships.htm",
				"Greek Devil Way" : "greeklife/gdw.htm",
				"Order of Omega" : "http://www.asu.edu/studentaffairs/mu/greeklife/ooo.htm"
			},
			"greek_awards" : {
				"Past Winners" : "greeklife/awards_winners.htm"				
			},
			"greek_parents" : {
				"FAQ" : "greeklife/parents.htm",
				"Myths &amp; Facts About Hazing" : "greeklife/parents.htm#hazing_myths"
			},
			"greek_contact" : {
				"Our Staff" : "greeklife/contact_us.htm",
				"Council Officers" : "greeklife/council_officers.htm"
			},
			"greek_presentations" : {
				"The Rights & Responsibilities of Living the Ritual Presentation":
				"greeklife/docs/fsl_rights_responsibilities.ppt",	
				"Leadership Styles Presentation" : "greeklife/docs/lead styles.ppt"
			},
			"mupa" : {
				"name" : "Campus Activities",
				"section" : "involvement",
				"Student Involvement Home" : "http://www.asu.edu/studentaffairs/mu/student_involvement.htm",
				"Last Lecture Series" : "mupa/last_lecture.htm",
				"Learning Outside the Classroom" : "!mupa_learning_outside",
				"Finals Breakfast" : "finalsbreakfast/",
				"Art Caf\&eacute\;" : "art_cafe.htm",
				"Programming and Activities Board" : "http://asasu.net/pab/",
				"Contact Campus Activities" : "mupa/about.htm"
			},
			"mupa_learning_outside" : {
				"name" : "Learning Outside the Classroom",
				"section" : "mupa", 
				"Benefits" : "mupa/benefits.htm",
				"Tips" : "mupa/tips.htm",
				"Campus Resources" : "mupa/resources.htm",
				"Further Reading" : "reading.htm"
			},
			"legal" : {
				"name" : "Student Legal Assistance",
				"section" : "resources",
				"Home" : "legal/index.htm"
			},
			"symposium" : {
				"name" : "Parent & Family Programs Symposium",
				"Home" : "symposium/index.htm",
				"Register Now" : "http://www.asu.edu/studentaffairs/mu/surveys/index.htm?sid=transitions_symposium_registration",
				"Schedule of Events" : "symposium/schedule.htm",
				"Local Attractions" : "!symposium_localattractions",
				"Parking/Directions" : "symposium/directions.htm",
				"Lodging and Accommodations" : "symposium/lodging.htm",
				"Contact Us" : "symposium/contact.htm"
			},
			"symposium_localattractions" : {
				"Weekend Events" : "symposium/area.htm?s=weekend&t=Weekend%20Events",
				"Museums" : "symposium/area.htm?s=museums&t=Local%20Museums",
				"Sites to See" : "symposium/area.htm?s=sites&t=Sites%20to%20See"
			},
			"asu_connect" : {
				"name" : "ASU Connect",
				"Home" :  "asuconnect/index.htm",
				"Parents Association" : "http://www.asu.edu/parents",
				"Transition and Parent Programs" : "http://www.asu.edu/studentaffairs/mu/transitions/index.htm",
				"Parent and Family Resources" : "http://www.asu.edu/studentaffairs/mu/transitions/Parents/index.htm",
				"Contact us" : "http://www.asu.edu/studentaffairs/mu/transitions/contact_us.htm"
			},
			"sustain2009" : {
				"name" : "Sustain 2009",
				"Home": "sustain2009/index.htm",
				"Register Now!": "sustain2009/register.htm",
				"Conference Schedule": "sustain2009/schedule.htm",
				"Accommodations": "sustain2009/accomodations.htm",
				"Call for Programs": "sustain2009/call_for_programs.htm",
				"WE-LEAD": "sustain2009/welead.htm",
				"School Brag Competition": "sustain2009/schoolbrag.htm",
				"U Did What Competition": "sustain2009/udidwhat.htm",
				"Call for Award Nominations": "sustain2009/awards.htm",
				"ACUI Voucher Program": "http://member.acui.org/core/events/eventdetails.aspx?meeting=09voucher",
				"Local Attractions": "http://students.asu.edu/node/1478",
				"ACUI Region 13": "http://region13.acui.org/"

			},
			"friday_night_fusion" : {
				"name" : "Friday Night Fusion",
				"Home" : "fusion/index.htm",
				"Upcoming Events" : "fusion/events.htm",
				"Incentives" : "fusion/incentives.htm",
				"Host an Upcoming Event" : "fusion/host_event.htm",
				"Feedback" : "fusion/feedback.htm"
			},
			"mu_after_dark" : {
				"name" : "MU After Dark",
				"Home" : "afterdark/index.html",
				"Upcoming Events" : "afterdark/events.htm",
				"MU After Dark Student Organization" : "afterdark/org.htm",
				"Feedback" : "afterdark/feedback.htm"
			},
			"lgbtq" : {
				"name" : "LGBTQ Services",
				"Student Involvement Home" : "http://www.asu.edu/studentaffairs/mu/student_involvement.htm",
				"Home" : "lgbtq/index.htm",
				"LGBT Certificate and LGBTQ Courses" : "lgbtq/certificate_courses.htm",
				"SafeZONE" : "lgbtq/safezone.htm",
				"Gender Neutral Restrooms" : "lgbtq/restrooms.htm",
				"Health Resources" : "lgbtq/health_resources.htm",
				"Campus Resources" : "lgbtq/resources_campus.htm",
				"Community Resources" : "lgbtq/resources_community.html",
				"Spirituality" : "lgbtq/spirituality.htm",
				"Events Calendar" : "http://www.google.com/calendar/hosted/asu.edu/embed?src=lpittari%40asu.edu&ctz=America/Phoenix",
				"OUTreach Newsletter" : "lgbtq/newsletter.htm",
				"Coming Out Resources" : "lgbtq/comingoutresources.html",
				"LGBTQA Terms/Definitions" : "lgbtq/def.html",
				"Q-Connect" : "lgbtq/Q-Connect.html",
				"SpeakOUT Speakers Bureau/Peer Mentoring" : "lgbtq/speakout.htm",
				"OUTspoken Dialogue Series" : "lgbtq/OUTspoken.htm"
			},
			"fork" : {
				"name" : "Farm-to-Fork",
				"Home" : "farmtofork/index.htm",
				"Sign up to Attend" : "farmtofork/application.html",
				}

		};
		// end menu item declaration
		
		that._checkTimer();
	}	
	/***** end constructor *****/
	
	/***** start top menu bar functions *****/
		
	/*	get:
	*	returns a section of the Menu.menus JSON object
	*/
	this.get = function(menu_id) {
		return that.menus[menu_id];
	}
	
	/*	show - displays the local menu or secondary navigation
	*	
	*	author: Omar Rodriguez
	*	date: 01/07
	*
	*	Description: Creates an unordered list markup structure with a h2 menu title
	*		This list is based on a section of the Menu.menus JSON object, the section of the menu
	*		to be displayed is taken from the first arguments.  All submenus contained 
	*		within the specified menu are denoted by a "!" in front of the menu item
	*		definition.  The rest of the submenu is another element of the JSON object with
	*		the identifier eaqual to the element definition without the "!"
	*		ex.
	*			"my_menu" : {
	*				"menu_item" : "!menu_item_submenu"
	*			},
	*			"menu_item_submenu" : { }
	*		The submenus are hidden until they're are moused over or clicked and disapear
	*		again when the mouse leaves the menu area.
	*
	*	Requirements: A div tag must exist in the DOM to insert the menu into.
	*/
	this.show = function(menu_id, submenu_id) {
		var i = 0;
		var idx=0;
		var _submenu = that.get(menu_id);
		var curReff = document.referrer.substr(0,document.referrer.lastIndexOf("/"));
		var curHref = document.location.href.substr(0,document.location.href.lastIndexOf("/"));

		if(_submenu["section"]) {
			_name = _submenu["name"];
			_section = that.get(_submenu["section"]);
			_href = that.baseHref + _section[_name];
		} else {
			_href = '';
		}
		// create a link to return to the homepage
		if(submenu_id == "#submenu") {
			if(_href) {
				_menu_title = "<a href=\"" + _href + "\">" + _submenu["name"] + "</a>";
			} else {
				_menu_title = _submenu["name"];
			}
		}
		var _html = "<h2>" + ((submenu_id == "#submenu")?_menu_title:'') + "</h2>";
		_html += "<ul>";
		for(li in _submenu) {
			if(li != "name" && li != "section") {
				if ( _submenu[li].indexOf("!")!=0){
					_html += "<li><a href=\"";
					_html += (_submenu[li].indexOf('http') == -1 && _submenu[li].indexOf('javascript') == -1)?that.baseHref:'';
					_html += _submenu[li] + "\">" + li + "</a></li>";
				}else{
					_html += "<li id='sm_"+ _submenu[li].substr(1,_submenu[li].length-1)+"'>";
					_html += "<a id=\""+ _submenu[li].substr(1,_submenu[li].length-1)+"\" onclick=\"menu.accordionOpenMenu(this,true)\" style=\"cursor:pointer\">" + li + "&nbsp;<img src=\"http://www.asu.edu/studentaffairs/mu/images/dropdown_arrow.png\" height=\"9\" width=\"9\"></a></li>";
				}
			}
			idx++;
		}
		_html += "</ul>";
		if(submenu_id != "#submenu" && $(submenu_id).size() == 0) {
			$("#submenu").after("<div id=\"" + submenu_id.replace(/#/, "") + "\"></div>");
		}
		$(submenu_id).html(_html);
		$(submenu_id).css("height", ""); // clear the height
		// only slide down when the submenu is hidden

		$(submenu_id + " ul li").filter( function (){ return ($("a", this).attr("id")!=null ? $(this) : null);}).each( function() {
			that.addSubs($("a", this).attr("id"));
		});

		if($(submenu_id).is(":hidden")) {
			$(submenu_id).slideDown("slow").css("margin", 0);
		} else {
			//Show only when comming from diffrent website or folder
			/*if (curReff!=curHref){
				$(submenu_id).hide();
				$(submenu_id).fadeIn(1000);
			}else{
				$(submenu_id).show();
			}*/

		}

		
		menu.addMouseEvents("#submenu");
	}
	/****** end top menu functions ******/

	/****** start left hand menu functions ******/	
	
	/*	addSubmenus
	*	required for accordian function
	*	adds the submenus dynamicly
	*/
	this.addSubs = function(menu_id) {
		//get submenu nodes
		if (menu_id=="") return;
		var _submenu = that.get(menu_id);
		var _link="";
		
		//build submenu
		var _html ="<ul>";
		for(li in _submenu) {
			if(li != "name" && li != "section" && li != "link") {
				_html += "<li><a href=\"";
				_html += (_submenu[li].indexOf('http') == -1 && _submenu[li].indexOf('javascript') == -1)?that.baseHref:'';
				_html += _submenu[li] + "\">" + li + "</a></li>";
			}
			if (li=="link"){
				_link = _submenu[li];
			}
		}
		_html += "</ul>";
		//add a link to the parent node
		if (_link!=""){
			$("#" + menu_id).parent().children("a").attr("onclick", ""); //remove click event
			$("#" + menu_id).parent().children("a").attr("href", (_submenu["link"].indexOf('http') == -1 && _submenu["link"].indexOf('javascript') == -1)?that.baseHref + _submenu["link"]:_submenu["link"]); //add link
		}
		// add  submenus and hide them
		$("#" + menu_id).parent().append(_html);
		$("#" + menu_id).siblings("ul").hide();
	}
	
	/*	accordian
	*	displays mouseover effect of the left hand menu, 
	*	not the top menu
	*/
	this.accordian = function(element, closeAll) {
		if (closeAll==false){
			$(element).siblings("ul:hidden").slideDown("normal");
			$(element).parent().siblings().children("ul:visible").slideUp("normal");
		}else
			$(element).parent().children("ul:visible").slideUp("normal");
	}
	
	/*Recursive timer check
	*	increases usability of the mouseover accordian effect
	*	pauses the mouseover function briefly to 
	*/
	this._checkTimer = function (){
		w = setTimeout("menu._checkTimer();",100);
		if (that.timerEnabled!=0){
			that.timer--;
			if (that.timer<=0){
				if (that.timerEnabled==1) {
					that.accordian(that.tmpObj, false);
				}else{
					that.accordian(that.tmpObj, true);
				}
				that.timerEnabled=0;
			}
		}
	}
	
	//Recieves input from the current page to implement the _checkTimer
    this.accordionOpenMenu = function(element,forceOpen) {
		that.timerEnabled=1;
		if (forceOpen)
			that.timer=0;
		else
			that.timer=5;
		that.tmpObj = element;
	}
	
	//Recieves input from the current page
	this.accordionCloseMenu  = function(element) {
		that.timerEnabled=-1;
		that.timer=5;
		that.tmpObj = element;
	}
	

	this.addMouseEvents = function(listContainerDiv){
		//add accordian effect
		$(listContainerDiv + " ul li").filter( function (){ return ($("a", this).attr("id")!=null ? $(this) : null);}).mouseover(function() {
			that.accordionOpenMenu($("a", this));
		});	
		$(listContainerDiv + " ul li").filter( function (){ return ($("a", this).attr("id")!=null ? $(this) : null);}).siblings("ul").mouseover(function() {
			that.accordionOpenMenu(this);
		});	
		$(listContainerDiv + " ul li").filter( function (){ return ($("a", this).attr("id")!=null ? $(this) : null);}).siblings("ul").mouseout(function() {
			that.accordionCloseMenu("#submenu ul li a");
		});	
		$(listContainerDiv + " ul li").filter( function (){ return ($("a", this).attr("id")!=null ? $(this) : null);}).mouseout(function() {
			that.accordionCloseMenu("#submenu ul li a");
		});

	}
	/****** end left hand menu functions ******/
	
	// create the menu object
	this._construct();

}

/********************* end menu object *************************/


/****************** Static Functions Section *******************/

//Helper functions for textfields usuage: onkeypress="return calculateWords(this, 'divName', 50)"
function calculateWords(textbox, divName, wordlimit){
	wordsLeft = wordlimit - textbox.value.split(' ').length;
	if (textbox.value.length>0) $(divName).html("<strong>You have "+ wordsLeft +" words left. </strong>");
	if (wordsLeft <=0)
		return false;
	return true;
}

//Helper functions for textfields usage: charLimit(document.getElementById('textbox'), 50)"
function charLimit(obj, charLimit){
	obj.onchange = function() {
		if (this.value.length > charLimit) this.value = this.value.substr(0,charLimit);
	}
	obj.onkeypress = function () {
		var charCode = (event.which) ? event.which : event.keyCode
		if (this.value.length > charLimit) this.value = this.value.substr(0,charLimit);
		if (charCode > 31 || charCode==13){
			charsLeft = charLimit - this.value.length;
			if (charsLeft <=0)
				return false;
			return true;
		}
		alert();
	};
}

//Helper funcion for textbox usge: formatField(document.getElementById('textbox'), '(###)###-####')" 
// X's are used for letters and numbers and #'s are used for numbers only
function formatField(obj, mask){
	if (!obj.mask){ 
		obj.mask = mask;
		obj.maxLength = mask.length
		obj.onkeydown = function (e) { 
			e = e || window.event;var chrs = new Array(); var cpos = new Array();	var t=0; var i; var ret = this.mask; var ret2 = this.value;
			for (i=0;i<this.mask.length;i++){if (this.mask.charAt(i)!='#' && this.mask.charAt(i)!='X'){chrs[t] = this.mask.charAt(i);cpos[t++] = i;}}
			for (i=0;i<chrs.length;i++){ret=ret.split(chrs[i]).join('');}
			for (i=0;i<chrs.length;i++){ret2=ret2.split(chrs[i]).join('');}
			var req = ret.charAt(ret2.length); if (e.shiftKey) return false; k = (!e) ? event.keyCode : e.keyCode
			if (!req) req = ret.charAt(0); if (k==8 || k==9 || k==13 || (k>32 && k<41) || (k>95 && k<106)) return true;
			if (req=="#"){ if(!((k>=48 && k<=57) || k==58)){ return false; }
			}else{if(!((k>=48 && k<=57) || (k>=65 && k<=90) || (k>=97 && k<=122) || k==58)){
			return false;}}		
		};
		obj.onkeypress= function (e) { 
			e = e || window.event; k = (!e) ? event.keyCode : e.keyCode;
			if (k==8 || k==9 || k==13 || (k>32 && k<41) || (k>95 && k<106)) return true;
			var chrs = new Array(); var cpos = new Array();	var nw=""; var ret = this.value; var t=0; var i;
			chrs[-1] = ""; cpos[-1] = -1; for (i=0;i<this.mask.length;i++){if (this.mask.charAt(i)!='#' && this.mask.charAt(i)!='X'){
			chrs[t] = this.mask.charAt(i);cpos[t++] = i;}}cpos[t] = this.mask.length;
			for (i=0;i<chrs.length;i++){ret=ret.split(chrs[i]).join('');}
			for (i=-1;i<chrs.length;i++){if (ret.length >=cpos[i]-i){nw += chrs[i] + ret.substr(cpos[i]-i,cpos[i+1]-cpos[i]-1);}}
			this.value=nw;		
		};
	}
}

//Helper function for textfields usage: onchange="return validateEmail(this, true)"
//checks if there is only one @ symbol and ends in .something
function validateEmail(textbox, displayAlert){
	var ret = true;
	if (textbox.value.indexOf('@')==-1 )
		ret = false;
	if (textbox.value.indexOf('@')!=textbox.value.lastIndexOf('@'))
		ret = false;
	if (textbox.value.lastIndexOf('.')<=textbox.value.indexOf('@')+1)
		ret = false;
	if (ret==false && displayAlert==true){
		alert("The e-mail address you've typed in is invalid!");
		textbox.value="";
	}
	return ret;
}

/* openTab - static function, which organizes content into tabs and animates tab transitions
 *
 * Author: Alejandro Gonzalez
 * Date: 5/14/07
 * 
 * Description: This function can be called from a link and is used to organize pages
 * into tabs and animate the transition between tabs.  All of the tabed content should 
 * be wraped in divs with id attributes set. Another div needs to be added for the title 
 * of the tab which needs id=section_title. <div id="section_title"></div> openTab requires
 * two arguments to be passed in when it is called, The id attribute of the div to display
 * and the html string of the title to display for the tab.
 *
 * Requirements: openTab requires the JQuery library jquery.js v1.1.2 or later and also the
 * Interface jQuery plugin v1.2 or at least the slide tranistion of the Interface plugin.
 */

/*	function openTab(divName, sect_title, showAll){
		if (showAll==true){
			$("#" + divName).siblings().slideDown("slow");
			$("#" + divName).slideDown("slow");
		}else{
			$("#" + divName).siblings("div:visible").slideUp("slow");
			$("#" + divName).slideDown("slow");
		}
		$("#section_title").SlideOutLeft("medium",function () {
			$("#section_title").html("<h2>"+ sect_title +"</h2>");
			$("#section_title").SlideInLeft("medium");
		});
	}*/
	
	function openTab(divName, sect_title){
		var i=0;
		var multiDivs = divName.split("|");
		var multiTitles = sect_title.split("|");
		
		if (multiDivs.length==1) $("#" + multiDivs[0]).siblings("div:visible").slideUp("slow");

		for(i=0; i<multiDivs.length; i++){
			$("#" + multiDivs[i]).slideDown("slow");
			$("div[@class='temp']").remove();
		}
		for(i=0; i<multiTitles.length; i++){
			if (i==0) {
				$("#section_title").fadeOut(500,function () {
					$("#section_title").html("<h2 style=\"color:#4A0030; padding-bottom:0px; margin-bottom:0px\">"+ multiTitles[0] +"</h2>");
					$("#section_title").fadeIn(500);
				});
			}else{
				$("#" + multiDivs[i-1]).prepend("<div class='temp'><br /><h2 style=\"color:#903; padding-bottom:0px; margin-bottom:0px\">"+multiTitles[i]+"</h2></div>");
			}
		}
	}
	
/* parseParameter - static function, which returns the value of a specific parameter
 *
 * Author: Alejandro Gonzalez 
 * Date: 5/14/07
 * 
 * Description: This function returns the actual value of a parameter passed through the 
 * QueryString. If there are diffrent instances of the same variable then only the last instance
 * will be read. Also, if the variable does not exist then returns null. 
 *
 */
	function parseParameter(varName){
		var ret = null;
		if (window.location.toString().split("?").length>1){
			var allParams = window.location.toString().split("?")[1].split("#")[0];
			var params = allParams.split("&");
			if (varName){
				for (var i=0; i<params.length;i++){
					if (params[i].split("=")[0]==varName)
						ret = params[i].split("=")[1];
				}
			}else
				ret = params;
		}
		return ret;
	}
	
/* getObject - static function, which returns the object of a specific tag depending on the Id
 *
 * Author: Alejandro Gonzalez
 * Date: 5/14/07
 * 
 * NOTE: This function only works if the objName has an ID attribute NOT the NAME attribute. It's
 * recommended that you specify both attributes the same name.
 *
 */
	function getObject(objName){
		return (document.all) ? document.all[objName] : document.getElementById(objName);
	}
	
/* timedRedirect - static function, which redirects the browser to a different location at a timed delay.
 *
 * Author: Alejandro Gonzalesz
 * Date: 5/14/07
 *
 */
	function timedRedirect(url, miliseconds){
		setTimeout("document.location.href = '"+ url+"'", miliseconds);	
	}
	
/* linkAfterDate - string function, which returns a URL corresponding to specific date in miliseconds must use 
 *	               Date.UTC(year,month,day,hour,minutes,seconds) for the deatline date. If today's date is before the
 *				   deadline then beforeURL is returned else it returns the afterURL. This can also be used with any 
 *				   other string not just for URL's.
 *
 * Author: Alejandro Gonzalesz
 * Date: 10/10/07
 *
 */
	function linkAfterDate(beforeURL, afterURL, deadline){
		var dt = new Date();
		var today = Date.UTC(dt.getFullYear(), dt.getMonth()+1, dt.getDate(),dt.getHours(),dt.getMinutes(),dt.getSeconds());
		if ((today-deadline) < 0) return beforeURL;
		return afterURL;
	}
	
    function emptyBox(fieldName, fieldText) {
  		if (document.getElementById(fieldName).value != fieldText)
  			{
  			// don't do anything
  			}		
  		else
  			{
  			document.getElementById(fieldName).value = "";
  			}
     	} // end function
	
	function fillBox(fieldName, fieldText) {
		if (document.getElementById(fieldName).value != "")
			{
			// don't do anything
			}			
		else
			{
			document.getElementById(fieldName).value = fieldText;
			} // end if
    } // end function	
