var SideMenu = new Object
/*
03/30/2009
Spry decision function 
Used:
Example:   <UL spry:if="function::SideMenu.subMenuOpen"> (if this is true it will fiilst the items in the LI)
This function decieds  if the menu should be open based on the path in the current url
matches the link in the xml file programs_nav_bar.xml
this function is only used for the programs and thier sub pages listed in the xml
*/
SideMenu.subMenuOpen =function(rgn,lookupFunc)
	{	
		var sPathName=location.pathname; 
		var bTest=false;

		if(lookupFunc("{overview}")==sPathName)
			{

				document.getElementById(rgn).className='on';
				bTest=true;
			}	
			
		else if(lookupFunc("{course_list}")==sPathName)
				{
				document.getElementById(rgn).className='on';

				bTest=true;
				}
			else if(lookupFunc("{tech_req}")==sPathName)
					{
						document.getElementById(rgn).className='on';

						bTest=true;
					}

		return bTest;
		 
	}





SideMenu.filterMenu = function(notificationType , notifier, data)
	{


			var url = location.href;
			var matchingRows = oCollege.findRowsWithColumnValues({"link": "http://www.staging.southuniversity-online.com/test_pg.html"}, true);
	
	
			if (matchingRows != null)
			{
			

				return matchingRows; // Return the row to keep it in the data set.
			}

			return null; // Return null to remove the row from the data set.

	}
	
/*

This function is used to produce the slide effect
the argument "e" is the element as an objectt.
the function assumes that it is a element in side of a div and that it 
contains an li. currently the event is attached to the <h2> of the program
the Element the is attached to this event must contain a custom attribute called "ulList"
The ulList is the id of the div to open.
*/

SideMenu.slide = function(e)
	{
	
		var sContent = e.parentNode.getElementsByTagName('li')
		var nSpaceNeeded = sContent.length * 18;

		e.parentNode.className=(e.parentNode.className)=='on' ? 'off':'on';
		
		var sCurrentState= (e.parentNode.className)=='on' ? true:false;
	// decied if we should fade in or out.	
		if(sCurrentState)
		{
			Spry.Effect.DoBlind(e.getAttribute('ulList'),  {duration: 1000, from: '0px', to: nSpaceNeeded+'px', toggle: false});
		}
		else
		{
			Spry.Effect.DoBlind(e.getAttribute('ulList'),  {duration: 1000, from: nSpaceNeeded+'px', to: '0px', toggle: false});
		}
		
	}




var oSouthSchools= new Spry.Data.XMLDataSet("/includes/navagation/programs_nav_bar.xml", "program_menu");

var oCollege =  new Spry.Data.NestedXMLDataSet(oSouthSchools, "college",{ entityEncodeStrings: -1 });


var oDegree =  new Spry.Data.NestedXMLDataSet(oCollege, "degree",{ entityEncodeStrings: -1 });
var oProgram = new Spry.Data.NestedXMLDataSet(oDegree, "program",{ entityEncodeStrings: -1 });

var dsMaster = new Spry.Data.NestedXMLDataSet(oSouthSchools, "college/degree[title = 'Master']/program", {entityEncodeStrings: -1,distinctOnLoad:true,sortOnLoad:"title"});

var dsAssociate = new Spry.Data.NestedXMLDataSet(oSouthSchools, "college/degree[title = 'Associate']/program",{ entityEncodeStrings: -1,distinctOnLoad:true,sortOnLoad:"title"});
var dsBachelor = new Spry.Data.NestedXMLDataSet(oSouthSchools, "college/degree[title = 'Bachelor']/program",{ entityEncodeStrings: -1,distinctOnLoad:true,sortOnLoad:"title"});

