var appId , emailId, obj;
var strHost, strBaseUrl;
var winModalWindow, strUrlExtension;
var strLcid;


function OnLoad()
{
	if (appId != "")
	{
		CheckP4Launch(appId, "");
	}
}

function CheckP4Launch(appId, emailId)
{
	CheckMessenger();
	LaunchApp(appId, emailId);
}

function TryItNow(appId)
{
	// Test #1: Launch with no email and no app id causing buddy picker to pop up and launch site to drop down
	CheckMessenger();
	LaunchApp(strLcid + appId, "");
}

function LaunchApp(appId, emailId)
{
	if (obj != null)
	{
		obj.LaunchApp(appId, emailId);
	}
}
function CheckMessenger()
{
	eval ('try {obj = new ActiveXObject("MSNMessenger.P4QuickLaunch"); } catch (e) {obj = null;}');
	var strErrorPage = "http://" + strHost + strBaseUrl + "/Resource/Error.aspx"
	
	if (fBrowser == false)
	{
		ShowWindow(strErrorPage + strUrlExtension + "err=1", 410, 130);
		
	}	
	else if (obj == null)
	{
		ShowWindow(strErrorPage + strUrlExtension + "err=2", 410, 225);
	}
	
}


 
function IgnoreEvents(e)
{
  return false
}
 
function ShowWindow(strError, width, height)
{
  if (window.showModalDialog)
  {
   
    window.showModalDialog(strError,null,
    "dialogWidth="+width+"px;dialogHeight="+height+"px;help=no;dialogLeft=160")
  }
  else
  {

    var ah = screen.availHeight;

    var y = (ah - height) / 2;

    window.top.captureEvents (Event.CLICK|Event.FOCUS)
    window.top.onfocus=HandleFocus 
    winModalWindow = window.open (strError,"ModalChild",
       "dependent=yes,width="+width+",height="+height+",top="+y+",left=160,screenX=160,screenY="+y)
    winModalWindow.focus()
  }
}

 
function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
    }
  }
  return false
}
