var winModalWindow;

function IgnoreEvents(e)
{
  return false
}
 
function displayLogin(blnValue,intToManyTries)
{
	if (blnValue != '1')
		{
  if (window.showModalDialog) // is it IE?
  {
 	if (blnValue == '2' || blnValue == '32')
	{
		var resp = showModalDialog('wfLoginPopup.aspx?B=IE&BV=' + blnValue + '&Error=1&Failed=' + intToManyTries.toString(),'Login','dialogWidth:330px;dialogHeight:250px;toolbar=0;scrollbars=1,status=0,resizable=0,fullscreen=0;');
	}
	else
	{
		var resp = showModalDialog('wfLoginPopup.aspx?B=IE&BV=' + blnValue,'Login','dialogWidth:330px;dialogHeight:250px;toolbar=0;scrollbars=1,status=0,resizable=0,fullscreen=0;');
	}

	if (resp == null || resp == 'cancel' || resp == '')
	{
		runPostBack = false;
		return false;
	}
	else
	{
		document.getElementById("UCTopNav1_txtLPUsername").value = resp.split('+')[0];
		document.getElementById("UCTopNav1_txtLPPassword").value = resp.split('+')[1];
		document.getElementById("UCTopNav1_txtLPHash").value = location.hash;
		__doPostBack("CheckLogin",blnValue);
	}		
  }
  else
  {
    //window.top.captureEvents (Event.CLICK|Event.FOCUS|Event.MOUSEDOWN|Event.MOUSEUP);
    window.top.captureEvents (Event.CLICK|Event.MOUSEMOVE|Event.CLICK|Event.DBLCLICK|Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEOUT|Event.MOUSEOVER|Event.KEYDOWN|Event.KEYUP|Event.KEYPRESS|Event.FOCUS|Event.BLUR);
    window.top.onclick=IgnoreEvents;
 window.top.ondblclick = IgnoreEvents;
 window.top.onmousemove = IgnoreEvents;
 window.top.onmouseover = IgnoreEvents;
 window.top.onmouseout = IgnoreEvents;
 window.top.onmousedown = IgnoreEvents; 
 window.top.onmouseup = IgnoreEvents;
 window.top.onkeydown = IgnoreEvents;
 window.top.onkeypress = IgnoreEvents;
 window.top.onkeyup = IgnoreEvents;
 window.top.onblur = IgnoreEvents;

    window.top.onfocus=HandleFocus;

			if (blnValue == "2" || blnValue == "32")
			{
				winModalWindow = window.open ("wfLoginPopup.aspx?B=N&BV=" + blnValue + "&Error=1&Failed=" + intToManyTries.toString(),"Login","dependent=yes,width=330,height=250")
			}
			else
			{
				winModalWindow = window.open ("wfLoginPopup.aspx?B=N&BV=" + blnValue,"Login","dependent=yes,width=330,height=250");
			}
    
    winModalWindow.focus();
  }
}

else
{
			window.location.replace("index.aspx?Out=1");
}
}
 
 
function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus();
    }
    else
    {
      //window.top.releaseEvents (Event.CLICK|Event.FOCUS|Event.MOUSEDOWN|Event.MOUSEUP);
      window.top.releaseEvents (Event.CLICK|Event.MOUSEMOVE|Event.CLICK|Event.DBLCLICK|Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEOUT|Event.MOUSEOVER|Event.KEYDOWN|Event.KEYUP|Event.KEYPRESS|Event.FOCUS|Event.BLUR);
      window.top.onclick = "";
 window.top.ondblclick = "";
 window.top.onmousemove = "";
 window.top.onmouseover = "";
 window.top.onmouseout = "";
 window.top.onmousedown = ""; 
 window.top.onmouseup = "";
 window.top.onkeydown = "";
 window.top.onkeypress = "";
 window.top.onkeyup = "";
 window.top.onblur = "";
    }
  }
  return false
}	
