// JavaScript Document
function mgrInit() {
	var hero = $("hero_image");
	if (hero && !$("manager_photos") && !$("manager_videos") && !$("manager_mns") && !$("manager_whitepaper")) {
		var heroImg = $T("img",hero)[0];
		if (heroImg) {
			
			var src = heroImg.src;
			var thumbIndex = src.indexOf("_thumb.");
			if (thumbIndex > 0 ) {
				src = src.replace("_thumb","");	
			}
			
			Event.observe(heroImg,"click",function(){
					var el = $E("div",{className:"photoz"});
					var heroImageClone = $E("img");
					heroImageClone.style.height="1px";
					heroImageClone.src = src;
					if (MNP.Browser.IE) {
							el.appendChild(heroImageClone);
							heroImageClone.style.height="auto";
	
							el.style.width = heroImageClone.offsetWidth + "px";
							Mbox.show(el,{className:"abox",closer:true,screen: {cancel: true,opacity: .35},s_class: "smoke", autoSize:1});
					} else {
						heroImageClone.onload = function(){
							el.appendChild(heroImageClone);
							heroImageClone.style.height="auto";
	
							el.style.width = heroImageClone.offsetWidth + "px";
							Mbox.show(el,{className:"abox",closer:true,screen: {cancel: true,opacity: .35},s_class: "smoke", autoSize:1});
						}
					}
			});	
		}
	}
	
	
	var finePrintPopupLink = $("finePrintLink");
	
	if (finePrintPopupLink) {
		Event.observe("finePrintLink","click",showFinePrint);	
	}
	
}
 function showFinePrint(e) {
     Event.stop(e);
	 var features = $("features").cloneNode(true);
	 features.id="";
     Mbox.show(features,{className:"abox",closer:true,screen: {cancel: true,opacity: .35},s_class: "smoke", autoSize:1});
 }
  
var Manager = {};
Manager.Video = function(){
	var videos = [];
	
	var FliqzPlayer = function(){
		var attrib = {
		  id:'player',
		  width:'450',
		  height:'392',
		  movie:'http://content.fliqz.com/components/885ff52cd63341caa567f0e90d2dde02.swf',
		  allowFullScreen:'true',
		  type:'application/x-shockwave-flash',
		  pluginspage:'http://www.macromedia.com/go/getflashplayer'
		};
		
		function createPlayer(target, fv, caption) {
		  var env = $(target);
		  var flashSupport = getFlashSupport();
		
		  if (flashSupport[0] < 9) {
		
			var msg = $E("p", {
			  parentNode:env,
			  className: "error",
			  text: "Sorry,  Adobe Flash Player version 9 (or above) is required to view the video."
			});
		
		  } else {
			if (caption) {
				var cptn = $E("div", {id:"caption",par: env});
				cptn.innerHTML = '<strong>Now Playing: ' + caption + '</strong>';
			}
				
			if (MNP.Browser.IE) {
			  var emed = $E("embed", {
				parentNode: env,
				attributes:{
				  id: attrib.id,
				  src: attrib.movie,
				  width: attrib.width,
				  height: attrib.height,
				  allowFullScreen: attrib.allowFullScreen,
				  wmode: attrib.wmode,
				  flashvars: fv,
				  type: attrib.type,
				  pluginspage: attrib.pluginspage
				}});
			} else {
			  var obj = $E("object", {
				parentNode: env,
				attributes: {
				  id: attrib.id,
				  data: attrib.movie + '?' + fv,
				  width: attrib.width,
				  height: attrib.height,
				  type: attrib.type
				}});
			  var param = $E("param", {
				parentNode: obj,
				attributes: {
				  name: "movie",
				  value: attrib.movie + '?' + fv
				}});
		
			}
		  }
		}
		
		function getFlashSupport() {
		  var ver = [0,0];
		  if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
			var _d = navigator.plugins["Shockwave Flash"].description;
			if (typeof _d != "undefined") {
			  _d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
			  var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
			  var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			  ver = [_m, _r];
			}
		
		  } else if (window.ActiveXObject) {
			try {
			  var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			  var _d = _a.GetVariable("$version");// bugs in fp 6.21/6.23
			  if (typeof _d != "undefined") {
				_d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
				ver = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
			  }
			}
			catch(e) {
			}
		  }
		
		  return ver;
		}	
	
		return {
			create:createPlayer	
		};	
	}();
	


	function showVideoPopup(e, el, rel) {
		/* load the popup */
		Event.stop(e);
		var scripts = ['/js/build/common/Mbox.js'];
		var video = videos[rel];
		MNP.Require(scripts, function(){
			var elpop = $E("div", {className:"playerEnv"});
			Mbox.show(elpop, {className:"abox",closer:true,screen: {cancel: true,opacity: .35},s_class: "smoke", autoSize:1,
			  afterFinish: function() {
				FliqzPlayer.create(elpop, video.vid, video.caption);
			  } });									  
		});
	}
	
	
	function addVideo(videoObj){
		videos[videoObj.rel] = videoObj;
		MNP.Page.addLinkClickByRel(videoObj.rel, showVideoPopup);
	}
	
	

	return {
		add: addVideo
	}
	
}();

Manager.Video.add({
	vid: 'file=6e3ea04fbff24807aff47a99336db98d&',
	caption: '',
	rel:'whypaymore'
});
addLoadEvent(mgrInit);