			

	CWS_subSite.list.sort(CWS_subSite.listsort)

	var CWS_thisSiteIndex = CWS_subSite.siteIndex(document.location.pathname)
	var CWS_thisSiteRoot = CWS_subSite.siteRoot()

//-------------------------------------//--------------------------------
// sub site details and seek 
//-------------------------------------//--------------------------------
	
	CWS_subSite.indexByNode = function (URL){
		URL = URL.substr(1, URL.lastIndexOf('/')-1)
		URL = URL +'/'
		var ssIndex = -1
		var testIndx = -1
		fthstMatch = -1
		indexOfMatch = -1
		for(var i = CWS_subSite.list.length -1; i > -1; --i){
			textIndx =URL.indexOf('/'+CWS_subSite.list[i][1]+'/')
			if( textIndx > fthstMatch){ fthstMatch =textIndx ; indexOfMatch= i }
		}
		return indexOfMatch
	}  
	
	var CWS_isNode = false
	CWS_colourMeByNode = function(){
		CWS_isNode = true
		CWS_thisSiteIndex = CWS_subSite.indexByNode(document.location.pathname)
		CWS_thisSiteRoot = CWS_subSite.siteRoot()
		CWS_colourMe();
	}
	
	CWS_titleMe= function(){
		if(CWS_thisSiteIndex != -1){
		document.write(CWS_subSite.list[CWS_thisSiteIndex][0])
		}
	}	
	
	
	CWS_colourMe = function (){
		document.write('<link rel="stylesheet" type="text/css" href="/styles'+CWS_thisSiteRoot+'area.css">')
	}


//-------------------------------------//--------------------------------	
//  Side Bar functions
//-------------------------------------//--------------------------------	
	CWS_repStr = function(str,f,t){
		var str= str.split(f).join(t)
		return str
	}
	
	CWS_isOrphan = function(){
		var menuHTML = document.getElementById('menu_bar').innerHTML.toLowerCase()
		var linkAt = menuHTML.indexOf('</a>')
		if(linkAt == -1) {return true}
		return false
	}

	CWS_sideBarTop = function(){}

	CWS_bendIt = function(){
		menuinner = document.getElementById("menu_bar").innerHTML
		strLoc = menuinner.toLowerCase()
		from = strLoc.indexOf('<div')
		strLoc =strLoc.substr(from)
		menuinner =	menuinner.substr(from)
		cutTo = strLoc.indexOf('<scri')
		menuinner =	menuinner.substr(0,cutTo)
		if(CWS_this_browserIs('mac')){		
			menuinner = CWS_repStr(menuinner,String.fromCharCode(160)," ")
		}
		menuinner = CWS_repStr(menuinner,"&nbsp;"," ")
		menuinner = CWS_repStr(menuinner,"<nobr>","")
		menuinner = CWS_repStr(menuinner,"</nobr>","")
		menuinner = CWS_repStr(menuinner,"<NOBR>","")
		menuinner = CWS_repStr(menuinner,"</NOBR>","")
		document.getElementById("menu_bar").innerHTML= menuinner 
	}
	
	/* remove 
	CWS_bendIt = function(){
		var menuinner = document.getElementById("menu_bar").innerHTML
		menuinner = CWS_repStr(menuinner,"&nbsp;"," ")
		menuinner = CWS_repStr(menuinner,"<nobr>","")
		menuinner = CWS_repStr(menuinner,"</nobr>","")
		menuinner = CWS_repStr(menuinner,"<NOBR>","")
		menuinner = CWS_repStr(menuinner,"</NOBR>","")
		document.getElementById("menu_bar").innerHTML=menuinner 
	}*/

	CWS_gotoCourses = function(){
		window.location.href = "/home/courses"+CWS_thisSiteRoot+"index.htm"
	}
	
	CWS_piMenuItem = function(){
		//document.write('<br><div class="menu_Global"><a href="javascript:CWS_gotoCourses()">Course Information</a><br></div>')	
		}
	
	CWS_sideBarTail = function(){
		//---------- writes in dept home and back for orphaned paged
		CWS_bendIt()
		if(CWS_isOrphan() ){ 
			var HTMLline1 = '<div class="menu_Global"><nobr><a href="'+CWS_thisSiteRoot+'" target="">Home</a></nobr><br></div>'
			var HTMLline2 = '<div class="menu"><nobr><a href="javascript:history.back()" target="">Up</a></nobr><br></div>'		
			document.getElementById("menu_bar").innerHTML= HTMLline1 + HTMLline2
		
		}
		
		if(CWS_thisSiteIndex != -1){
			var hasCrs = CWS_subSite.list[CWS_thisSiteIndex][3]
			if(hasCrs && !CWS_isNode){
				CWS_piMenuItem()
			}
		}
		//----------	
	}


//-------------------------------------//--------------------------------	

function CWS_printMe(){
	window.print()
}
//---------------------
var CWS_showNavSearch = true




function CWS_displayNavSearch(){
	document.write('<div class="menu"><a href="'+CWS_subWebRoot+'_componants/searchpage.htm" >Search</a></div>')

}


//-------------------------------------//--------------------------------	
//  goto_new_courses function is now called from every page in the old courses subsite
//  It attempts to redirect any visitor who tries to view old course info to the new CCIS pages in the respective dept sites
//-------------------------------------//--------------------------------	
function goto_new_courses(){
	urlPage="";
	thisURL=document.location.href;
	urlBits=thisURL.split("home/courses");
	
	if(urlBits[1]){
		atSlashes=urlBits[1].split("/");
		if(atSlashes[2]){
			if(atSlashes[2].toUpperCase()=="UNDERGRADUATE"){
				urlPage="_courses/undergraduate_list.asp";
			}else if(atSlashes[2].toUpperCase()=="POSTGRADUATE"){
				urlPage="_courses/postgraduate_list.asp";
			}
		}
		newUrl="/"+atSlashes[1]+"/"+urlPage+"";
		document.location.href=newUrl;
	}
	
}