var SViewer = {
	
	url : null,
	title : null,
	showing : false,
	
	popupSpec : null,
	
	defaultSpec :{
		width:	790,
		height:	450
	},

	show : function (title, url, dims){
		title="&nbsp;";
		if (dims){
			SViewer.popupSpec = dims;
		} else {
			SViewer.popupSpec = SViewer.defaultSpec;
		}
		
		//Possible bug, what if url does not contain '?'?
		url = url+'&mssource='+MS.source;
		SViewer.title = title;
		SViewer.url = url;
		
		if (SViewer.win == null) {
			var s=SViewer.popupSpec;
			
			if (MS.browser == BR_IE){
				windowHeight 	= document.documentElement.clientHeight;
				windowWidth 	= document.documentElement.clientWidth;
			} else {
				windowHeight 	= window.innerHeight;
				windowWidth 	= window.innerWidth;
			}
			
			var top = ((windowHeight/2) -(SViewer.popupSpec.height/2));
			var left = ((windowWidth/2) -(SViewer.popupSpec.width/2));
			SViewer.win = new JsWin(title, s.width,s.height, left, top);
			SViewer.win.content.style.overflow = 'hidden';
		}

		if (!SViewer.showing){
			SViewer.win.onshow = SViewer.doContent;
			SViewer.win.onhide = SViewer.doHide;
			SViewer.win.show();
			SViewer.showing = true;
		} else {
			SViewer.doContent();	
		}
	},
	
	hide : function(){
		SViewer.win.hide();
	},
	
	doHide : function(){
		SViewer.showing = false;
	},
	
	reload : function(){
		SViewer.doContent();
	},
	
	doContent : function() {
		var container = SViewer.win.content;
		SViewer.win.changeTitle(SViewer.title);
		var height = SViewer.popupSpec['height']-4;
		var width = container.clientWidth-8;//SViewer.popupSpec['width']-8;
		
		var scroll = 'scrolling="yes"';
		
		if (MS.browser != BR_IE){scroll ='';};
		
		container.innerHTML = '<iframe '+scroll+' marginheight="0" marginwidth="0" src="'+SViewer.url+'" border="0" width="'+width+'" style="height: '+height+'px;"></iframe>';
	}
}
	
