function asset()
{
	this.xreqs = new reqs();
	
	this.connectPublish = function()
	{
		xfb.connect(xasset.publish);
		window.scroll(0,0);
	}
	
	this.publish = function()
	{
		xunity.forcedHide = 1;
		xunity.hide();
		
		gE('asset-publish').style.display = "none";
		gE('asset-connect').style.display = "none";
		
		xasset.update();
		
		xasset.xreqs.get("?cmd=fb.publishAsset", null)
		
		gE('asset-content').innerHTML = "<div id=\"asset-message\">Facebook upload complete. Please approve the image in your Facebook account.</div>";
		window.scroll(0,0);
	}
	
	this.update = function()
	{
		var o = gE('overlay');
		if(o)
		{
			//do the overlay
			o.style.left = 0 + "px";
			o.style.top = 0 + "px";
			o.style.width = "100%";
			o.style.height = getDocHeight() + "px";
			o.style.display = "block";
		}
		
		var c = gE('asset');
		if(c)
		{
			//do the overlay
			c.style.left = 0 + "px";
			c.style.top = 0 + "px";
			c.style.width = "100%";
			c.style.height = getDocHeight() + "px";
			c.style.display = "block";
		}
		
		/*
		var ac = gE('asset-content');
		if(ac)
			ac.style.marginTop = parseInt(getDocHeight() / 2) - parseInt(ac.offsetHeight / 2) + "px";
		*/
	}
	
	this.show = function()
	{
		xunity.forcedHide = 1;
		xunity.hide();
    
		window.onresize = xasset.update;
		
		var ac = gE('asset-content');
		ac.innerHTML = '<a target="_new" href="poster.html"><img src="images/asset/poster.jpg" alt="Movie Poster" /></a>';
		
		this.update();
		
		if(xfb.getConnected())
			gE('asset-publish').style.display = "block";
		else
			gE('asset-connect').style.display = "block";
	}
	
	this.hide = function()
	{
		window.onresize = null;
		
		var o = gE('overlay');
		if(o)
			o.style.display = "none";
			
		var c = gE('asset');
		if(c)
			c.style.display = "none";
		
		gE('asset-publish').style.display = "none";
		gE('asset-connect').style.display = "none";
		
		xunity.forcedHide = 0;
	}

  this.clickHide = function()
	{
    var m = gE("asset-border");

		if(m.style.display != "none" && (m.offsetTop >= mousey || (parseInt(m.offsetTop + m.clientHeight) <= mousey)) || (m.offsetLeft >= mousex || (parseInt(m.offsetLeft + m.clientWidth) <= mousex)))
			xasset.hide();
  }
}

var xasset = new asset();

function asset2()
{
	this.xreqs = new reqs();
	
	this.connectPublish = function()
	{
		xfb.connect(xasset2.publish);
		window.scroll(0,0);
	}
	
	this.publish = function()
	{
		xunity.forcedHide = 1;
		xunity.hide();
		
		gE('asset-publish').style.display = "none";
		gE('asset-connect').style.display = "none";
		
		xasset2.update();
		
		xasset2.xreqs.get("?cmd=fb.publishAsset2", null)
		
		gE('asset-content').innerHTML = "<div id=\"asset-message\">Facebook upload complete. Please approve the image in your Facebook account.</div>";
		window.scroll(0,0);
	}
	
	this.update = function()
	{
		var o = gE('overlay');
		if(o)
		{
			//do the overlay
			o.style.left = 0 + "px";
			o.style.top = 0 + "px";
			o.style.width = "100%";
			o.style.height = getDocHeight() + "px";
			o.style.display = "block";
		}
		
		var c = gE('asset');
		if(c)
		{
			//do the overlay
			c.style.left = 0 + "px";
			c.style.top = 0 + "px";
			c.style.width = "100%";
			c.style.height = getDocHeight() + "px";
			c.style.display = "block";
		}
		
		/*
		var ac = gE('asset-content');
		if(ac)
			ac.style.marginTop = parseInt(getDocHeight() / 2) - parseInt(ac.offsetHeight / 2) + "px";
		*/
	}
	
	this.show = function()
	{
		xunity.forcedHide = 1;
		xunity.hide();
    
		window.onresize = xasset2.update;
		
		var ac = gE('asset-content');
		ac.innerHTML = '<a target="_new" href="poster2.html"><img src="images/asset/poster2.jpg" alt="Movie Poster 2" /></a>';
		
		this.update();
		
		if(xfb.getConnected())
			gE('asset-publish').style.display = "block";
		else
			gE('asset-connect').style.display = "block";
	}
	
	this.hide = function()
	{
		window.onresize = null;
		
		var o = gE('overlay');
		if(o)
			o.style.display = "none";
			
		var c = gE('asset');
		if(c)
			c.style.display = "none";
		
		gE('asset-publish').style.display = "none";
		gE('asset-connect').style.display = "none";
		
		xunity.forcedHide = 0;
	}

  this.clickHide = function()
	{
    var m = gE("asset-border");

		if(m.style.display != "none" && (m.offsetTop >= mousey || (parseInt(m.offsetTop + m.clientHeight) <= mousey)) || (m.offsetLeft >= mousex || (parseInt(m.offsetLeft + m.clientWidth) <= mousex)))
			xasset2.hide();
  }
}

var xasset2 = new asset2();
