﻿// JScript File

function fnLogOut()
{
    __doPostBack('ctl00$btnSignOut','');
}

function EndSession()
{ 
   // Get the real ASPX page name
   var sPath = window.location.pathname;
   var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
   if(sPage == '') sPage = "Default.aspx";

   // They're in a  popup window, don't kill the session here!
   if(window.opener != null) return;

 

   // Only want to run the endsession for IE, no way to tell currently if it's not IE and
   // the window is closing
   if(window.event != null) {
     var abssize = document.body.offsetWidth-30; 
     if (window.event.clientY < 0 && event.clientX >= abssize)  {
           fnLogOut();
     }
   }
}



function unloadEvent(eventArg)
{
    var yPos;
    //if('clientY' in eventArg){yPos=eventArg.clientY}
    //else if('clientY' in window.event) {yPos=window.event.clientY}
    yPos = eventArg.clientY;

    alert('in unload Event ' + yPos);
	//if(window.screenLeft < 10004)
	//if(event.clientY < 0)
	if(yPos < 0)
	{
  		//this is refresh
  		//alert('hello if ' + yPos);
  		//fnLogOut();
  		window.event.returnValue = 'Please sign out before leaving the page';
  		return true;
	}
	else
	{
	    alert('hello else');
	}
}		 

            
function sendChatMessage(eventArg, buttonToClick){
    var k;
    if ("which" in eventArg){k=eventArg.which}
    else if("keyCode" in eventArg){k=eventArg.keyCode}
    else if("keyCode" in window.event){k=window.event.keyCode }
    else if ("which" in window.event){k=eventArg.which}
    else{return true}

    if (k == 13)
    {
        __doPostBack(buttonToClick,'');
    }
}



