if(!SmackDisplay){
		var SmackDisplay = function(container,swf,id,width,height,bgcolor,params){
			this.id = id;
			var na = navigator.userAgent;
			SmackDisplay.setBrowser();
			
			var so = new SWFObject(swf,id,width,height,"9",bgcolor,"high");
			so.useExpressInstall('expressinstall.swf');
			
			//if(bgcolor == 'transparent')
			so.addParam("wmode", "transparent");
			so.addParam("menu", "false");
			so.addParam("allowFullScreen", "true");	
			so.addParam("allowScriptAccess", "always");
			so.write(container);
			
			SmackDisplay.getFlashMovie(id).smackData = params;
		};
		SmackDisplay.prototype = new Object();
		SmackDisplay.prototype.constructor = SmackDisplay;
		
		SmackDisplay.getParams = function(id){
			return SmackDisplay.getFlashMovie(id).smackData
		}
		
		SmackDisplay.removePopup = function(){
			if(!SmackDisplay.popup) return;
			setTimeout("SmackDisplay._doRemovePopup()", 100);
		}
		
		SmackDisplay._doRemovePopup = function(){
			if(!SmackDisplay.popup) return;
			document.body.removeChild(SmackDisplay.popup);
			SmackDisplay.popup = undefined;
		}		
		SmackDisplay.setContainerSize = function(w,h){
			var elem = document.getElementById("smackpopupcontainer");
			elem.style.width = w+"px";
			elem.style.height = "";
			elem.flashcontainer.style.width = w+"px";
			elem.flashcontainer.style.height = h+"px";
			elem.style.top = (screen.availHeight-h)/2+"px";
			elem.style.left = (screen.availWidth-w)/2+"px";			
			
			//alert(w+"x"+h);
		}
		
		SmackDisplay.moveContainer = function(byX,byY){
			var elem = document.getElementById('smackpopupcontainer');
			var x = parseInt(elem.style.top)+byY;
			var y = parseInt(elem.style.left)+byX;
			elem.style.top = x;
			elem.style.left = y;
		}
		
		SmackDisplay.intToColor = function(col){
			var color = Number(col).toString(16);
			while(color.length < 6) color = "0"+color;
			return "#"+color;
		}
		
		SmackDisplay.setBrowser = function(){
			  var ua, s, i;
			  var ret = new Object();
			  ret.isIE    = false;
			  ret.isNS    = false;
			  ret.version = null;
			
			  ua = navigator.userAgent;
			
			  s = "MSIE";
			  if ((i = ua.indexOf(s)) >= 0) {
			    ret.isIE = true;
			    ret.version = parseFloat(ua.substr(i + s.length));
			  }
			
			  s = "Netscape6/";
			  if ((i = ua.indexOf(s)) >= 0) {
			    ret.isNS = true;
			    ret.version = parseFloat(ua.substr(i + s.length));
			  }
			
			  // Treat any other "Gecko" browser as NS 6.1.
			
			  s = "Gecko";
			  if ((i = ua.indexOf(s)) >= 0) {
			    ret.isNS = true;
			    ret.version = 6.1;
			  }	
			  SmackDisplay.browser = ret;		
		}
		
		SmackDisplay.showPopup = function(params){
			if(SmackDisplay.popup != undefined){
				SmackDisplay._doRemovePopup();
			}

			var elem = document.createElement("DIV");
			elem.style.position = 'absolute';
			elem.style.width = '330px';
			elem.style.height = '300px';

			elem.style.top = ((screen.availHeight-300)/2)+"px";
			elem.style.left = ((screen.availWidth-330)/2)+"px";
			elem.style.backgroundColor = SmackDisplay.intToColor(params.style['bgColor']);
			elem.style.border = "1px solid #726B6B";

			elem.id = "smackpopupcontainer";
			
			var header = document.createElement("DIV");
			header.style.height = '25px';
			header.style.fontFamily = "Verdana,Arial,Helvetica";
			header.style.fontSize = "11px";
			header.style.fontWeight = "bold";
			header.style.color = SmackDisplay.intToColor(params.style['textColor']);
			header.style.lineHeight = "25px";
			header.style.paddingLeft = "6px";
			header.style.paddingRight = "5px";

			var closeImg = document.createElement("IMG");
			closeImg.src = params['domain']+"/client/assets/closebtn.gif";
			closeImg.align="right";
			closeImg.style.marginTop = "10px";
			closeImg.style.marginRight = "1px";
			closeImg.onclick = "SmackDisplay.removePopup()";

			var browser = SmackDisplay.browser;
			if (browser.isIE) {
			    header.attachEvent("onmousedown", SmackDisplay.dragStart);
			    closeImg.attachEvent("onclick", SmackDisplay.removePopup);
			}
			if (browser.isNS) {
			    header.addEventListener("mousedown", SmackDisplay.dragStart,   true);
			    closeImg.addEventListener("click", SmackDisplay.removePopup, true);
            }

			header.appendChild(closeImg);
			
			var title = "";
			var subj = "";
			for(var i=0; i<params.meta.length; i++)
				if(params.meta[i] && params.meta[i].value){
					if(params.meta[i].name == 'meta_subject')
						subj = params.meta[i].value;		
					if(parseInt(params.meta[i].is_title)){
						if(params.meta[i].input_type != "dropdwon")
							title = params.meta[i].value;
						else{
							for(var ii=0; ii < params.meta[i].input_data; ii++)
								if(params.meta[i].input_data[ii].value == params.meta[i].value)
									title = params.meta[i].input_data[ii].label;
						}
					}
				}
			if(!title)
				 title = subj?subj:"Video playback";		
			
			
			header.appendChild(document.createTextNode(title));
			
			var flashcontainer = document.createElement("DIV");
			
			elem.appendChild(header);
			elem.flashcontainer = elem.appendChild(flashcontainer);

			SmackDisplay.popup = document.body.appendChild(elem);

			var so = new SWFObject(params['domain']+"/client/SmackVideoDisplay.swf",'smackpopupflash','100%','100%',"9",SmackDisplay.intToColor(params.style['bgColor']),"high");
			so.useExpressInstall(params['domain']+'/client/expressinstall.swf');
			//so.addParam("wmode", "transparent");
			so.addParam("allowFullScreen", "true");
			so.addParam("allowScriptAccess", "always");
			so.addParam("menu", "false");
			so.write(flashcontainer);
			SmackDisplay.getFlashMovie('smackpopupflash').smackData = params;
		}
		
		SmackDisplay.getFlashMovie = function(movieName) {
			return document.getElementById(movieName);
		}
		
		SmackDisplay.test = function(){
			SmackDisplay.showPopup({
			'layout':{'thumbWidth':'165','thumbHeight':'165','itemsPerPage':'3','showBottomNav':true,'showTopNav':true,'rows':'3','showSearch':true,'position':'bottom','columns':'1','direction':'horizontal'},
			'search':[],
			'sort':[{'dir':'D','name':'meta_time_added'}],
			'service':'http://app1.smackbiz.biz/smackbiz/gateway.php',
			'style':{'bgAlphaTop':1,'bgColorTop':26112,'bgAlphaBottom':0,'textColor':16777215,'themeColor':51,'bgImage':'','bgColor':65280,'bgColorBottom':65535},
			'domain':'http://app1.smackbiz.biz/smackbiz',
			'meta':{'meta_subject':{'show_label':false,'bold':true,'order':2},'meta_submitter':{'show_label':true,'bold':false,'order':5},'meta_orig_name':{'show_label':false,'bold':false,'order':3},'meta_time_added':{'show_label':false,'bold':false,'order':6},'meta_category':{'show_label':false,'bold':false,'order':1},'meta_author':{'show_label':false,'bold':false,'order':4}}
			});
		}
		
		// Global object to hold drag information.
		SmackDisplay.dragObj = new Object();
		SmackDisplay.dragObj.zIndex = 0;
		
		SmackDisplay.dragStart = function(event) {
			var x, y;
			var dragObj = SmackDisplay.dragObj
			dragObj.elNode = SmackDisplay.popup;

			// Get cursor position with respect to the page.
			var browser = SmackDisplay.browser;

			if (browser.isIE) {
				x = window.event.clientX + document.documentElement.scrollLeft
				    + document.body.scrollLeft;
				y = window.event.clientY + document.documentElement.scrollTop
				    + document.body.scrollTop;
			}
			if (browser.isNS) {
			    x = event.clientX + window.scrollX;
			    y = event.clientY + window.scrollY;
			}

			// Save starting positions of cursor and element.

			dragObj.cursorStartX = x;
			dragObj.cursorStartY = y;
			dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
			dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

			if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
			if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

			// Update element's z-index.
			dragObj.elNode.style.zIndex = ++dragObj.zIndex;

			// Capture mousemove and mouseup events on the page.
			if (browser.isIE) {
			    document.attachEvent("onmousemove", SmackDisplay.dragGo);
			    document.attachEvent("onmouseup",   SmackDisplay.dragStop);
			    window.event.cancelBubble = true;
			    window.event.returnValue = false;
			}
			if (browser.isNS) {
			    document.addEventListener("mousemove", SmackDisplay.dragGo,   true);
			    document.addEventListener("mouseup",   SmackDisplay.dragStop, true);
			    event.preventDefault();
			}
		}

		SmackDisplay.dragGo = function (event) {
			var x, y;
			var browser = SmackDisplay.browser;
			if (browser.isIE) {
				x = window.event.clientX + document.documentElement.scrollLeft
					+ document.body.scrollLeft;
				y = window.event.clientY + document.documentElement.scrollTop
					+ document.body.scrollTop;
			}
			if (browser.isNS) {
				x = event.clientX + window.scrollX;
				y = event.clientY + window.scrollY;
			}

			SmackDisplay.dragObj.elNode.style.left = (SmackDisplay.dragObj.elStartLeft + x - SmackDisplay.dragObj.cursorStartX) + "px";
			SmackDisplay.dragObj.elNode.style.top  = (SmackDisplay.dragObj.elStartTop  + y - SmackDisplay.dragObj.cursorStartY) + "px";

			if (browser.isIE) {
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			}
			if (browser.isNS)
				event.preventDefault();
		}

		SmackDisplay.dragStop = function(event) {
			var browser = SmackDisplay.browser;
			if (browser.isIE) {
			    document.detachEvent("onmousemove", SmackDisplay.dragGo);
			    document.detachEvent("onmouseup",   SmackDisplay.dragStop);
			}
			if (browser.isNS) {
				document.removeEventListener("mousemove", SmackDisplay.dragGo,   true);
				document.removeEventListener("mouseup",   SmackDisplay.dragStop, true);
			}
		}		
}