﻿var pnlWidth = 700;
var pnlHeight = 520;
var blnshown = 0;
var blnnomore = 0;
var msg_exit='Please complete our survey.';
var newloc='';

 window.onbeforeunload = function(evt)
   {  
       //has user checked box for no more surveys today?
       if (document.getElementById('hf_nomore').value == 1) {blnshown='1';}
       
       if (blnshown==0)
       {
            //survey not yet displayed, so show it now...
            show_survey();
            
            msg_exit = "WE HAVE A SHORT SURVEY OF 7 QUESTIONS.\n\nPLEASE CLICK 'CANCEL' TO STAY ON THE PAGE AND ANSWER OUR QUESTIONS.\n\nPLEASE CLICK 'CANCEL'.";

            
            if(typeof evt=='undefined') 
            {//IE
                evt=window.event;
            }
            if (evt) { 
              evt.returnValue = msg_exit; 
            }
            return msg_exit;
       } 
    }
    
    
function close_survey()
{
   
    document.getElementById('pnl_survey').style.display='none';
    document.getElementById('pnl_Mask').style.display='none';
    msg_exit='';
    //set new location address...
    if (newloc!='') {window.location=newloc;}
}


function do_goback(url, elemid)
{
   newloc = url;
   //has user checked box for no more surveys today?
   if (document.getElementById('hf_nomore').value == 1) {blnshown='1';}

   if (blnshown==0)
    {
       document.getElementById(elemid).href=url;
       show_survey();
    }
    else
    {
      //survey has been displayed, need to exit page...
        if (newloc!='') {window.location=newloc;}
    }  
}

function do_listresort(url)
{
    if (url!='') 
        {
            if (blnshown==0){blnshown=2;}
            window.location=url;
            if (blnshown==2){blnshown=0;}
        }
}



function show_survey()
{
    blnshown=1;
    msg_exit='';            
    position_survey();
    document.getElementById('pnl_survey').style.display='block';
    document.getElementById('pnl_Mask').style.display='block';
}

function position_survey()
{
    var ypos;
    set_mask_height(); 
    iY = get_pageoffset(); 

    ypos = position_panel(pnlHeight, iY);  
    document.getElementById('pnl_survey').style.top = ypos  + "px";
    document.getElementById('pnl_survey').style.left = (screen.width - pnlWidth) / 2 + "px";
   }
   