/*
OctopusMT provide a range of streaming and media managment services including online conversion and managment of HD content. For more information please visit the website www.octopusmt.com

*/


//SWFobject Ver 1.5


if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

var divTagId = 1;

var OctopusMT = function(){

	var imgElement;
	var imgGUID;
	var thumbnailHolder = [];
	
   function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

var dragObj = new Object();
dragObj.zIndex = 9999;

function dragStart(event, id) {

  var el;
  var x, y;

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  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", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  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;
  }

  if((dragObj.elStartLeft + x - dragObj.cursorStartX) > 0 && (dragObj.elStartTop  + y - dragObj.cursorStartY) > 0){
	dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  	dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px"; 
  }
  
  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {


  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

	
    var DefaultSettings = {		
			Width: 540,
			Height: 465, 
			AutoPlay: true,
			VideoLocationName: 'OctopusMTPlayer',
			EmbedPlayer:true,
			DragPlayer:false,
			AllowResize: true,
			ThumbnailDiv: 'thumbnailTest',
			ThumbnailAlt: 'click to play',
			ThumbnailWidth: 90,
			ThumbnailLocation: 'http://niathumbnails.octopusmt.com/defaultthumbnail.ashx'	
    };
	var SysFunc = new Object();
         SysFunc.extendObject = function(destination, source) {
              
                  for (var property in source) {
                        destination[property] = source[property];
                  };
                  return destination;
            }
    if(typeof ConfigSettings !== 'undefined'){
	    DefaultSettings = SysFunc.extendObject(DefaultSettings, ConfigSettings);
	    console.log(DefaultSettings);
	}
    var get_element = document.all ?
        function (s_id) { return document.all[s_id] } :
        function (s_id) { return document.getElementById(s_id) };

	var carouselTarget;

    var Flash = {
        write : function (target){
			var playerLocation = "http://static.octopusmt.com/clients/n/nia/OctopusMTPlayer.swf";

          	var so = new SWFObject(playerLocation,"mediaPlayer", DefaultSettings.Width, DefaultSettings.Height, FlashVersion,"");	
			so.addParam("allowScriptAccess", "always");
			so.addParam("swLiveConnect", "true");
			so.addParam("allowFullScreen", "true");
			so.addParam("wmode","window");
			
			for(var prop in DefaultSettings)
			{
				so.addVariable("set"+prop, DefaultSettings[prop]);
			}
			
			if(!document.getElementById(target)){
			document.write(unescape("%3Cdiv%20id%3D%22OctopusMTPlayer%22%3E%3C/div%3E"));
			}
			so.write(target); 
        }
    };

	function hex2RGB ( hex ) {
		return '0x'+hex;
	}
	
function RenderPlayer(guid,autoPlay) {
         
		if(guid != null && guid !=='undefined') {
		    if(guid.indexOf("-") == -1){
					DefaultSettings.VideoFile=guid;
					delete DefaultSettings.AssetGUID;
				}else{
					DefaultSettings.AssetGUID=guid;
					delete DefaultSettings.VideoFile;
				}
		}else{
			delete DefaultSettings.VideoFile;
			delete DefaultSettings.AssetGUID;
		}
		
		var isFlash = false;
		
		if(typeof autoPlay === 'undefined'){
			DefaultSettings.AutoPlay = DefaultSettings.AutoPlay;
		} else {
			DefaultSettings.AutoPlay = autoPlay;
		}
		
		var version = deconcept.SWFObjectUtil.getPlayerVersion();
		var MajorMin = 9;
		var MinorMin = 0;
		var RevMin = 28;
        FlashVersion = MajorMin+"."+MinorMin+"."+RevMin;

			if(version['major'] == 10){
				Flash.write(DefaultSettings.VideoLocationName);
			}else{
		if(version['major']>=MajorMin){
			if(version['rev']>=RevMin){
				
				Flash.write(DefaultSettings.VideoLocationName);
			}else{
				  FlashErrorMessage();
			}
		}else{
				  FlashErrorMessage();
		}
			} 	        
    }
	
	function flashVersion()
	{
		return deconcept.SWFObjectUtil.getPlayerVersion();
	}
	
	
	function FlashErrorMessage(){
	
	document.getElementById(VideoLocationName).innerHTML = unescape("%3C%64%69%76%20%69%64%3D%22%46%6C%61%73%68%55%70%64%61%74%65%4D%65%73%73%61%67%65%22%20%73%74%79%6C%65%3D%22%66%6F%6E%74%2D%66%61%6D%69%6C%79%3A%41%72%69%61%6C%2C%20%48%65%6C%76%65%74%69%63%61%2C%20%73%61%6E%73%2D%73%65%72%69%66%3B%20%66%6F%6E%74%2D%73%69%7A%65%3A%31%32%70%78%22%3E%3C%74%61%62%6C%65%20%77%69%64%74%68%3D%22%32%36%30%22%20%62%6F%72%64%65%72%3D%22%30%22%20%63%65%6C%6C%70%61%64%64%69%6E%67%3D%22%30%22%20%63%65%6C%6C%73%70%61%63%69%6E%67%3D%22%35%22%20%62%67%63%6F%6C%6F%72%3D%22%23%46%46%46%46%46%46%22%20%69%64%3D%22%46%6C%61%73%68%4D%65%73%73%61%67%65%54%61%62%6C%65%22%3E%0A%20%20%3C%74%72%3E%0A%20%20%20%20%3C%74%64%3E%3C%64%69%76%20%61%6C%69%67%6E%3D%22%63%65%6E%74%65%72%22%3E%59%6F%75%20%6E%65%65%64%20%61%20%6E%65%77%65%72%20%76%65%72%73%69%6F%6E%20%6F%66%20%74%68%65%20%46%6C%61%73%68%20%70%6C%61%79%65%72%3C%62%72%20%2F%3E%20%0A%20%20%20%20%20%20%74%68%61%6E%20%79%6F%75%20%70%72%65%73%65%6E%74%6C%79%20%68%61%76%65%20%74%6F%20%76%69%65%77%20%74%68%69%73%20%63%6F%6E%74%65%6E%74%2E%3C%62%72%20%2F%3E%20%0A%20%20%20%20%20%20%54%6F%20%75%70%64%61%74%65%20%79%6F%75%72%20%46%6C%61%73%68%20%70%6C%61%79%65%72%20%63%6C%69%63%6B%20%3C%61%20%68%72%65%66%3D%22%68%74%74%70%3A%2F%2F%77%77%77%2E%61%64%6F%62%65%2E%63%6F%6D%2F%70%72%6F%64%75%63%74%73%2F%66%6C%61%73%68%70%6C%61%79%65%72%2F%22%20%74%61%72%67%65%74%3D%22%5F%62%6C%61%6E%6B%22%20%73%74%79%6C%65%3D%22%66%6F%6E%74%2D%66%61%6D%69%6C%79%3A%41%72%69%61%6C%2C%20%48%65%6C%76%65%74%69%63%61%2C%20%73%61%6E%73%2D%73%65%72%69%66%3B%20%66%6F%6E%74%2D%73%69%7A%65%3A%31%32%70%78%3B%20%66%6F%6E%74%2D%77%65%69%67%68%74%3A%62%6F%6C%64%3B%20%74%65%78%74%2D%64%65%63%6F%72%61%74%69%6F%6E%3A%6E%6F%6E%65%3B%20%63%6F%6C%6F%72%3A%23%30%30%30%30%30%30%22%3E%68%65%72%65%3C%2F%61%3E%2E%3C%2F%64%69%76%3E%3C%2F%74%64%3E%0A%20%20%3C%2F%74%72%3E%0A%3C%2F%74%61%62%6C%65%3E%0A%3C%2F%64%69%76%3E");
	
	}
	
    
	function InsertDragPlayerCode(){

			if(document.getElementById("Octopus-Popup-Player") == null || document.getElementById("Octopus-Popup-Player") === undefined){
				var container = document.createElement('div');
				var header = document.createElement('div');
				var videoContainer = document.createElement('div');
				var headerInfo = document.createElement('span');
				var headerClose = document.createElement('a');
				
				container.setAttribute('id','Octopus-Popup-Player');
				header.setAttribute('id','Octopus-Popup-Player-header');
				videoContainer.setAttribute('id','OctopusMTPlayer');
				
				container.style.position = "absolute";
				container.style.zIndex = "99999";
				container.style.backgroundColor = "#333333";
				container.style.display = "none";
				
				header.style.cursor = "pointer";
				header.style.fontSize = "12px";
				header.style.fontFamily = "Verdana,Arial,Helvetica,sans-serif";
				header.style.color = "#FFFFFF";
				header.style.display = "none";
				header.style.height = "20px";
				header.onmousedown = function(e) { OctopusMT.dragStart(e, 'Octopus-Popup-Player')};
				
				headerInfo.style.cssFloat = "left";
				headerInfo.style.styleFloat = "left";
				headerInfo.style.paddingTop = "3px";
				headerInfo.style.paddingLeft = "3px";
				
				headerInfo.appendChild(document.createTextNode("Click to drag video"));
				
				headerClose.style.fontWeight = "bold";
				headerClose.style.cssFloat = "right";
				headerClose.style.styleFloat = "right";
				headerClose.style.paddingTop = "3px";
				headerClose.style.paddingRight = "3px";
				headerClose.style.color = "#FFFFFF";
				headerClose.onclick = function() {OctopusMT.CloseFlashWindow()};
				
				headerClose.appendChild(document.createTextNode("Close"));
				
				//setInterval(function(){ document.getElementById('mediaPlayer').style.display = "block"},100);
				
				header.appendChild(headerInfo);
				header.appendChild(headerClose);
				
				container.appendChild(header);
				container.appendChild(videoContainer);
				//document.body.appendChild(container);
				if(arguments[0] === undefined){
					window.onload+= function() { document.body.appendChild(container) };
				}else{
					document.body.appendChild(container);
				}
			}
	}
   	
	function init() {
		if(typeof this.ConfigSettings !=='undefined'){
			DefaultSettings = SysFunc.extendObject(DefaultSettings, this.ConfigSettings);  
		}	
		
		if(DefaultSettings.DragPlayer==true){
			//alert('insert drag code');
			InsertDragPlayerCode();
			//OpenFlashWindow(AssetGUID);
			
		}else if(DefaultSettings.EmbedPlayer==true){
			RenderPlayer(DefaultSettings.AssetGUID,DefaultSettings.AutoPlay);
			
		}
		
	}
    
	function ResizeVideo(newHeight, videoWidth, videoHeight)
    {   
			VideoWidth = videoWidth;
        		VideoHeight = videoHeight;
			PreviousHeight = newHeight;
			if(browser.isIE){

			}

			//document.getElementById('OctopusMTPlayer').style.width = OctopusMT.ConfigSettings.Width + 'px';

			//document.getElementById('OctopusMTPlayer').style.height = newHeight + 'px';

		
			//document.getElementById('boxB').style.width = videoWidth + 'px';
			document.getElementById('boxB').style.height = newHeight + 'px';
			document.getElementById('mediaPlayer').height =  newHeight;
			//document.getElementById('mediaPlayer').setAttribute('Height',newHeight);
    }

	
function findPos(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
               curleft = obj.offsetLeft
               curtop = obj.offsetTop
               while (obj = obj.offsetParent) {
                       curleft += obj.offsetLeft
                       curtop += obj.offsetTop
               }
        }
        return [curleft,curtop];
}

	function getHeightAndWidth(element)
	{
		var heightWidth;
		
		if(element.style.width != "" && element.style.width !== undefined) heightWidth = {height:parseInt(element.style.height),width:parseInt(element.style.width)};
		else if(element.width != "" && element.width !== undefined) heightWidth = {height:parseInt(element.height),width:parseInt(element.width)};
		else if(element.offsetWidth != "" && element.offsetWidth !== undefined) heightWidth = {height:parseInt(element.offsetHeight),width:parseInt(element.offsetWidth)};
		else if(element.style.pixelWidth != "" && element.style.pixelWidth !== undefined) heightWidth = {height:parseInt(element.style.pixelHeight),width:parseInt(element.style.pixelWidth)};

		return heightWidth;
	}
	
	function OpenFlashWindow(){
				
		//document.body.write("<div id=\"wooo\"></div>");
		//alert("open me: "+document.getElementById('boxB'));
		InsertDragPlayerCode(true);
		if(typeof arguments[1] === "string") arguments[1] = document.getElementById(arguments[1]);
		var hw = getHeightAndWidth(arguments[1]);
		
		var pos = findPos(arguments[1]);
		DefaultSettings.VideoLocationName = 'OctopusMTPlayer';
		var width = (arguments[1].href) ? arguments[1].offsetWidth : hw.width; 
		var height = (arguments[1].href) ? arguments[1].offsetHeight : hw.height; 	

		//alert(pos[1]+" , "+DefaultSettings.Height+" , "+height);
		
		var topPos = pos[1] - ((DefaultSettings.Height - height)/2);
		var leftPos = pos[0] - ((DefaultSettings.Width - width)/2);
		
		//alert(topPos+","+leftPos);

		if(topPos < 0) topPos = 10;
		if(leftPos < 0) leftPos = 10;


		//alert(arguments[2]);
		if(arguments[2] !== undefined){
			if(typeof arguments[2] === 'string'){
				DefaultSettings.RelatedGUID = arguments[2];
			}
				
		}
		leftPos = (screen.width / 2) - (DefaultSettings.Width / 2);	

		
		document.getElementById('Octopus-Popup-Player').style.top = topPos + 'px';
		document.getElementById('Octopus-Popup-Player').style.left = leftPos + 'px';
		document.getElementById('Octopus-Popup-Player').style.width = DefaultSettings.Width + 'px';
		document.getElementById('Octopus-Popup-Player').style.height = DefaultSettings.Height + 'px';
		document.getElementById('Octopus-Popup-Player-header').style.width = DefaultSettings.Width + 'px';
		document.getElementById('Octopus-Popup-Player').style.display = 'block';
		document.getElementById('Octopus-Popup-Player-header').style.display = 'block';
		document.getElementById('OctopusMTPlayer').style.display = 'block';
		DefaultSettings.VideoFile = arguments[0];
		
		//alert(document.getElementById('OctopusMTPlayer').style.display);
		
		var scrollProp = window.scrollY;
		//if(arguments[1].href) setTimeout(function (){window.scroll(window.scrollX,scrollProp)},100);
		RenderPlayer(arguments[0],true);

	}	

	function CloseFlashWindow(){
		document.getElementById('OctopusMTPlayer').innerHTML="";
		document.getElementById('Octopus-Popup-Player').style.display = 'none';
		document.getElementById('Octopus-Popup-Player-header').style.display = 'none';
		document.getElementById('OctopusMTPlayer').style.display = 'none';
	}
	
	
	function getScreenSize()
    {
    	return screen.width+","+screen.height;
    }
	
	function generateThumbnail()
	{
		InsertDragPlayerCode();
		
		if(arguments.length > 0){
			var guid = (arguments[0] === undefined) ? DefaultSettings.VideoFile : arguments[0];
			var altText = (arguments[1] === undefined) ? DefaultSettings.ThumbnailAlt : arguments[1];
			var width = (arguments[2] === undefined) ? DefaultSettings.ThumbnailWidth : arguments[2];
			
			var outputElement = DefaultSettings.VideoLocationName + divTagId;
			divTagId++;
			document.write(unescape("%3Cdiv%20id%3D%22"+outputElement+"%22%3E%3C/div%3E"));
			var elementContainer = document.getElementById(outputElement);
			var element = document.createElement('img');
			element.setAttribute('src',getThumbnail(guid,width));
			element.setAttribute('alt',altText);
			element.style.cursor = 'pointer';
			addListener(element,'click',popupPlayerEvent,false);
			//addListener(element,'mouseover',playMouseOver,false);
			//addListener(element,'mouseout',playMouseOut,false);
			elementContainer.appendChild(element);
			
			var tempHolder = new ThumbnailElement();
			tempHolder.setGuid(guid);
			tempHolder.setElement(element);
			tempHolder.setPosition((arguments[4] === undefined) ? false : true);
			thumbnailHolder.push(tempHolder);
			
			DefaultSettings.RelatedGUID = arguments[3];
			
			/*var overlayImage = document.createElement('img');
			overlayImage.setAttribute('src','testPlay.png');
			elementContainer.appendChild(overlayImage);
			var position = findPos(element);
			overlayImage.style.position = 'absolute';
			overlayImage.style.left = (position[0] + (element.width/2)-(overlayImage.width/2)) +'px';
			overlayImage.style.top = (position[1] + (element.height/2)-(overlayImage.height/2)) +'px';
			overlayImage.style.cursor = 'pointer';
			addListener(overlayImage,'click',popupPlayerEvent,false);
			addListener(overlayImage,'mouseover',playMouseOver,false);
			addListener(overlayImage,'mouseout',playMouseOut,false);
			changeOpac(80,overlayImage);*/
		}else{
			alert("You haven't entered any properties into the thumbnail function,\nplease enter at least a GUID, i.e: \nOctopusMT.generateThumbnail('0ac86b05-c396-47bc-a4fc-a4aac3d85378').");
		}
	}
	
	function ThumbnailElement()
	{
		var thumbnailElement;
		var thumbnailGUID;
		var positionSelf;
		
		this.setGuid = setGuid;
		this.getGuid = getGuid;
		this.setElement = setElement;
		this.getElement = getElement;
		this.setPosition = setPosition;
		this.getPosition = getPosition;
		
		function setGuid(guidIn)
		{
			this.thumbnailGUID = guidIn;
		}
		
		function getGuid()
		{
			return this.thumbnailGUID;
		}
		
		function setElement(elementIn)
		{
			this.thumbnailElement  = elementIn;
		}
		
		function getElement()
		{
			return this.thumbnailElement;	
		}

		function setPosition(positionIn)
		{
			this.positionSelf = positionIn;	
		}

		function getPosition()
		{
			return this.positionSelf;
		}
	}
	
	function playMouseOver(e)
	{
		//alert("mouse over");
		var eventType;
		if(e.target === undefined){
			//I.E
			eventType = event.srcElement;
		}else{
			//Firefox
			eventType = e.target;
		}
		//opacity(eventType, 100, 80, 200);
		changeOpac(100,eventType);
	}
	
	function playMouseOut(e)
	{
		var eventType;
		if(e.target === undefined){
			//I.E
			eventType = event.srcElement;
		}else{
			//Firefox
			eventType = e.target;
		}
		//opacity(eventType, 80, 100, 200);
		changeOpac(80,eventType);
	}
	
	function getThumbnail(guid,size)
	{
		var serviceLocation = DefaultSettings.ThumbnailLocation;
		serviceLocation+='?assetguid='+guid;
		serviceLocation+='&width='+size;
		return serviceLocation;
	}
	
	function popupPlayerEvent(e)
	{
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		
		var guid;
		var element;
		var pos = null;
		
		for(var i = 0;i<thumbnailHolder.length;i++)
		{
			if(thumbnailHolder[i].getElement() == targ){
				element = thumbnailHolder[i].getElement();
				guid = thumbnailHolder[i].getGuid();
				pos = thumbnailHolder[i].getPosition();

			}
		}
		
		if(pos == true && pos != null) OpenFlashWindow(guid,element,pos);
		else OpenFlashWindow(guid,element);	
	}
	
	function addListener(element, type, expression, bubbling)
	{
		bubbling = bubbling || false;
		if(window.addEventListener) { // Standard
		element.addEventListener(type, expression, bubbling);
		return true;

		}else if(window.attachEvent){ // IE
			element.attachEvent('on' + type, expression);
			return true;
		}else return false;
	}
	
	function changeOpac(opacity,id)
	{
		//alert(id);
		var object = id.style; 
   		object.opacity = (opacity / 100); 
    	object.MozOpacity = (opacity / 100); 
    	object.KhtmlOpacity = (opacity / 100);
    	object.filter = "alpha(opacity=" + opacity + ")";
	}
	
	function opacity(id, opacStart, opacEnd, millisec) 
	{ 
	
	//speed for each frame 
	var speed = Math.round(millisec / 100); 
	var timer = 0; 
	
	if(opacStart > opacEnd)
	{ 
		for(i = opacStart; i >= opacEnd; i--) 
		{ 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		}
	} 
	
	else if(opacStart < opacEnd) 
	{ 
		for(i = opacStart; i <= opacEnd; i++) 
		{ 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		} 
	}
	} 
	
    return {
	    init : init,
	    RenderPlayer : RenderPlayer,
		ResizeVideo : ResizeVideo,
		OpenFlashWindow : OpenFlashWindow,
		CloseFlashWindow : CloseFlashWindow,
		getScreenSize : getScreenSize,
		dragStart: dragStart,
		changeOpac: changeOpac,
		generateThumbnail: generateThumbnail,
		getHeightAndWidth : getHeightAndWidth,
		flashVersion : flashVersion
	}   
	
	
}();

function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName("head").item(0);
    // Generate a unique script tag id
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}

// Static script ID counter
JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement("script");
    
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl);
    this.scriptObj.setAttribute("id", this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
}

/*OctopusMT.init();*/