﻿function gel(id)
{
  return document.getElementById(id);
}
function sayHello(isbackDiv,receiveUserID)
{
  if(gel('floatDiv')==null)
  {
    var floatDiv = document.createElement('div');
    floatDiv.id = "floatDiv";
    floatDiv.style.position = "absolute";
    floatDiv.style.width = 800 + "px";
    floatDiv.style.height = 400 + "px";
    floatDiv.style.left =(document.documentElement.clientWidth/2 + document.documentElement.scrollLeft - 400)+"px";
    floatDiv.style.top =(document.documentElement.clientHeight/2 + document.documentElement.scrollTop-150 )+"px";
    floatDiv.style.zIndex = 1001;
    var sendHelloText=null;
    var scrollTop=document.documentElement.scrollTop;
   
    if(receiveUserID!=null)
    {
          sendHelloText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"../User/SayHello.aspx?userID="+receiveUserID+"&scrollTop="+scrollTop+"\" width=\"100%\" height=\"400\"></iframe>";
    }  
    floatDiv.innerHTML = sendHelloText;
    document.body.appendChild(floatDiv);
  }
  else
  {
    gel('floatDiv').style.display = "block";
  }
  if(gel('backDiv')==null && isbackDiv ==true)
  {
    var backDiv = document.createElement('div');
    backDiv.id = "backDiv";
    backDiv.style.backgroundColor = "Black";
    backDiv.style.filter = "alpha(opacity=70)";
    backDiv.style.MozOpacity = "0.70";
    backDiv.style.position = "absolute";
    backDiv.style.left = "0px";
    backDiv.style.top = "0px";
    backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) +"px";
    backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight)+"px";
    document.body.appendChild(backDiv);
    gel('backDiv').style.zIndex = 1000;
  }
  else if(isbackDiv ==true)
  {
    gel('backDiv').style.display = "block";
  }
}
function moveDiv(event, elem)
{
  gel('floatDiv').style.filter = "alpha(opacity=50)";
  var oObj = gel(elem);
  oObj.onmousemove = mousemove;
  oObj.onmouseup = mouseup;
  oObj.setCapture ? oObj.setCapture() : function()
 {

 };
oEvent = window.event ? window.event : event;
var dragData =
{
  x : oEvent.clientX, y : oEvent.clientY
};
var backData =
{
  x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)
};
function mousemove()
{
  var oEvent = window.event ? window.event : event;
  var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
  var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
  oObj.style.left = iLeft;
  oObj.style.top = iTop;
  dragData =
  {
    x: oEvent.clientX, y: oEvent.clientY
  };
}
function mouseup()
{
  var oEvent = window.event ? window.event : event;
  oObj.onmousemove = null;
  oObj.onmouseup = null;
  gel('floatDiv').style.filter = "";
  if(oEvent.clientX < 1 || oEvent.clientY < 1)
  {
    oObj.style.left = backData.y;
    oObj.style.top = backData.x;
  }
oObj.releaseCapture ? oObj.releaseCapture() : function()
{
};
}
}
function CloseFloatDiv()
{   
  if(gel('floatDiv'))
  {
    gel('floatDiv').style.display = "none";
  } 
  if(gel('backDiv'))
  {
    gel('backDiv').style.display = "none";
  }
   window.location.reload();

}
function CloseFloatDivWithoutFresh()
{
  if(gel('floatDiv'))
  {
    gel('floatDiv').style.display = "none";
  } 
  if(gel('backDiv'))
  {
    gel('backDiv').style.display = "none";
  }
}
