


Vudu.widget.PurchasePanel = function( parentDiv , refDiv , mId , mTitle , pageUrl , rootUrl )	{
	
	this._parentDiv = parentDiv;
	this._movieTitle = mTitle;
	this._movieId = mId;
	// is sent with the purchase detail request 
	// as the URL for the request
	this._pageURL = pageUrl;
	this._rootUrl = rootUrl;
	this.refRegion = YAHOO.util.Dom.getRegion(refDiv);
	
	this.render();
};


Vudu.widget.PurchasePanel.prototype = {

	render : function()	{
		
		var sugX = Math.round( (YAHOO.util.Dom.getViewportWidth() - 550 )/2) ;
		var sugY = Math.round( (YAHOO.util.Dom.getViewportHeight() - 250 )/2) ;
		
		// populate YUI panel
		this.popupPanel = new YAHOO.widget.Panel( YAHOO.util.Dom.get(this._parentDiv) , {
				width:"550px",
				visible:false,
				constraintoviewport:false,
				draggable:false ,
				underlay: "shadow",
				modal:true,
				fixedcenter:false,
				x: sugX,
				y: sugY,
				close:false,
				zIndex:100000
		});
		
        
		// build the table of the panel div - contains the title and iframe 
		var cTable = document.createElement('table');
		cTable.cellspacing = '0';
		cTable.cellpadding = '0';
		cTable.border = '0';
		
		var cRow = cTable.insertRow(0);
		
		var frameCel = cRow.insertCell(0);
		
		this.purchaseFrame = document.createElement('iframe');
		this.purchaseFrame.width = '542px';
		this.purchaseFrame.height = '295px';
		this.purchaseFrame.scrolling = 'no';
		this.purchaseFrame.frameBorder = '0';
		
		frameCel.appendChild(this.purchaseFrame);
		
		this.popupPanel.render();
		
		// set the body of the div 
		this.popupPanel.setBody(cTable);
		// render the YUI panel
	},
	
	showPanel : function( pto )	{
		
		this.purchaseFrame.src = this._rootUrl+'/LoadMoviePurchaseDetails?contentId='+this._movieId+'&offerType='+pto+'&pageReturnUrl='+this._pageURL;
		this.popupPanel.show();
	}
};