// Fallowing are The javaScript functions used in this js file
    
    // 1 Managing the tabs of the product layer
    // 2 On clicking the link,show the product layer
    // 3 On clicking the close button,hide the product layer
    // 4 Moving the product layer dynamically on the page
    // 5 On clicking the arrow on the layer,slide the div
    // 6 Function to fetch the data dynamically using controller  
    
//**************************************************************************************
// Change History
// DATE       CODER               COMMENTS
// ---------- ------------------- -------------------------------------------
// 11Aug2009   AVELARDE            Fixed Issue with IE8.0-Added pageScroll
// 12Aug2009   MPACLAON            Mantis 453 - Ability for Multiple Auction
//**************************************************************************************/
 
//****************************************************************************************

// function to move the div(product layer) dynamically on the page
// Determine browser and version.
currentItemPL = 1 ;

function pageScroll() {
        // AVelarde Added 11Aug2009 - Mantis 546
        var incBy = (document.documentElement ? document.documentElement.scrollTop : document.body.scrollTop);
        var incByDc = (-1 * incBy) - 1000
        window.scrollBy(0,incByDc); // horizontal and vertical scroll increments
        scrolldelay = setTimeout('pageScroll()',1); // scrolls every 100 milliseconds
        clearTimeout(scrolldelay);
}


function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  //dragObj.elNode.style.zIndex = ++dragObj.zIndex; // Commented by Tejswita - to remove transperancy

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

//****************************************************************************************

// Function to manage the Tabs
function ManageTabPanelDisplay() {
//
// Between the parenthesis, list the id's of the div's that 
//     will be affected when tabs are clicked. List in any 
//     order. Put the id's in single quotes (apostrophes) 
//     and separate them with a comma -- all one line.
//
var idlist = new Array('tab1focus','tab2focus','tab1ready','tab2ready','content1','content2');

// No other customizations are necessary.
if(arguments.length < 1) { return; }
for(var i = 0; i < idlist.length; i++) {
   var block = false;
   for(var ii = 0; ii < arguments.length; ii++) {
      if(idlist[i] == arguments[ii]) {
         block = true;
         break;
         }
      }
   if(block) { document.getElementById(idlist[i]).style.display = "block"; }
   else { document.getElementById(idlist[i]).style.display = "none"; }
   }
}

var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}

// function to hide the Div(product layer)


// function to show the Div(product layer)
function showLayer(prodid,page) {
getProdInfo(prodid,page);
showQuickView();
  
}

// function to show the Div for Sale & shop page (product layer)
function showLayerSale(prodid,price,page) {
getProdInfoSale(prodid,price,page); 
showQuickView();
}

// function to show the Div for Web game (product layer)
function showLayerWeb(prodid,price,page,prodCnt) {
getProdInfoWeb(prodid,price,page,prodCnt); 
showQuickView();
}

//start mantis 453 - ability for multiple auction
function showLayerProductGrpWeb(prodid,price,page,prodCnt) {
        getProductGroupWeb(prodid,price,page,prodCnt); 
        showQuickView();
}

function showLayerTVProductGrpWeb(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId)
{
        getTVProductGroupWeb(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId); 
        showQuickView();
}
//end mantis 453

function showQuickView()
{
          if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("QuickView")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("QuickView")');
  else
     document.poppedLayer = 
         eval('document.layers["QuickView"]');
         
  // to show the div on the center of the screen
  // *********************************************
  var IpopTop = ((screen.height - document.getElementById("QuickView").offsetHeight)/2) - (100 + 50);
  var IpopLeft = ((screen.width - document.getElementById("QuickView").offsetWidth)/2) - (75 + 10);
  var scrLft =  (document.documentElement ? document.documentElement.scrollLeft : document.body.scrollLeft);
  var scrTop =  (document.documentElement ? document.documentElement.scrollTop : document.body.scrollTop);
  
  document.getElementById("QuickView").style.left = IpopLeft + scrLft;
  document.getElementById("QuickView").style.top = IpopTop + scrTop;
  
   
   // ****document.getElementById("QuickView").style.left = IpopLeft + document.body.scrollLeft;
  //**document.getElementById("QuickView").style.top=IpopTop + document.body.scrollTop;
  // *********************************************         
  document.poppedLayer.style.visibility = "visible";
  $("#QuickView").show();
  $("#QuickView").focus();
//  document.poppedLayer.focus();  
  
}

function show1() {
hide1();
        var obj1 = document.getElementById("viewLink");
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("view3d")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("view3d")');
  else
     document.poppedLayer = 
         eval('document.layers["view3d"]');
  document.poppedLayer.style.display = "block";
  
  obj1.innerHTML="<a href=\"javascript:show2()\" value=\"show\" >Click Here for Image View</a>";
}

function show2() {
hide2();
        var obj1 = document.getElementById("viewLink");
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("imgdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("imgdiv")');
  else
     document.poppedLayer = 
         eval('document.layers["imgdiv"]');
  document.poppedLayer.style.display = "block";
  obj1.innerHTML="<a href=\"javascript:show1()\" value=\"show\" >Click Here for 3D View</a>";
}

function hide() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("QuickView")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("QuickView")');
  else
     document.poppedLayer =   
        eval('document.layers["QuickView"]');
  document.poppedLayer.style.visibility = "hidden";
}

function hide1() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("imgdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("imgdiv")');
  else
     document.poppedLayer =   
        eval('document.layers["imgdiv"]');
  document.poppedLayer.style.display = "none";
}

function hide2() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("view3d")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("view3d")');
  else
     document.poppedLayer =   
        eval('document.layers["view3d"]');
  document.poppedLayer.style.display = "none";
  
}

// Function for scrolling starts here
// *************************************************************************************
currentItemPL = 1 ;
function sliderProductLayer(direction){

        if(!scrollObjectsPL['slideshowpl'].isMoving){
        
                tempItem = currentItemPL + direction ;
                if (tempItem > 0 && tempItem <= slideShowItemsPL) {
                        if (tempItem == 1){
                        
                                slideLeftButVarPL.style.display = "none" ;      
                        } else {
                        
                                slideLeftButVarPL.style.display = "block" ;
                        }
                        if (tempItem == slideShowItemsPL){
                        
                                slideRightButVarPL.style.display = "none" ;
                        } else {
                                slideRightButVarPL.style.display = "block" ;
                        }
                        
                        scrollObjectPL.plScrollBy('slideshowpl',-1*direction*liWidthPL,0);
                        currentItemPL += direction;
                }
        }
}

scrollObjectsPL = {};
function scrollObjectPL(divId,iniX,iniY){
        this.id=divId;
        scrollObjectsPL[this.id]=this;
        this.animString="scrollObjectsPL."+this.id;
        this.plLoad(divId,iniX,iniY);
};


scrollObjectPL.prototype.plLoad=function(divId,iniX,iniY){

        if(!document.getElementById)return;
        var scrollingDivPL;

        this.scrollingDivPL=document.getElementById(divId);
        
        this.scrollingDivPL.style.top=this.y=iniY;
        this.scrollingDivPL.style.left=this.x=iniX;
        
        this.ready=true;
};


scrollObjectPL.plSlideDur = 500; // duration of glide

scrollObjectPL.plScrollBy = function(divId, x, y, dur, hideWhenStop) {
        if ( scrollObjectsPL[divId] ) scrollObjectsPL[divId].plGlideBy(x, y, dur, hideWhenStop);
}


scrollObjectPL.prototype.plGlideBy = function(dx, dy, dur, hideWhenStop) {
  if ( !document.getElementById || this.isMoving ) return;
  this.plSlideDur = dur || scrollObjectPL.plSlideDur;
  this.destX = this.destY = this.distX = this.distY = 0;
  this.startX = this.x; this.startY = this.y;
  
  this.distY = dy;
  this.distX = dx;
  
  this.destX = this.startX + this.distX; 
  this.destY = this.startY + this.distY;
  
  this.hideWhenStop = hideWhenStop ;
  
  this.isMoving = true;
  this.per = Math.PI/(2 * this.plSlideDur);
  this.slideStart = (new Date()).getTime();
  this.aniTimer = setInterval(this.animString + ".plDoSlide()",10);
}

scrollObjectPL.prototype.plDoSlide = function() {
        var elapsed = (new Date()).getTime() - this.slideStart;
        if (elapsed < this.plSlideDur) {
                var x = this.startX + this.distX * Math.sin(this.per*elapsed);
                var y = this.startY + this.distY * Math.sin(this.per*elapsed);
    this.plShiftTo(this.scrollingDivPL, x, y); 
        } else {
    clearInterval(this.aniTimer); this.isMoving = false;
        this.plShiftTo(this.scrollingDivPL, this.destX, this.destY);
                if (this.hideWhenStop){
                        this.scrollingDivPL.style.visibility="hidden";
                }
        }
}

scrollObjectPL.prototype.plShiftTo=function(scrollingDivPL,x,y){
        if(!scrollingDivPL.style)return;
        scrollingDivPL.style.left=(this.x=x)+"px";
        scrollingDivPL.style.top=(this.y=y)+"px";
};

function initSlideshowProductLayer(itemWidth) {

        if(document.getElementById){
        
                slideShowListPL = document.getElementById('slideshowlistpl');
                
                slideShowItemsPL = 0 ;
        
                try
                {
                        slideShowChildNodes = slideShowListPL.childNodes ;
                
                        
                        for (i=0; i<slideShowChildNodes.length; i++){
                        
                                if (slideShowChildNodes[i].nodeName == "LI") slideShowItemsPL++ ;
                        }
                        
                        slideLeftButVarPL=document.getElementById('leftArrowpl');               
                        slideRightButVarPL=document.getElementById('rightArrowpl');
                        //var count = 0;
                        //count = slideShowItemsPL;
                        slideLeftButVarPL.style.display = "none" ;
                        if (slideShowItemsPL == 1){
                                
                                slideRightButVarPL.style.display = "none" ;
        
                        }
                        var slideShowPL = new scrollObjectPL('slideshowpl', 0, 0);
                        
                        liWidthPL = itemWidth;
                }
                catch (exception)
                {
                }
                
        }       
}
//  ****************************************************************************************


// Function to call the controller and get the dynamic data
//  ****************************************************************************************
var reqProdInfo;
function getProdInfo(prodid,page){

QuickView.innerHTML = "";
        var url = "viewproductinfogems.htm?productid="+prodid+"&addtocart=no&ouCode=GEM&pgname="+page+"";
        //var url = "viewproductinfogems.htm?productid=16036&addtocart=no&ouCode=GEM";
        //alert(url);
        if (window.XMLHttpRequest){
                reqProdInfo = new XMLHttpRequest(); 
        }else if (window.ActiveXObject){
                reqProdInfo = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        reqProdInfo.open("GET", url, true);
        reqProdInfo.onreadystatechange = callBackProductInfoGems;
        reqProdInfo.send(null);
}


function getProdInfoSale(prodid,price,page){

        QuickView.innerHTML = "";
        var url = "/viewproductinfogems.htm?productid="+prodid+"&price="+price+"&addtocart=no&ouCode=GEM&pgname="+page+"";
        //var url = "viewproductinfogems.htm?productid=16036&addtocart=no&ouCode=GEM";
        //alert(url);
        if (window.XMLHttpRequest){
                reqProdInfo = new XMLHttpRequest(); 
        }else if (window.ActiveXObject){
                reqProdInfo = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        reqProdInfo.open("GET", url, true);
        reqProdInfo.onreadystatechange = callBackProductInfoGems;
        reqProdInfo.send(null);
        setTimeout('document.getElementById("QuickView").focus();',1);
                
}

function getProdInfoWeb(prodid,price,page,prodCnt){
        QuickView.innerHTML = "";
        var url = "viewproductinfogems.htm?productid="+prodid+"&price="+price+"&prodCnt="+prodCnt+"&addtocart=no&ouCode=GEM&pgname="+page+"";
        //var url = "viewproductinfogems.htm?productid=16036&addtocart=no&ouCode=GEM";
        //alert(url);
        if (window.XMLHttpRequest){
                reqProdInfo = new XMLHttpRequest(); 
        }else if (window.ActiveXObject){
                reqProdInfo = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        reqProdInfo.open("GET", url, true);
        reqProdInfo.onreadystatechange = callBackProductInfoGems;
        reqProdInfo.send(null);
}
 
function callBackProductInfoGems(){     
        if (reqProdInfo.readyState == 4){
                if (reqProdInfo.status == 200){
                        var l = reqProdInfo.responseText;
                        // Html to be replaced with Div(QuickView)
                        currentItemPL = 1 ;
                        QuickView.innerHTML = l;                
                        initSlideshowProductLayer(250); 
                        
                        // To get the layer on the center of page
                    var IpopTop = ((screen.Height - document.getElementById("QuickView").offsetHeight)/2) - (100 + 50);
                    var IpopLeft = ((screen.Width - document.getElementById("QuickView").offsetWidth)/2) - (75 + 10);              
                    //document.getElementById("QuickView").style.left=IpopLeft + document.body.scrollLeft;
                    //document.getElementById("QuickView").style.top=IpopTop + document.body.scrollTop;
                    // To get the layer on the center of page   
                    $("#imgdiv").focus();                                       
                    //document.getElementById("imgdiv").focus();                     
                    // AVelarde Added 11Aug2009 - Mantis 546
                    pageScroll();
                }
        }
}
//  ****************************************************************************************
//start mantis 453
var reqGrpProd;

function getProductGroupWeb(prodid,price,page,prodCnt){
        QuickView.innerHTML = "";
        var url = "multipleProductAuction.htm?productId="+prodid+"&price="+price+"&page="+page+"&priceIndex="+prodCnt+"&dummy="+Math.floor(Math.random()*1000000);
        if (window.XMLHttpRequest){
                reqGrpProd = new XMLHttpRequest(); 
        }else if (window.ActiveXObject){
                reqGrpProd = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        reqGrpProd.open("GET", url, true);
        reqGrpProd.onreadystatechange = callBackProductGroupGems;
        reqGrpProd.send(null);
}
 
function callBackProductGroupGems(){    
        if (reqGrpProd.readyState == 4){
                if (reqGrpProd.status == 200){
                        var l = reqGrpProd.responseText;
                        currentItemPL = 1 ;
                        QuickView.innerHTML = l;                
                        
                        // To get the layer on the center of page
                    var IpopTop = ((screen.Height - document.getElementById("QuickView").offsetHeight)/2) - (100 + 50);
                    var IpopLeft = ((screen.Width - document.getElementById("QuickView").offsetWidth)/2) - (75 + 10);              
                    document.getElementById("QuickView").style.left=IpopLeft + document.body.scrollLeft;
                    document.getElementById("QuickView").style.top=IpopTop + document.body.scrollTop;
                    // To get the layer on the center of page                                                                           
                }
        }
}
function getTVProductGroupWeb(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId){
        QuickView.innerHTML = "";
        //var url = "viewproductinfogems.htm?productid="+prodid+"&price="+price+"&prodCnt="+prodCnt+"&addtocart=no&ouCode=GEM&pgname="+page+"";
        var url = "multipleProductAuction.htm?productId="+proId+"&ouCode="+ouCode+"&purchaseAmount="+purchaseAmount+"&purchasePrice="+purchasePrice
                  +"&channelId="+channelId+"&gameId="+gameId+"&page=TV&dummy="+Math.floor(Math.random()*1000000);
        if (window.XMLHttpRequest){
                reqGrpProd = new XMLHttpRequest(); 
        }else if (window.ActiveXObject){
                reqGrpProd = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        reqGrpProd.open("GET", url, true);
        reqGrpProd.onreadystatechange = callBackTVProductGroupGems;
        reqGrpProd.send(null);
}
 
function callBackTVProductGroupGems(){  
        if (reqGrpProd.readyState == 4){
                if (reqGrpProd.status == 200){
                        var l = reqGrpProd.responseText;
                        currentItemPL = 1 ;
                        QuickView.innerHTML = l;                
                        
                        // To get the layer on the center of page
                    var IpopTop = ((screen.Height - document.getElementById("QuickView").offsetHeight)/2) - (100 + 50);
                    var IpopLeft = ((screen.Width - document.getElementById("QuickView").offsetWidth)/2) - (75 + 10);              
                    document.getElementById("QuickView").style.left=IpopLeft + document.body.scrollLeft;
                    document.getElementById("QuickView").style.top=IpopTop + document.body.scrollTop;
                    // To get the layer on the center of page                                                                           
                }
        }
}

//end mantis 453

// AVelarde -- Added for Message Box

function hideMsgBox() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("MsgBox")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("MsgBox")');
  else
     document.poppedLayer =   
        eval('document.layers["MsgBox"]');
  document.poppedLayer.style.visibility = "hidden";
}

function showMsg(type,msgTitle){  
         currentItemPL = 1 ;
         var msgHead = '<div class="plHeader"><div class="plHeader_l"></div><div class="plHeader_b" onmousedown="dragStart(event, \'MsgBox\')"> <div class="prodName" style="text-align:center">'+msgTitle+'</div><div class="close"><a id="closeTag" href="javascript:hideMsgBox()" title="Hide">&nbsp;</a></div></div><div class="plHeader_r"></div></div><div class="plBody" style="height:90px"><div class="plBody_l"></div>';
         var btnYES = ' <button id="btnYes" class="ui-state-default ui-corner-all" type="submit">&nbsp;Yes&nbsp;</button> &nbsp';
         var btnNO  = ' <button id="btnNo" class="ui-state-default ui-corner-all" type="submit">&nbsp;No&nbsp;</button> &nbsp';
         var btnCANCEL  = ' <button id="btnCan" class="ui-state-default ui-corner-all" type="submit">&nbsp;Cancel&nbsp;</button> &nbsp';
         var btnOK      = ' <button id="btnOk" class="ui-state-default ui-corner-all" type="submit">&nbsp;OK&nbsp;</button> &nbsp';
         var buttons ="";
         switch(type) {
            case 'yes|no': buttons = buttons + btnYES+btnNO; break;
            case 'yes|no|cancel': buttons = buttons + btnYES+btnNO+btnCANCEL; break;
            case 'ok|cancel': buttons = buttons + btnOK+btnCANCEL;  break;
            case 'ok': buttons = buttons + btnOK;  break;
          }

         
         var msgBody = '<div class="plBody_b"> <div id="msgHead"> <div id="msgContent" style="color:#136C8A;font-weight:bold;font-family:Arial,Helvetica,sans-serif;font-size:12px">ANTONS CUSTOM MESSAGE</div> <div id="buttons" > <br/>' + buttons +' <br/></div> </div> </div><div class="plBody_r"></div></div>';
         var msgFooter = '<div class="plFooter"><div class="plFooter_l"></div><div class="plFooter_b"></div><div class="plFooter_r"></div></div>';                
         MsgBox.innerHTML= msgHead + msgBody + msgFooter;
         // To get the layer on the center of page
         MsgBox.width = "150px";
         if (browserType == "gecko" )
             document.poppedLayer = 
                 eval('document.getElementById("MsgBox")');
          else if (browserType == "ie")
             document.poppedLayer = 
                eval('document.getElementById("MsgBox")');
          else
             document.poppedLayer = 
                 eval('document.layers["MsgBox"]');
         
          document.poppedLayer.style.visibility = "visible";
          //document.poppedLayer.focus();          
}
