
if(!window.slideband)
	slideband = {};


slideband.DocumentViewer = new Class({

		initialize:function(){
			this.isListBoxOpen = false;
			this.currFile = "";
			this.canOpen = true;
			
			this.postListBoxFx = new Fx.Tween($("presentationTool"), {
				onComplete: this.onTweenComplete.bind(this)
			});
		},
		
		onTweenComplete: function(){
			this.canOpen = true;
			if(this.isListBoxOpen)
				this.get_document(this.currFile);
			else 
				$("presentationTool").empty();
		},
		
		open_viewer:function(str) {
			if(screen.height<=800) {
				 window.scrollTo(0,400);
			}
			this._open_viewer(str);
			
		},
		
		_open_viewer:function(str){
			this.postListBoxFx.cancel();
			this.currFile = str; 
			this.isListBoxOpen = true;
			this.postListBoxFx.start('height', 800);
		},
		
		close_viewer:function(){
			this.postListBoxFx.cancel();
			this.isListBoxOpen = false;
			if(screen.height<=800) {
				 window.scrollTo(0,0);
			}
			this.postListBoxFx.start('height', 0);
			
		},
		
		get_document:function(src){
			$("presentationTool").empty();
			var iframe = new Element("iframe", {
				src:src,
				border:"0",
				scrolling:"no",
				align:"left",
				frameborder:"0",
				marginwidth:"1",
				marginheight:"1",
				height:800,
				width:704 
			});
			
			//console.log(src);
			$("presentationTool").grab(iframe);
		}
});

window.addEvent('domready', function() {  
	__H_docviewer = new slideband.DocumentViewer();
} );


