// turn this into an object
// check for the presence of the System object

// requires system - this bit lets it run in module mode
////////////////////////////////////////////////////////
var systemtest = false;
try{
	if(System)
		systemtest = true;
}catch(e){}

if(!systemtest)
	document.write('<sc'+'ript src="/sitewide/scripts/System.js"></sc'+'ript>');
////////////////////////////////////////////////////////

// need to namespace the left nav functions video_left_nav.
var video_left_nav = { 
	
	last_expanded : '',
	showHide : function (id) {
		System.out.println('showHide('+id+')');
		if(id=='tv shows')
			id='shows';
		
		var obj = document.getElementById(id);
		var status = obj.className;
	
		if (status == 'hide') {
	
			if (video_left_nav.last_expanded != '') {
				var last_obj = document.getElementById(video_left_nav.last_expanded);
				last_obj.className = 'hide';
			}
			obj.className = 'show';
			video_left_nav.last_expanded = id;
		}
		else {
			obj.className = 'hide';
		}	
	},
	
	show : function (id) {
		if(id=='tv shows')
			id='shows';
		if(id=='shows')
			id='tv_shows';
		if(id=='classic')
			id='vh1_classic';
		//alert('-'+id+'-');
		System.out.println('show(-'+id+'-)');
		System.out.println('id.charAt(0)='+id.charAt(0));
		System.out.println('id.charCodeAt(0)='+id.charCodeAt(0));
		try{
			var obj = document.getElementById(id+'_sub');
			var divObj = document.getElementById(id+'_arrow');
			if(obj.className != 'show'){
				obj.className = 'show';
				
				divObj.innerHTML = '<img src="/video/img/lnav_arrow_down.gif" width="20" height="16" />';
				
			}
			else {
				obj.className = 'hide';
				divObj.innerHTML = '<img src="/video/img/lnav_arrow_right.gif" width="20" height="16" />';
			}
		}catch(e){}
	},

	highlight : function(id){
		if(id=='tv shows')
			id='shows';
		if(id=='shows')
			id='tv_shows';
		if(id=='classic')
			id='vh1_classic';
		try{
			var obj = document.getElementById(id+'_main');
			obj.className = 'menuhigh';
		}catch(e){}
	},
	
	highsubmenu : function(id){
		System.out.println('highsubmenu('+id+')');
		if(id=='tv shows')
			id='shows';
		try{
			System.out.println('highlighting menu '+id);
			var obj = document.getElementById('link_'+id);
			obj.className = 'submenuhigh';
		}catch(e){System.out.println('could not find submenu object');
		}
	},
	
	openMenu : function() {

		//var cookieParams_name = global_cookieParams;
	
		//System.out.println('||cookieParams_name='+cookieParams_name);
		//if(cookieParams_name!='empty' && cookieParams_name!=''){
		//	highlight(cookieParams_name);
		//	return;
		
		//}
		// this is called by the page
		System.out.println('openMenu()');
		try{
			var contentHead = document.getElementById('content_head').innerHTML;
			System.out.println('contentHead='+contentHead);
			var contentHeadLower = System.util.trimString(contentHead.toLowerCase());
			
			contentHeadLower = System.util.stripWhitespace(contentHeadLower);
			contentHeadLower = Page.replaceChar(contentHeadLower,' ','_');
			
			System.out.println('contentHeadLower='+contentHeadLower);
			video_left_nav.show(contentHeadLower);
			video_left_nav.highlight(contentHeadLower);
		}catch(e){System.out.println('Error: openMenu()');}
	},
	
	mover : function(id){
		//mouseover event for primary channel??
		try{
			var obj = document.getElementById(id);
			obj.className = 'submenuhigh';
		}catch(e){ System.out.println('ERROR: mover()');}
	},
	
	mout : function(id){
		try{
			var obj = document.getElementById(id);
			obj.className = 'menu_link';
		}catch(e){ System.out.println('ERROR: mout()');}
	},
	
	linkto : function(id){
		document.location.href='/video/browse/index.jhtml?id='+id;
	},
	
	clicked : function(url){
		document.location.href = url;
		//alert(url);
	}


}




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////DONE

