﻿var layerToRePos;
function SetFocusOnControl(id)
{
    setTimeout("FocusOnControl('"+ id + "')",500);
}

function FocusOnControl(controlId)
{
    eval("document.getElementById('"+controlId+"').focus()");
}

function EmailConfirmationPopUp(id)
{  
    ModalLayer();
	var div = document.createElement('div');
	div.innerHTML = document.getElementById(id).innerHTML;
	div.style.cssText= document.getElementById(id).style.cssText;
	div.id = 'confirmPop1';
	div.style.visibility = 'visible';
	div.style.display = 'block';
	div.className = 'modalPopup';
	document.forms[0].appendChild(div);
	
	layerToRePos='confirmPop1';
    var appVer = navigator.appVersion;
    if(appVer.indexOf('MSIE 6') <= -1)
        div.style.position = 'fixed';
    else 
        div.style.position = 'absolute';
    resetLayerPos();
    window.onresize= resetLayerPos;
    if(appVer.indexOf('MSIE 6')>-1)
    window.onscroll= resetLayerPos;   
}

function InputSearchNameConfirmationPopUp(id)
{   
    ModalLayer();
	var div = document.createElement('div');
	div.innerHTML = document.getElementById(id).innerHTML;
	div.style.cssText= document.getElementById(id).style.cssText;
	div.id = 'confirmPop1';
	div.style.visibility = 'visible';
	div.style.display = 'block';
	div.className = 'modalPopup';
	div.style.position = "absolute";                          
	//Set the position of the confirmation div
	var appVer = navigator.appVersion;

	document.forms[0].appendChild(div);	
	
	 layerToRePos='confirmPop1';
    var appVer = navigator.appVersion;
    if(appVer.indexOf('MSIE 6') <= -1)
        div.style.position = 'fixed';
    else 
        div.style.position = 'absolute';
    resetLayerPos();
    window.onresize= resetLayerPos;
    if(appVer.indexOf('MSIE 6')>-1)
    window.onscroll= resetLayerPos;   
}

function CallMeNowConfirmationPopUp(id)
{  
    ModalLayer();
	var div = document.createElement('div');
	div.innerHTML = document.getElementById(id).innerHTML;
	div.style.cssText= document.getElementById(id).style.cssText;
	div.id = 'confirmPop1';
	div.style.visibility = 'visible';
	div.style.display = 'block';
	div.className = 'modalPopup';
	document.forms[0].appendChild(div);	
	
	layerToRePos='confirmPop1';
    var appVer = navigator.appVersion;
    if(appVer.indexOf('MSIE 6') <= -1)
        div.style.position = 'fixed';
    else 
        div.style.position = 'absolute';
    resetLayerPos();
    window.onresize= resetLayerPos;
    if(appVer.indexOf('MSIE 6')>-1)
    window.onscroll= resetLayerPos;   
}

function showPopUpOWS(id)
{
    ModalLayer();
	var div = document.createElement('div');
	div.innerHTML = document.getElementById(id).innerHTML;
	div.style.cssText= document.getElementById(id).style.cssText;
	div.id = 'confirmPop1';
	div.style.visibility = 'visible';
	div.style.display = 'block';
	if(id != "virtualTourDiv")// VT div from xsl
	    div.className = 'modalPopupOWS';
	document.forms[0].appendChild(div);
	layerToRePos='confirmPop1';
    var appVer = navigator.appVersion;
    if(appVer.indexOf('MSIE 6') <= -1)
        div.style.position = 'fixed';
    else 
        div.style.position = 'absolute';
    resetLayerPos();
    window.onresize= resetLayerPos;
   
    if(appVer.indexOf('MSIE 6')>-1)
    window.onscroll= resetLayerPos;
}

function closePop()
{   popupcall='';
    var d = document.getElementById('confirmPop');
    if(d)
        document.forms[0].removeChild(d);
    var d1 = document.getElementById('confirmPop1');
    if(d1)
        document.forms[0].removeChild(d1);    
    if(navigator.appVersion.indexOf('MSIE 6')>-1)ShowDropDowns(1);
}	

function ShowDropDowns(flag)
{
    var ary = document.getElementsByTagName('SELECT');
    for (var i = 0; i < ary.length; i++)
    {
       if(flag == 0)
          ary[i].style.visibility = 'hidden';
       else
          ary[i].style.visibility = 'visible';   
    }
 }

function VTPopUp()
{
    var ary = document.getElementsByTagName('DIV');
    for (var i = 0; i < ary.length; i++)
    {
        if(ary[i].id.indexOf('divVirtualTour') >= 0)
        {
            ModalLayer();
            var childDiv = document.createElement('div');
            childDiv.innerHTML=ary[i].innerHTML;
            childDiv.style.cssText= ary[i].style.cssText;
            childDiv.id = 'confirmPop1';
            childDiv.style.visibility = 'visible';
            childDiv.style.display = 'block';
            document.forms[0].appendChild(childDiv);
            layerToRePos='confirmPop1';
            var appVer = navigator.appVersion;
            if(appVer.indexOf('MSIE 6') <= -1)
                childDiv.style.position = 'fixed';
            else 
                childDiv.style.position = 'absolute';
            resetLayerPos();
            window.onresize= resetLayerPos;
            if(appVer.indexOf('MSIE 6')>-1)
            window.onscroll= resetLayerPos;
            break;
        }
    }
}

function ModalLayer()
{
    if(navigator.appVersion.indexOf('MSIE 6')>-1)ShowDropDowns(0);
    var modalDiv = document.createElement('div');
    modalDiv.innerHTML = '<div id="confirmPop" style="position:absolute;background-color:Gray;filter:alpha(opacity=70);opacity:0.7;top:0;left:0;z-index:10002;" ></div>';	
    document.forms[0].appendChild(modalDiv.firstChild);
    var divConfirmPop = document.getElementById('confirmPop');
    var appVer = navigator.appVersion;
    var height;
    if(navigator.userAgent.indexOf("Firefox")>-1){height =document.documentElement.scrollHeight;} else{height =document.body.scrollHeight;}
    var width = parseInt(screen.width);
    divConfirmPop.style.height=height+"px";
    divConfirmPop.style.width=width+"px";
}

function MessageLayer(msg)
{
    ModalLayer();
    var DIV = document.createElement('div');
	DIV.innerHTML = '<div id="confirmPop1" class="modalPopup" style="position:absolute;left:200;top:300;display:block;z-index:10005;"> \
    <div style="width:350px; text-align:right"><a style="float:right; COLOR:#666; text-decoration:none" id="close" onclick="closePop();" href="javascript:void(0);"> \
	    Close<img alt="Close" height="11" src="/TheSystemSharedUserControls/Themes/AWS/images/lnf_ad_pop_ci_close.gif" style="border: none" width="11" /></a> </div>\
    <div>&nbsp;</div><div><label id="Label1" style="margin-left:0px;color:Red">'+ msg+'</label></div> \
    <div>&nbsp;</div></div>';
	document.forms[0].appendChild(DIV.firstChild);
	
	var divMsgLayer = document.getElementById('confirmPop1');
    divMsgLayer.style.top = 250 + "px";
    divMsgLayer.style.left = 350 + "px";
}

function MessageLayerOWS(msg)
{  
    ModalLayer();
    var DIV = document.createElement('div');
	DIV.innerHTML = '<div id="confirmPop1" class="modalPopupOWS" style="position:absolute;left:200;top:300;display:block;z-index:1000;"> \
    <div style="width:350px; text-align:right"><a style="float:right; COLOR:#666; text-decoration:none" id="close" onclick="closePop();" href="javascript:void(0);"> \
	    Close<img alt="Close" height="11" src="/TheSystemSharedUserControls/Themes/AWS/images/lnf_ad_pop_ci_close.gif" style="border: none" width="11" /></a> </div>\
    <div>&nbsp;</div><div><label id="Label1" style="margin-left:0px;color:Red">'+ msg+'</label></div> \
    <div>&nbsp;</div></div>';
	document.forms[0].appendChild(DIV.firstChild);
}

function OWSCallMeNowPopUp(id)
{   
    ModalLayer();
	var div = document.getElementById(id);
	div.style.visibility = 'visible';
	div.style.display = 'block';	
	div.className = 'modalPopupOWS';
}

function PDFPopUp()
{
    var ary = document.getElementsByTagName('DIV');
    for (var i = 0; i < ary.length; i++)
    {
        if(ary[i].id.indexOf('divBrochure') >= 0)
        {
            ModalLayer();
            var childDiv = document.createElement('div');
            childDiv.innerHTML=ary[i].innerHTML;
            childDiv.style.cssText= ary[i].style.cssText;
            childDiv.id = 'confirmPop1';
            childDiv.style.visibility = 'visible';
            childDiv.style.display = 'block';
            document.forms[0].appendChild(childDiv);
            layerToRePos='confirmPop1';
            var appVer = navigator.appVersion;
            if(appVer.indexOf('MSIE 6') <= -1)
                childDiv.style.position = 'fixed';
            else 
                childDiv.style.position = 'absolute';
            resetLayerPos();
            window.onresize= resetLayerPos;
            if(appVer.indexOf('MSIE 6')>-1)
            window.onscroll= resetLayerPos;
            break;
        }
    }
}

function SetLayerPosGlobalVariable(id)
{
    layerToRePos = id;
}

function ResetLayerPosGlobalVariable()
{
   layerToRePos = '';
}

function OnWindowResize()
{
     doResize();
     resetLayerPos();
}

function OnWindowScroll()
{
     doResize();
     resetLayerPos();
}

function doResize()
{
    var appVer = navigator.appVersion;
    if(appVer.indexOf('MSIE 6') <= -1)
        return;
    var ele; 
    var ary = document.getElementsByTagName('DIV');
    for (var i = 0; i < ary.length; i++)
    {
        if(ary[i].id.indexOf('_backgroundElement') >= 0)
        {
            ary[i].style.width=screen.width;
            ary[i].style.left=0; 
        }
    }
}

function resetLayerPos(eleId)
{
  var ele =document.getElementById(eleId);   
  if(ele==null)
    ele =document.getElementById(layerToRePos); 
  if(ele)
  {   
      var leftPOS = (document.documentElement.clientWidth- document.documentElement.clientLeft) / 2;
      var eleWidth = ele.clientWidth / 2;
      leftPOS = leftPOS- eleWidth;
      
      var topPOS = (document.documentElement.clientHeight- document.documentElement.clientTop) / 2;
      var eleHeight = ele.clientHeight / 2;
      topPOS = topPOS- eleHeight;
      var appVer = navigator.appVersion;
      if(appVer.indexOf('MSIE 6')>-1)
      {
          if(document.documentElement.scrollTop>0)
                topPOS = topPOS + (document.documentElement.scrollTop);
           if(document.documentElement.scrollLeft>0)
                leftPOS = leftPOS + (document.documentElement.scrollLeft);      
      }
      ele.style.top= topPOS+'px';
      ele.style.left= leftPOS+'px';
   }
}

//Used in Featued Listing Section 

function ShowPopUp(divId,para1)
{   
    var para1X,para1Y;
    
    //Get the X & Y position of reference element
    XYPos = getXY(document.getElementById(para1));
    if((XYPos)&& (XYPos!=''))
    {
       para1X = XYPos[0];
       para1Y = XYPos[1];
    }
   
	//Reassign the position Reset this posituiing and
    var divViewPhotos = document.getElementById(divId);
    if (divViewPhotos) {
        divViewPhotos.style.left = para1X;
        divViewPhotos.style.top = para1Y + 120;
    }
}

function getXY(para1)
{
  var XYElement = new Array();
  var xP = para1.offsetLeft;
  var yP = para1.offsetTop;
  while (para1.offsetParent)
  	{
		para1 = para1.offsetParent;
		xP += para1.offsetLeft;
		yP += para1.offsetTop;
		if(para1 != document.body && para1!= document.documentElement) 
		{
			xP -= para1.scrollLeft;
			yP -= para1.scrollTop;
		}
	}
	XYElement[0] = xP;
	XYElement[1] = yP;
	return XYElement;
 
}