appLK = Object.extend (new HPEItemApp, {

	InitApp : function() {
		var html = "<form id='AppLinkTools' style='display:none' class='nomargin'><table width='100%' height='27' border='0' cellspacing='0' cellpadding='0'><tr>\
			<td align='left'>&nbsp;&nbsp;<input type='button' value='Close & Return' id='AppITClose' onClick='HPEBackApp()' />\
			</td></tr></table></form>";

		var elt = $("tabbarmiddle");
		if(!elt) { hpe.error("Failed to find tabbarmiddle"); return }
		new Insertion.Bottom(elt, html);

		this.body = "<div id='content' style='margin-left:0px'><div id='contentbreakprotect'>\
			<div id='LKContent' style='padding:5px' align='center'></div>\
			</div></div>";
	},

	SuspendApp : function () {
		var elt = $("AppLinkTools"); elt.hide();
	},

	ResumeApp : function () {
		var elt = $("AppLinkTools"); elt.show();
		elt = $("MainBody"); if(elt) elt.innerHTML = this.body;
		this.ShowLink();
	},

	ShowBackMessage : function() {
		var elt = $("ApplicationBackButton");
		if(!elt) return;
		elt.innerHTML = "<a class=\"OB\" href=\"#\" onClick=\"HPEBackApp()\">[back to item details]</a>";
		Element.show(elt);
	},

	Reload : function() {
		this.LoadItemInfo();
	},

	ShowLink : function () {
		var useif = hpe.isffwin && Ajax;

		if(useif) {
			var elt = $("LKContent");
			var hh = $("header").offsetHeight;
			var fh = $("ftr").offsetHeight;
			var ch = hpe.screen.visHeight() - hh - fh - 10;
			var cw = hpe.screen.visWidth() - 1;

			if(ch > 100)
			{
				elt.style.maxHeight = ch + "px";
				elt.style.height = ch + "px";
				elt.style.width = cw + "px";
				elt.innerHTML = "<iframe width='" + cw + "' height='" + ch + "' src='" + this.link + "' style='border:0'></iframe>";
				elt.show();
			} else {
				elt.hide();
				alert("Window is too small to show content");
			}
		} else {
			new Ajax.Updater("LKContent", this.link, {method:'get'});
		}
	},

	LoadLink : function(link) {
		this.link = link;
		HPEResumeApp(this);
	}

});

