var tStart=new Date();
var fv='http://emp.enikos.com/emp/view.php?c=';

var empWidgets;
var empFW;
if(typeof(empWidgets)=="undefined"){
empWidgets={
	playing:null, 
	logID:0,
	logURL:'http://emp.enikos.com/emp/empLog.php',
	checkTimer:null,
	exp:[],

	add:function(id,title,width,height,share,prev,description,click){
		this.exp[id]={'title':title,'prev':prev,'width':width,'height':height,'description':description,'share':share,'click':click};
		this.draw(id);
	},

	draw:function(id){
		var c="<div id='empLauncher"+id+"' style='width:300px;height:250px;background:black;position:relative;overflow:hidden'><div style='padding:1px;width:298px;height:248px;' title='\""+this.exp[id].description+"\"'><div style='position:absolute;width:298;height:217;background:url("+this.exp[id].prev+") top center no-repeat'></div><a href='#play' onclick=\"empWidgets.log('play',"+id+");empWidgets.play("+id+");return false\" style='display:block;position:absolute;width:298;height:248;background:url(http://emp.enikos.com/emp/images/preview.png) bottom left no-repeat'></a>";
		c+=(this.exp[id].share?"<a href='#share' onclick=\"empWidgets.shareThis("+id+");return false\" title='Share: "+this.exp[id].title+"' style='display:block;position:absolute;top:217px;right:0px;width:46px;height:32px;background:url(http://emp.enikos.com/emp/images/share.png) top right no-repeat'></a>":'<!--no sharing-->');
		c+="<a href='http://enikos.com' target='_blank' title='About Enikos' style='display:block;position:absolute;top:5px;right:5px;color:#333;text-decoration:none'>Enikos</a><a href='#play' onclick=\"empWidgets.log('play',"+id+");empWidgets.play("+id+");return false\" style='display:block;position:absolute;top:202px;left:50px;width:200px;color:white;text-decoration:none;font-weight:bold;font:16pt/60px arial,sans-serif;text-align:center'>"+this.exp[id].title+"</a></div></div>";

		var w=document.getElementById('empLegacy'+id);
		if(!w){document.write('<div id="empWidget'+id+'"></div>');w=document.getElementById('empWidget'+id);}
		w.innerHTML=c;
		
		var tEnd=new Date();
		var tDiff=tEnd.getTime() - tStart.getTime();
		empWidgets.log('preview&t='+tDiff,id);
	},
	
	shareThis:function(id){
		var p = window.open("http://w.sharethis.com/widget/loading", "stframe","status=1,toolbar=0,width=354,height=437");
		try{
			p.document.open();
			p.document.clear();
			p.window.document.write(SHARETHIS.widget.loaderHTML);
			p.document.close();
			p.focus();
		}catch(err){}
		var f=document.createElement("form");
		f.method = "post";
		f.action = "http://sharethis.com/share/lightbox.php";
		f.target = "stframe";
		
		
		field = function(k, v, brackets) {
			var f   = document.createElement("input");
			f.type  = "hidden";
			f.name  = (brackets == true ? k + "[]" : k);
			f.value = v;
			return f;
		}
		normalize=function(s){return(s==null?'':encodeURIComponent(s));}
		
		f.appendChild(field("meta_hostname",normalize("emp.enikos.com")));
		f.appendChild(field("meta_location",normalize("/emp/widget.php")));
		f.appendChild(field("page_url",normalize("")));
		f.appendChild(field("opts_popup",normalize("true")));
		f.appendChild(field("opts_publisher",normalize("5076552f-5980-422d-b0ae-bb6fdffa0724")));
		f.appendChild(field("query_publisher",normalize("5076552f-5980-422d-b0ae-bb6fdffa0724")));
		
		f.appendChild(field("title[]",normalize(this.exp[id].title)));
		f.appendChild(field("summary[]",normalize(this.exp[id].description)));
		f.appendChild(field("icon[]",normalize(this.exp[id].prev)));
		f.appendChild(field("url[]",normalize("http://emp.enikos.com/emp/view.php?c="+id)));
		
		document.body.appendChild(f);
		f.submit();
		return false;
	},

	play:function(id){
		this.playing=id;
		var p="<div id='curtain' style='position:absolute;left:0;top:0;width:100%;z-index:10001;text-align:center'><div style='position:absolute;left:0;top:0;z-index:1;width:100%;height:3000px;background:#333;filter:alpha(opacity=75);-moz-opacity:.75;opacity:.75'></div><div id='emp' style='position:relative;margin:5px auto;border:2px solid #000;border-color:#777 #444 #444 #777;z-index:2;overflow:hidden;background:#000;width:"+this.exp[id].width+"px'>";
		p+="<div style='background:#444 url(http://emp.enikos.com/emp/images/grad.png) bottom left;height:28px;color:silver;font:16pt arial,sans-serif;text-align:center;border-bottom:1px solid #444'><a href='#' onClick=\"empWidgets.log('close',id);empWidgets.close();return false\" title='Close Experience' style='background:#222 url(http://emp.enikos.com/emp/images/close.png) bottom left no-repeat;width:45px;height:28px;border:0;float:right'></a>"+this.exp[id].title+"</div>";
		p+="<iframe id='empifr' frameBorder='0' width='"+this.exp[id].width+"' height='"+(this.exp[id].height+16)+"' scrolling='no' src='"+(fv+id)+"'></iframe>";
		p+="</div></div></div>";
		document.body.innerHTML+=p;
		var c=document.getElementById('curtain');
		var e=document.createElement('div');
		e.setAttribute('id','empFWc');
		e.style.position='relative';
		e.style.zIndex=2;
		c.appendChild(e);

		scroll(0,0);//top

		clearTimeout(this.checkTimer);
		this.checkTimer=setInterval("empWidgets.check()",200);
	},

	close:function(){
		this.playing=null;
		clearTimeout(this.checkTimer);
		try{document.getElementById('empifr').setAttribute('src','');}catch(e){}
		var curtain=document.getElementById('curtain');
		curtain.parentNode.removeChild(curtain);
		empFW.windowCounter=0;
	},

	check:function(){
		var hash=document.location.hash;
		if(hash.length>1){
			document.location.hash='#';
			var url=unescape(hash).replace(/#/g,'');
			if(url.indexOf('http')===0){empFW.open(url);}
			if(url=="end"){this.log('end',this.playing);this.close();}
		}
	},

	log:function(s,id){
		var url=this.logURL + '?id='+id+'&state='+s+'&rnd='+Math.random()
			+ '&'+[(window.screen) ? 'w='+window.screen.width : '', (window.screen) ? 'h='+window.screen.height: ''].join('&');
			
		setTimeout('empWidgets.poll("'+url+'")',10000);
		if(s=='play'){if(this.exp[id].click){this.poll(this.exp[id].click);}}
	},

	poll:function(url){
		var f=document.createElement('iframe');
		f.setAttribute('frameBorder','0');
		f.setAttribute('height','1');
		f.setAttribute('width','1');
		f.setAttribute('src',url);
		f.setAttribute('id','empLog'+this.logID);
		document.body.appendChild(f);
		setTimeout('document.body.removeChild(document.getElementById("empLog'+this.logID+'"))',10000);
		this.logID++;
	}
};

/* empFW code */
empFW={
	open:function(url,w,h){
		var w=(w==null?900:w);
		var h=(h==null?600:h);
		var winID=0;
		while(document.getElementById('win'+winID)){winID++;}
		var fw=document.createElement('div');
		fw.setAttribute('id','win'+winID);
		fw.style.position='absolute';
		fw.style.zIndex=(200+winID);
		fw.style.top=(25*winID)+'px';
		fw.style.left=(25*(winID%4))+'px';
		fw.style.background='#000';
		fw.style.border='2px solid #444';
		fw.style.borderColor='#777 #444 #444 #777';
		fw.style.width=w+'px';
		fw.style.textAlign='right';

		var d=document.createElement('div');
		d.style.height='20px';

		var a=document.createElement('a');
		a.setAttribute('href','#');
		a.setAttribute('title','Close Window');
		a.setAttribute('onclick',"this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);return false;");
		a.onclick=function(){this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);return false;};//for IE
		a.style.display='block';
		a.style.width='16px';
		a.style.height='16px';
		a.style.margin='2px 2px 2px '+(w-18)+'px';
		a.style.background='transparent url(http://emp.enikos.com/emp/images/sprite.gif) no-repeat -64px 0';

		var i=document.createTextNode(' ');

		var f=document.createElement('iframe');
		f.setAttribute('src',url);
		f.setAttribute('frameBorder','0');
		f.setAttribute('width',w+'px');
		f.setAttribute('height',h+'px');

		var e=document.getElementById('empFWc');
		if(e){
			e.style.position='relative';
			e.style.height='2000px';
			e.style.margin='0 auto';
			e.style.width='780px';
		}else{
			e=document.body
			fw.style.top='50px';
			fw.style.marginLeft='50%';
			fw.style.left='-'+(w/2)+'px';
		}

		e.appendChild(fw);
		fw.appendChild(d);
		a.appendChild(i);
		d.appendChild(a);
		fw.appendChild(f);
	}
};
}

if(typeof(click)=="undefined"){
	click=null;
}
empWidgets.add(475,"enikos EMP Introduction",900,520,true,"http://media.enikos.com/upload/c=1/u=46c58872c03b99c0176ea35136ea2b2e/142_miab.jpg","Preview our next generation media platform",click);
click=null;
empWidgets.log('server&t=0',475)