
function playHDMovie(movie,title){   
   movie = 'http://downloads.rogers.com/movies/'+movie;
	showMovie(movie,title);
}

var channelsubtabs={
	subcontainers:[], 
	last_accessed_tab:null,
	channeltabids:[],
	path_prefix:null,
	
	revealsubmenu:function(curtabref){
	   if(curtabref) {
			this.hideallsubs()
			if (this.last_accessed_tab!=null)
				this.last_accessed_tab.className="rocketStickTabLevel2Off"
			if (curtabref.getAttribute("tabid")) //If there's a sub menu defined for this tab item, show it
				if(document.getElementById(curtabref.getAttribute("tabid")))
				    document.getElementById(curtabref.getAttribute("tabid")).style.display="block"

			if (curtabref.getAttribute("path")) //If there's a image path defined
				if(document.getElementById("channels_sub_main_img_"))				    
				    document.getElementById("channels_sub_main_img_").src=this.path_prefix + curtabref.getAttribute("path")
				    
			curtabref.className="rocketStickTabLevel2On"
			this.last_accessed_tab=curtabref
		}
	},

	hideallsubs:function(){
		for (var i=0; i<this.subcontainers.length; i++) {
		   if(document.getElementById(this.subcontainers[i]))
			    document.getElementById(this.subcontainers[i]).style.display="none"
		}
	},

   revealsubmenubyid:function(tabid){
      this.revealsubmenu(document.getElementById(tabid))
   },
   
   reveal:function(index) {
      if(index <  channelsubtabs.channeltabids.length) {
         if(document.getElementById("channels_main_"))
            document.getElementById("channels_main_").style.display="none"
         if(document.getElementById("channels_sub_"))
            document.getElementById("channels_sub_").style.display="block"    
   		channelsubtabs.revealsubmenubyid(channelsubtabs.channeltabids[index])
   	}
   },
   
   revealmain:function() {
       if(document.getElementById("channels_sub_"))
         document.getElementById("channels_sub_").style.display="none" 
       if(document.getElementById("channels_main_"))
         document.getElementById("channels_main_").style.display="block"            
   },
   
	init:function(menuId, selectedIndex,path){
	   if(document.getElementById(menuId)) {
	      this.path_prefix=path
			var selectedMenu = false
			var tabItems=document.getElementById(menuId).getElementsByTagName("li")
			for (var i=0; i<tabItems.length; i++){
				if (tabItems[i].getAttribute("tabid"))
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("tabid") //store id of submenu div of tab menu item
				if (tabItems[i].getAttribute("id"))
					this.channeltabids[this.channeltabids.length]=tabItems[i].getAttribute("id")
				if (i==selectedIndex){ //if this tab item should be selected by default
				   selectedMenu = true
				}
				tabItems[i].onclick=function() {
					channelsubtabs.revealsubmenu(this)
				}
			} //END FOR LOOP
			if (selectedMenu) {
			   tabItems[selectedIndex].className="rocketStickTabLevel2On"
				this.revealsubmenu(tabItems[selectedIndex])
			}
			//channelsubtabs.revealsubmenubyid(pnpsubtabs.channeltabids[0])
		}
	}
}

var offersubtabs={
	subcontainers:[], 
	last_accessed_tab:null,
	offertabids:[],

	revealsubmenu:function(curtabref){
	  if(curtabref) {
			this.hideallsubs()
			if (this.last_accessed_tab!=null)
				this.last_accessed_tab.className="rocketStickTabLevel2Off"
			if (curtabref.getAttribute("tabid")) //If there's a sub menu defined for this tab item, show it
			   if (document.getElementById(curtabref.getAttribute("tabid")))
					document.getElementById(curtabref.getAttribute("tabid")).style.display="block"
			curtabref.className="rocketStickTabLevel2On"
			this.last_accessed_tab=curtabref
	  }
	},

	hideallsubs:function(){
		for (var i=0; i<this.subcontainers.length; i++) {
		   if(document.getElementById(this.subcontainers[i]))
				document.getElementById(this.subcontainers[i]).style.display="none"
		}
	},

   revealsubmenubyid:function(tabid){
      this.revealsubmenu(document.getElementById(tabid))
   },
   
   reveal:function(index) {
      if(index <  offersubtabs.offertabids.length)
   		offersubtabs.revealsubmenubyid(offersubtabs.offertabids[index])
   },
   
	init:function(menuId, selectedIndex){
	  if (document.getElementById(menuId)) {
			var selectedMenu = false
			var tabItems=document.getElementById(menuId).getElementsByTagName("li")
			for (var i=0; i<tabItems.length; i++){
				if (tabItems[i].getAttribute("tabid"))
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("tabid") //store id of submenu div of tab menu item
					this.offertabids[this.offertabids.length]=tabItems[i].getAttribute("id")
				if (i==selectedIndex){ //if this tab item should be selected by default
				   selectedMenu = true
				}
				tabItems[i].onclick=function() {
					offersubtabs.revealsubmenu(this)
				}
			} //END FOR LOOP
			if (selectedMenu) {
			   tabItems[selectedIndex].className="rocketStickTabLevel2On"
				this.revealsubmenu(tabItems[selectedIndex])
			}
		}
	}

}


var pnpsubtabs={
	subcontainers:[], 
	last_accessed_tab:null,
	plugnplaytabids:[],

	revealsubmenu:function(curtabref){
	   if(curtabref) {
			this.hideallsubs()
			if (curtabref.getAttribute("anchorid")) {
			    if(document.getElementById(curtabref.getAttribute("anchorid")))
			        window.open(document.getElementById(curtabref.getAttribute("anchorid")).href)			    
			}
			if (this.last_accessed_tab!=null)
				this.last_accessed_tab.className="rocketStickTabLevel2Off"
			if (curtabref.getAttribute("tabid")) //If there's a sub menu defined for this tab item, show it
			   if(document.getElementById(curtabref.getAttribute("tabid")))
			       document.getElementById(curtabref.getAttribute("tabid")).style.display="block"
			curtabref.className="rocketStickTabLevel2On"
			this.last_accessed_tab=curtabref
	   }
	},

	hideallsubs:function(){
		for (var i=0; i<this.subcontainers.length; i++) {
		   if(document.getElementById(this.subcontainers[i]))
				document.getElementById(this.subcontainers[i]).style.display="none"
		}
	},

   revealsubmenubyid:function(tabid){
      this.revealsubmenu(document.getElementById(tabid))
   },
   
   reveal:function(index) {
   		pnpsubtabs.revealsubmenubyid(pnpsubtabs.plugnplaytabids[index])
   },
   
	init:function(menuId, selectedIndex){
	   if (document.getElementById(menuId)) {
			var selectedMenu = false
			var tabItems=document.getElementById(menuId).getElementsByTagName("li")
			for (var i=0; i<tabItems.length; i++){
				if (tabItems[i].getAttribute("tabid"))
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("tabid") //store id of submenu div of tab menu item
					this.plugnplaytabids[this.plugnplaytabids.length]=tabItems[i].getAttribute("id")
				if (i==selectedIndex){ //if this tab item should be selected by default
				   selectedMenu = true
				}
				tabItems[i].onclick=function() {
					pnpsubtabs.revealsubmenu(this)
				}
			} //END FOR LOOP
			if (selectedMenu) {
			   tabItems[selectedIndex].className="rocketStickTabLevel2On"
				this.revealsubmenu(tabItems[selectedIndex])
			}
		}
	}

}

var hdutil = {

   hideallexceptme:function(tabid, myindex){
       this.hideallbyid(tabid)
       this.showtab(tabid + myindex)
	},
	
	hideallbyid:function(id){
	   var i = 1;
	   while (true) {
		   if(document.getElementById(id + i) != null){
		     document.getElementById(id + i).style.display="none"
		     i++
		   } else {
		      break
		   }
      }
	},
	showtab:function(tabid){
	    if(document.getElementById(tabid)) {
	       document.getElementById(tabid).style.display="block"
	    }
	}
}

var hdtabs={
	subcontainers:[],
	centerblockids:[], 
	last_accessed_tab:null,
	path_prefix:null,

	revealsubmenu:function(curtabref){
	   if(curtabref) {
			if (curtabref.getAttribute("centerid")!=null){ //If there's a main image defined for this tab item, show it
			
			   this.hideallsubs()
			   //document.getElementById("imgMain_").parentNode.style.display="none"
				//document.getElementById("imgMain_").src=this.path_prefix + curtabref.getAttribute("path")	
				//document.getElementById("imgMain_").parentNode.parentNode.style.height=document.getElementById("imgMain_").height
				
				if (document.getElementById(curtabref.getAttribute("centerid"))) {
				    if (curtabref.getAttribute("hideid")!=null){
					    if (document.getElementById(curtabref.getAttribute("hideid"))) {
					        document.getElementById(curtabref.getAttribute("hideid")).style.display="none"
					    }
				    }
				    document.getElementById(curtabref.getAttribute("centerid")).style.display="block"
				}
	
				if (curtabref.getAttribute("rel")){ //If there's a sub menu defined for this tab item, show it
				   if(document.getElementById(curtabref.getAttribute("rel")))
						document.getElementById(curtabref.getAttribute("rel")).style.display="block"
				}
				if (this.last_accessed_tab != null ){ // if the menu is not selected for first time
					this.last_accessed_tab.className="redlblnotselected"
					this.last_accessed_tab.parentNode.className="redmenunotselected"
				}
				curtabref.className="blklblselected"
				curtabref.parentNode.className="blkmenuselected"
				this.last_accessed_tab=curtabref
			}
		}
	},

	hideallsubs:function(){
		for (var i=0; i<this.subcontainers.length; i++) {
		   if(document.getElementById(this.subcontainers[i]))
				document.getElementById(this.subcontainers[i]).style.display="none"
		}
		for (var i=0; i<this.centerblockids.length; i++) {
			if(document.getElementById(this.centerblockids[i]))
				document.getElementById(this.centerblockids[i]).style.display="none"
		}
	},

	inittab:function(pathprefix, menuId, selectedIndex){
	   if (document.getElementById(menuId)) {
			var selectedMenu = false
			this.path_prefix = pathprefix
			var tabItems=document.getElementById(menuId).getElementsByTagName("label")
			for (var i=0; i<tabItems.length; i++){
				if (tabItems[i].getAttribute("rel")){
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("rel") //store id of submenu div of tab menu item
	
					tabItems[i].onclick=function(){
					   hdtabs.revealsubmenu(this)
					}
				}
				if (tabItems[i].getAttribute("centerid")){
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("centerid") //store id of center block div
				}
				if (tabItems[i].getAttribute("hideid")){
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("hideid") //store id of center block div
				}
				tabItems[i].parentNode.onclick=function(){
				   hdtabs.revealsubmenu(this.firstChild)
				}
				if (tabItems[i].getAttribute("centerid")==null && !selectedMenu){ //see if selected index is ment for this menu
				    selectedIndex++
				}
				if (i==selectedIndex){ //if this tab item should be selected by default
				   selectedMenu = true
				}
	
			} //END FOR LOOP
			if (selectedMenu) {
					this.revealsubmenu(tabItems[selectedIndex])
			}
		}
	}

}

var movietabs={
	subcontainers:[], 
	last_accessed_tab:null,
	path_prefix:null,
	selectedLinkIndex:0,
	
	playnovie:function(){
     if (this.selectedLinkIndex < this.subcontainers.length) {
     		if (document.getElementById(this.subcontainers[this.selectedLinkIndex])) {
     		    document.location.href=document.getElementById(this.subcontainers[this.selectedLinkIndex]).href
     		}
     }
   },
	
	slideMovieBackward:function(){
     this.selectedLinkIndex = ((this.selectedLinkIndex - 1 + this.subcontainers.length)%(this.subcontainers.length))
     this.flipMovie(document.getElementById(this.subcontainers[this.selectedLinkIndex]))
   },
	
   slideMovieForward:function(){
     this.selectedLinkIndex = ((this.selectedLinkIndex + 1)%(this.subcontainers.length))
     this.flipMovie(document.getElementById(this.subcontainers[this.selectedLinkIndex]))
   },

	flipMovie:function(curtabref){
	   if(curtabref) {
		   var filename = curtabref.getAttribute("path")
			if (this.last_accessed_tab != null ){
			  this.last_accessed_tab.className="BlackLink"
			}
			if(document.getElementById("HdOnDemandImgBlockImage"))
				document.getElementById("HdOnDemandImgBlockImage").src = this.path_prefix + filename
			if(document.getElementById("HdMovieNameId_"))
				document.getElementById("HdMovieNameId_").innerHTML  = curtabref.getAttribute("txt")
			curtabref.className="redlink"
			this.last_accessed_tab=curtabref
			for (var i = 0; i < this.subcontainers.length; i++){
			    if (curtabref.getAttribute("id") == this.subcontainers[i]){
			       this.selectedLinkIndex = i
			    }
			}
		}
	},

	initlinks:function(pathprefix, linkId,selectedlink){
	if (document.getElementById(linkId)) {
	  			
		var selectedMenu = false
		this.path_prefix = pathprefix
		var tabItems=document.getElementById(linkId).getElementsByTagName("a")
			for (var i=0; i<tabItems.length; i++){
					this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("id") //store id of submenu div of tab menu item
					//tabItems[i].href="javascript:movietabs.flipMovie(this);"
					tabItems[i].onclick=function(){
					   movietabs.flipMovie(this)
					}
					if(i==selectedlink) {
					   this.selectedLinkIndex = i
					   this.flipMovie(tabItems[i])
					}
			} //END FOR LOOP
			if(document.getElementById("hdrightimg_"))
				document.getElementById("hdrightimg_").onclick=function(){
						   movietabs.slideMovieForward(this)
				}
			if(document.getElementById("hdleftimg_"))
				document.getElementById("hdleftimg_").onclick=function(){
						   movietabs.slideMovieBackward(this)
				}				
			if(document.getElementById("HdOnDemandImgBlockImage")) {
			   document.getElementById("HdOnDemandImgBlockImage").onclick=function(){
						   movietabs.playnovie()
				}
			}
			
			  
		}
	}

}

