/**
					scoped to page and module name
				**/
				function globaldispatcher(){
				 	return dispatcher;
				}
				Page.mod_videos = {
					
					contentIDs : [],
					flash	: {},
					playing : false,
					untouched : true, // flag
					current_index : 0, // index starts at one
					current_tab : 1, // defaulting to one - but it may be 2
					current_object : 'mod_videos.tab_1.index_1', // the currently playing object
					current_highlight : null, // holds current hightlighted object
					
					// these objects are set in videos.jhtml
					current_contentID : null, //1540724, //1549668
					contentID_A : null,
					contentID_B : null,
					
					next_object : null,
					highColor : '#ffffff',
					pauseColor : '#f8f8f8',
					lowColor  : '#acb4b7',
					blankPosterframeSrc : '/home/modules/videos/img/blank_poster.gif',
					vspot_info : false,
					num_started_clips : 0,
					num_watched_clips : 0, //increments after each clip ends
					num_milestone_clips : 0, //number of clips played for at least five seconds
					milestone_threshold : 1, // number of clips to play without ads
					milestone : null, // when play reaches five second report sum 
					milestone_time : 10000, 
					playad : false,
					num_of_vids	: 0,
					timer : null,
					
					
					tab : function(n){
						this.current_tab = n;
						if(this.untouched){
							
							var nextVid = 'mod_videos.tab_'+n+'.index_1'
							this.next_object = element(nextVid);
							Page.mod_videos.pause_next_video();
							//this.untouched = false;
						}
						
						// Swaps tabs
						var h = (n==1)? 2:1;
						var showtab = 'mod_videos.tab_'+n;
						var hidetab = 'mod_videos.tab_'+h;
						Page.hide(hidetab);
						Page.show(showtab);
						
						// Swaps footer link
						var showFooter = 'mod_videos.footer_'+n;
						var hideFooter = 'mod_videos.footer_'+h;
						Page.hide(hideFooter);
						Page.show(showFooter);
						
						if(n==1){
							this.current_contentID = this.contentID_A;
							if(Page.mod_videos.timer!=null)
								window.clearTimeout(Page.mod_videos.timer)
							Page.mod_videos.timer = setTimeout("Page.mod_videos.report(7);",2000);
						}
						else{
							this.current_contentID = this.contentID_B;
							if(Page.mod_videos.timer!=null)
								window.clearTimeout(Page.mod_videos.timer)
							Page.mod_videos.timer = setTimeout("Page.mod_videos.report(8);",2000);
						}
					},
					
					register : function() {
					
						this.num_of_vids++;
					
					},
					
					play : function(obj){ // When user clicks on list item
						System.out.println('this.num_milestone_clips='+this.num_milestone_clips);
						
						if(this.num_milestone_clips >= this.milestone_threshold){
							System.out.println("ABOVE THRESHOLD clip#="+this.num_milestone_clips);
							if(this.num_milestone_clips%2)
								this.playad = true;
							else
								this.playad = false;
						}
						
						// load and play video
						if(this.milestone != null)
							clearTimeout(this.milestone);
							
						this.playing = true;
						this.num_started_clips++;
						if(this.untouched)
							this.untouched = false;
							
						if(obj)
							this.current_object = obj;
						else
							obj = this.current_object;
						
						// interface changes
						try {
							if(this.current_highlight!=null){
							 	var preObj = this.current_highlight;
								this.lowlight(preObj);
								
								var tog = Page.e(preObj.id+'.toggle');
								tog.src = '/home/modules/videos/img/btn_arrow_off.gif';
							}
							this.highlight(obj);
							// set image to pause
							var toggle = Page.e(obj.id+'.toggle');
							toggle.src = '/home/modules/videos/img/btn_play_on.gif';
						}
						catch(e){
							System.out.println('error:'+e.description);
						}
						
						// close posterframe
						Page.hide('mod_videos.posterholder');
						
						// get data
						var name = 	Page.e(obj.id+'.name').innerHTML;
						var title = Page.e(obj.id+'.title').innerHTML;
						var vid = 	Page.e(obj.id+'.vid').innerHTML;
						
						// load and play video
						this.load(vid);
						
						obj.blur();
						// report watched clips in ten seconds
						this.milestone = setTimeout("Page.mod_videos.milestone_action();",this.milestone_time);
						
						// report the play functionality
						setTimeout('Page.mod_videos.report(10);',5000);
						
					},
					
					milestone_action : function() {
						System.out.println('reporting here');
						this.num_milestone_clips++; // incrementing the number of milestone clip count
						Page.mod_videos.report(9);
					
					},
					
					pause : function(obj, isInit) { // Highlight item and displays posterframe
						// this should be called que
						//pause is only called internaly
						this.current_object = obj;
						// interface 
						try{
							
							if(this.current_highlight!=null){
							 	var preObj = this.current_highlight;
								this.lowlight(preObj);
								
								var tog = document.getElementById(preObj.id+'.toggle');
								tog.src = '/home/modules/videos/img/btn_arrow_off.gif';
							}
							
							// set image to pause
							var toggle = document.getElementById(obj.id+'.toggle');
							toggle.src = '/home/modules/videos/img/btn_play_init.gif';
							this.light(obj,this.pauseColor);
							
							// load this videos posterframe image
							this.loadposter(obj);
			
						}
						catch(e){
							System.out.println('error:pause '+e.description);
						}
					},
					
					// player makes js call to Page.mod_videos.end();
					end  : function(){
						this.playing = false;
						this.num_watched_clips++;
						var obj = this.current_object;
						if(obj == null){// don't know what was playing
							System.out.println('end : current_object unknown');
							return;
						}
						
						// get tab and track indexes to set next video
						var id = obj.id;// mod_videos.tab_1.index_1
						var tab = id.substring(id.indexOf('.')+1,id.lastIndexOf('.'));
						var tabNumber = tab.substring(tab.indexOf('_')+1);
						var index = id.substring(id.lastIndexOf('.')+1);
						var indexNumber = index.substring(index.indexOf('_')+1);
						var intNumber = indexNumber/1;
						intNumber++;
						//////////////////////////////////////////////////////////
						
						
						// this comes around after ten vids - but it may have less with the new player
						if(intNumber>this.num_of_vids)
							intNumber=1;
							
							
						//////////////////////////////////////////////////	
						var nextVid = 'mod_videos.'+tab+'.index_'+intNumber
						
						// set the next object to be pick up after the push to vspot
						this.next_object = element(nextVid);
						
						// display the push to vspot
						this.loadvspotpromo();
		
					},
					
					load : function(vid) {
						System.out.println('this.playad='+this.playad);
						try{
							Page.mod_videos.flash.loadVideo(vid,this.current_contentID,this.playad)
						}
						catch(e){
							System.out.println('error:load'+e.description);
						}
					},
					
					clearvid : function() { // this will clear both the old video and the old posterframe
						try{
							Page.e('mod_videos.vidholder').innerHTML = '';
							Page.e('mod_videos.posterframe_img').src = this.blankPosterframeSrc;
						}
						catch(e){
							System.out.println('error:load'+e.description);
						}
					
					},
					
					loadposter : function(obj){
						// loads the poster frame when a video is paused
						// fires after page load and when videos end
						var posterframeSrc = document.getElementById(obj.id+'.poster').innerHTML;
						var swfurl = '/home/modules/videos/swf/poster_frame.swf';
						var flashvars = 'swfurl='+posterframeSrc
						Page.mod_videos.flash.loadflash(swfurl,'mod_videos.posterframe','posterframe_flash_container',226,171,flashvars)
						Page.show('mod_videos.posterholder');
						return;
						try{
							var posterframeSrc = document.getElementById(obj.id+'.poster').innerHTML;
							document.getElementById('mod_videos.posterframe_img').src = posterframeSrc;
						}
						catch(e){
							System.out.println('error:loadposter');
						}
						
						// show posterframe layer
						Page.show('mod_videos.posterholder');
					},
					
					loadvspotpromo : function() {
					
						var swfurl = '/home/modules/videos/swf/vspot_slate1.swf';
						var layer = 'mod_videos.vspot';
						
						Page.show('mod_videos.vspot');
						Page.mod_videos.flash.loadflash(swfurl,layer,'promo',226,171);
						this.clearvid();
						
						setTimeout('Page.mod_videos.pause_next_video()',5000);
					},
					
					showinfo : function() {
						if(!this.vspot_info){
							document.getElementById('mod_videos_head_img').src = '/home/modules/videos/img/head_close.jpg';
							this.vspot_info = true;
							var swfurl = '/home/modules/videos/swf/vspot_slate2.swf';
							var layer = 'mod_videos.vspot';
							
							Page.show('mod_videos.vspot');
							Page.mod_videos.flash.loadflash(swfurl,layer,'promo',226,171);
						}
						else {
							document.getElementById('mod_videos_head_img').src = '/home/modules/videos/img/headnew.jpg';
							Page.hide('mod_videos.vspot');
							this.vspot_info = false;
						}
						//this.clearvid();
					},
					
					report : function(i){
					
						System.out.println('------------------------------------------------------');
						System.out.println('report #'+i);
						System.out.println('playad = '+this.playad);
						var obj = this.current_object;
						//System.out.println('a');
						var name = 	Page.e(obj.id+'.name').innerHTML;
						
						var seriesname = null;
						if(Page.e(obj.id+'.seriesname'))
							seriesname = Page.e(obj.id+'.seriesname').innerHTML;
						//System.out.println('b');
						var title = Page.e(obj.id+'.title').innerHTML;
						//System.out.println('c');
						title = Page.removeChar(title,'"');
						//System.out.println('d');
						var vid = 	Page.e(obj.id+'.vid').innerHTML;
						//System.out.println('e');
						var label = null;
						//System.out.println('f');
						if(Page.e(obj.id+'.label')!=null)
							label = Page.e(obj.id+'.label').innerHTML;
						//System.out.println('g');	
						var gaid  = null;
						if(Page.e(obj.id+'.gaid')!=null)
							gaid= Page.e(obj.id+'.gaid').innerHTML;
						//System.out.println('h');
						//alert(i);
						// these report events are being fired from the player
						// 0 = play
						// 1 = pause
						// 2 = unpause
						// 3 = go big
						/*
						s_pageName
						s_hier2
						s_hier5
						s_prop13
						
						*/	
						/*
						try {
							var c_pageName = s_pageName+'';
							var c_hier2 = s_hier2+'';
							var c_hier5 = s_hier5+''; 
							var c_prop13 = s_prop13+'';
							var c_prop22 = s_prop22+'';
							var c_channel = s_channel+'';
						}catch(e){}
						*/
						
						var dispatcher = globaldispatcher();
						var oldpn = com.mtvi.config.SectionSetup.pageName;
						
						
						var pn; //pageName
						var h2; //hier2
						var p22; //Prop22
						
						//System.out.println('label='+label);
						
						if(i==0){ // this is a play function as reported by the player
							// this function is getting over hit by the flash player
							// I am moving this over to a page level call and will be captured as report(10)
							//return;
							/*
							System.out.println('report NUMBER ZERO');
						
							if(seriesname!=null)
								pn = 'inline-video/main/'+seriesname+'/'+title+'#'+vid;
							else if(label != null)
								pn = 'inline-video/main/top_music_videos/'+title+'#'+vid;
							else
								pn = 'inline-video/main/top_show_videos/'+title+'#'+vid;
								
							System.out.println('report PAGENAME='+pn);
								
							try{
								if(label!=null){
									System.out.println('LABEL REPORT');
									var distributor = getVidGovLabelName(gaid);
									var h5 = distributor+','+label+','+name+','+title;
									System.out.println('h5='+h5);
									System.out.println('sendReportingCall({setOverrides:{ s_pageName:'+pn+', s_hier2:'+ pn+', s_hier5: '+h5+', s_prop22:\'inline-video/main/index.jhtml\', s_prop13:'+gaid+':'+label+':'+name+':'+vid+':'+title+', s_channel:\'In-line Video\' }});');
									//sendReportingCall({setOverrides:{ s_pageName:pn, s_hier2: pn, s_hier5: h5, s_prop22:'inline-video/main/index.jhtml', s_prop13:gaid+':'+label+':'+name+':'+vid+':'+title, s_channel:'In-line Video' }});
								}
								else{
									System.out.println('NONE LABEL REPORT');
									//sendReportingCall({setOverrides:{ s_pageName:pn, s_hier2: pn, s_prop22:'inline-video/main/index.jhtml', s_channel:'In-line Video' }});
									//sendReportingCall();
								
								}
							}
							catch(e){
								System.out.println('Reporting Error');
							}
							*/
							//Page.mod_videos.report(9); // send in watched videos report
						}
						else if(i==1){ // user has paused the video
							sendLinkCall('inline-video/main/pause/'+title+'#'+vid);
							System.out.println('PAUSE');
						}
						else if(i==2){ // user has unpaused the video
							sendLinkCall('inline-video/main/unpause/'+title+'#'+vid);
							System.out.println('UNPAUSE');
						}
						else if(i==3){// GOBIG
							//TODO: create a go big function that inturn makes the report call
							sendLinkCall('inline-video/main/gobig/'+title+'#'+vid);
							System.out.println('GOBIG');
							
							// kill the video
							//document.getElementById('mod_videos.vidholder').innerHTML = '';
							this.clearvid();
							
							// pop vspot with the current object
							launchVspot('vid='+vid+'&id='+Page.mod_videos.current_contentID);
							
							//load the next posterframe
							this.end();
						}
						else if(i==4){
							//push to vspot
							System.out.println('launchVspot');
							sendLinkCall('inline-video/main/VspotLogo.jhtml');
						}
						else if(i==5){
							sendLinkCall('inline-video/main/play/clip title')
						}
						else if(i==6){
							// determine which tab we are on
							if(this.current_tab==1){
								sendLinkCall('inline-video/main/WatchAllVSPOTShow Clips/');
							}
							else if(this.current_tab==2){
								sendLinkCall('inline-video/main/WatchAllVSPOTMusic Clips/');
							}
						}
						else if(i==7){
							sendLinkCall('inline-video/main/Top Show/');
						}
						else if(i==8){
							sendLinkCall('inline-video/main/Top Music/');
						}
						else if(i==9){ // five second mark on video play
							// inline-video/main/Watch 15
							
							sendLinkCall('inline-video/main/Watch '+this.num_watched_clips++);
							System.out.println('report: inline-video/main/Watch '+this.num_watched_clips);
							clearTimeout(this.milestone);
							this.milestone = null;
						}
						else if(i==10){
							// new page level play reporting
							System.out.println('report NUMBER ZERO');
						
							if(seriesname!=null)
								pn = 'inline-video/main/'+seriesname+'/'+title+'#'+vid;
							else if(label != null)
								pn = 'inline-video/main/top_music_videos/'+title+'#'+vid;
							else
								pn = 'inline-video/main/top_show_videos/'+title+'#'+vid;
								
							System.out.println('report PAGENAME='+pn);
								
							try{
								if(label!=null){
									//System.out.println('LABEL REPORT');
									var distributor = getVidGovLabelName(gaid);
									var h5 = distributor+','+label+','+name+','+title;
									//System.out.println('h5='+h5);
									//System.out.println('sendReportingCall({setOverrides:{ s_pageName:'+pn+', s_hier2:'+ pn+', s_hier5: '+h5+', s_prop22:\'inline-video/main/index.jhtml\', s_prop13:'+gaid+':'+label+':'+name+':'+vid+':'+title+', s_channel:\'In-line Video\' }});');
									//sendReportingCall({setOverrides:{ s_pageName:pn, s_hier2: pn, s_hier5: h5, s_prop22:'inline-video/main/index.jhtml', s_prop13:gaid+':'+label+':'+name+':'+vid+':'+title, s_channel:'In-line Video' }});
									com.mtvi.config.SectionSetup.pageName = pn;
									com.mtvi.config.SectionSetup.hier2 = pn;
									com.mtvi.config.SectionSetup.hier5 = h5;
									dispatcher.setAttribute('pageName',pn);
									dispatcher.setAttribute('hier2',pn);
									dispatcher.setAttribute('hier5',h5);
									dispatcher.setAttribute('prop22','inline-video/main/index.jhtml');
									dispatcher.setAttribute('prop13',gaid+':'+label+':'+name+':'+vid+':'+title);
									dispatcher.setAttribute('channel','In-line Video');
									//dispatcher.setAttribute('prop23','LINE: 541');
									dispatcher.sendCall();
					
								}
								else{
									
									com.mtvi.config.SectionSetup.pageName = pn;
									com.mtvi.config.SectionSetup.hier2 = pn;
									dispatcher.setAttribute('pageName',pn);
									dispatcher.setAttribute('hier2',pn);
									dispatcher.setAttribute('prop22','inline-video/main/index.jhtml');
									dispatcher.setAttribute('channel','In-line Video');
									//dispatcher.setAttribute('prop23','LINE: 541');
									dispatcher.sendCall();
								
								}
							}
							catch(e){
								System.out.println('Reporting Error');
							}
						}
						
						
						com.mtvi.config.SectionSetup.pageName = oldpn;
						dispatcher.setAttribute('pageName',oldpn);
						
						System.out.println('com.mtvi.config.SectionSetup.pageName='+com.mtvi.config.SectionSetup.pageName);
						
						
						//System.out.println('here');
						//System.out.println('PRETEST: s_pageName='+s_pageName);
						/*
						try{
							
							s_pageName 	= c_pageName+'';
							s_hier2 	= c_hier2+'';
							s_hier5 	= c_hier5+''; 
							s_prop13 	= c_prop13+'';
							s_prop22 	= c_prop22+'';
							s_channel	= c_channel+'';
							
						}catch(e){
							System.out.println('problem resetting reporting variables');
						}
						*/
						//System.out.println('POSTTEST: s_pageName='+s_pageName);
						//System.out.println('VALUE s_hier5='+s_hier5);
						
						function getVidGovLabelName(id){
						   id = parseInt(id);
						   switch(id){
						      case 1:
						         return "Warner";
						      break;
						      case 2:
						         return "BMG";
						      break;
						
						      case 3:
						         return "Universal";
						      break;
						
						      case 4:
						         return "Sony";
						      break;
						
						      case 5:
						         return "EMI";
						      break;
						
						      case 6:
						         return "Independent Label";
						      break;
						
						      default:
						      return "Unknown";
						      break;
						   }
						}
					},
					
					pause_next_video : function(index){
						System.out.println('pause_next_video');
						Page.hide('mod_videos.vspot');
						this.pause(this.next_object);
					},
					
					highlight : function(obj) { // changes background color
						this.current_highlight = obj;
						obj.style.backgroundColor = this.highColor;
					},
					
					lowlight : function(obj) {
						obj.style.backgroundColor = this.lowColor;
					},
					
					light : function(obj,color){
						this.current_highlight = obj;
						obj.style.backgroundColor = color;
					},
					
					init : function() {
						var obj = Page.e(Page.mod_videos.current_object);
						Page.mod_videos.pause(obj, true);
					}
				
				}; // End Page.mod_videos
				
				// add to window load events
				Page.onload("Page.mod_videos.init");
				
