
/* common to all pages */

  function showPricingTerms()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/pricing_terms.html";
      window.open ( tgtUrl, "PricingTermsAndConditions", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=300,height=300,screenX=30,screenY=25,left=30,top=25");
  }  

  function benumberone()
  {
  
      if (top.location != location) {
          top.location.href = document.location.href ;
      }
  
  }

  function OnSelectDestination ( newURL )
  {
      if ( newURL != "" )
          if ( newURL != "none")
              location.href = newURL;
  }

  function submitForm(name)
  {
      eval("document." + name + ".submit()"); return;
  }

  function PopupOnSelectDestination ( newURL )
  {
      if ( newURL != "" )
          if ( newURL != "none")
              if(opener == null || opener.closed == true)
                  {
                      window.open(newURL, 'TripAdvisor');
                  }
              else
                  {
                      opener.location.href = newURL;
                  }
      self.close();
  }
  
  function focusOpener()
  {
      if(self.opener != null)
          {
              self.opener.focus();
          }
  }
  
  function getCookie(name)
  {
      var sCookies = document.cookie;
      var sPrefix = name + '=';
  
      if(sCookies == null)
          {
              return null;
          }
  
      var nBegin = sCookies.indexOf('; ' + sPrefix);
      if(nBegin == -1)
          {
              nBegin = sCookies.indexOf(sPrefix);
              if(nBegin == -1)
                  {
                      return null;
                  }
          }
      else
          {
              nBegin += 2;
          }
      var nEnd = sCookies.indexOf(';', nBegin);
      if(nEnd == -1)
          {
              nEnd = sCookies.length;
          }
  
      return unescape(sCookies.substring(nBegin + sPrefix.length, nEnd));
  }

  function setCookie(sName, sValue, nDays)
  {
      var dExpires = null;
      if(nDays > 0)
          {
              dExpires = new Date();
              dExpires.setTime(dExpires.getTime() + (nDays * 24 * 3600 * 1000));
          }
  
      var sCookie = sName + "=" + escape(sValue) +
          ((dExpires == null) ? "" : "; expires="
          + dExpires.toGMTString())
          + "; path=/";
      sCookie += "; domain=.tripadvisor.com";
      document.cookie = sCookie;
  
  }

   

  /* all other pages */

  function openWindowQuickCheck()
  {
      window.open('http://www.tripadvisor.com/pages/quickcheck_popup.html','quickcheck_popup','toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=550,height=395,screenX=30,screenY=25,left=30,top=25');
  }
  
  function showuserrev_rules()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/userrev_rules.html";
      window.open ( tgtUrl, "userrev_rules", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=400,screenX=30,screenY=25,left=30,top=25");
  }
  
  function showuserrev_photoguide()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/photo_submission_guidelines.html";
      window.open ( tgtUrl, "userrev_rules", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=400,screenX=30,screenY=25,left=30,top=25");
  }
  
  
  function popularityIndex()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/hotel_popularity_popup.html";
      window.open ( tgtUrl, "hotel_popularity_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=400,screenX=30,screenY=25,left=30,top=25");
  }
  
  function userreviewName()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/write_a_review_name_popup.html";
      window.open ( tgtUrl, "write_a_review_name_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=550,height=175,screenX=30,screenY=25,left=30,top=25");
  }
  
  function userreviewLocation()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/write_a_review_location_popup.html";
      window.open ( tgtUrl, "write_a_review_location_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=550,height=175,screenX=30,screenY=25,left=30,top=25");
  }
  
  function userreviewSample()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/write_a_review_sample_popup.html";
      window.open ( tgtUrl, "write_a_review_sample_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=685,height=484,screenX=25,screenY=25,left=25,top=25");
  }
  
  function cityPopularityIndex()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/city_popularity_popup.html";
      window.open ( tgtUrl, "city_popularity_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=400,screenX=30,screenY=25,left=30,top=25");
  }
  
  function smartDeals()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/smart_deals_popup.html";
      window.open ( tgtUrl, "smart_deals_popup", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=350,height=350,screenX=30,screenY=25,left=30,top=25");
  }
  
  
  /* added by jay 4/16/04 to support popup privacy link */
  function showPrivacyPolicy()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/privacy_plain.html";
      window.open ( tgtUrl, "PrivacyPolicy", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=300,screenX=30,screenY=25,left=30,top=25");
  }
  
  /* added by sugata 5/20/04 to support popup stay-logged-in help*/
  function showStayLoggedinHelp()
  {
      var tgtUrl = "http://www.tripadvisor.com/pages/stay_logged_help.html";
      window.open ( tgtUrl, "StayLoggedIn", "toolbar=0,resizable=1,menubar=0,location=0,status=0,scrollbars=3,width=500,height=300,screenX=30,screenY=25,left=30,top=25");
  }  
  
  function submitNewsletter()
  {
      document.newsletter.submit();
      self.close();
  }
  
  function setBlackout()
  {
      document.cookie = 'NLPB=true';
      setCookie('NLPB', 'true', 1);
  }
  
  function popDYKWindow(sUrl)
  {
      setBlackout();
      var w = window.open(sUrl, 'TripAdvisor', 'toolbar=1,location=1,status=1,menubar=1,resizable=1,copyhistory=1,scrollbars=1');
      self.close();
  }
  
    
  var nCurrentWindowOffset = 0;
  
  function makeOptions()
  {
      var nW = 475;
      var nH = 390;
      var nXI = 24;
      var nYI = 24;
      var nX = 210;
      var nY = 5;
  
      if(screen.width > 1024) {
          nW = 800;
          nH = 600;
          nX = 240;
      } else if(screen.width > 800) {
          nW = 620;
          nH = 500;
          nX = 240;
      }
  
      nCurrentWindowOffset ++;
  
      return 'toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1,left=' + (nX + (nCurrentWindowOffset * nXI)) + ',top='+ (nY + (nCurrentWindowOffset * nYI)) + ',width=' + nW + ',height=' + nH;
  }
  
   function escramble_affiliates() {
          var a,b,c;
          a='<a href="ma';
          b='trip';
          a+='ilto:affi';
          b+='advisor.com">Become an affiliate</a>';
          c=unescape('%40');
          d='liates';
          document.write(a+d+c+b);
   }
  
  function getMouseY(e){
      if (!e && window.event) var e = window.event;
      if (e && e.pageY) return e.pageY+20;
      if (e && e.clientY) return e.clientY + document.body.scrollTop+20;
      return 50;
  }
  
  function getMouseX(e){
      if (!e && window.event) var e = window.event;
      if (e && e.pageX) return e.pageX;
      if (e && e.clientX) return e.clientX + document.body.scrollLeft;
      return 50;
  }
  
  function showYesNoButton(rUrl, uId, yesno){
    // yesno is either 'yes' or 'no';
    var buttonPath = "/img/" + yesno + "_button.gif";
    var rateURL;
    if (yesno == 'no')
        rateURL = rUrl + '&amp;rateValue=0';
    else 
        rateURL = rUrl + '&amp;rateValue=1';
    
    var imgTag = "<img src='" + buttonPath + "' hspace='2' vspace='2' " +
                 "alt='" + yesno + "' style='cursor:pointer;'  align='absmiddle' " +
                 "onclick='sendUserRating(\"" + rateURL + "\",\"" + uId + "\")'>";
    document.write(imgTag);
  }

  function sendUserRating(rateUrl, id){
    var idName = 'RatingFrame' + id;
    // treat an iframe as frame instead of the DOM element.
    var iframe = frames[idName];
    if (!iframe && document.layers && document.layers[idName]) 
    {
        iframe = document.layers[idName];
    }
    else if (!iframe && document.all && document.all[idName]) 
    {
        iframe = document.all[idName];
    }
    if (!iframe)
    {   // Bug 4148: the following works on most browsers except NS on Mac and AOL on Mac. 
        // So we don't use it unless the frame model does not work.
        iframe = document.getElementById(idName);
        if (iframe)
            iframe.src = rateUrl;
    }
    else // this fixes the bug 4148. Treat an iframe as frame instead of the DOM element.
    {
        iframe.location.href = rateUrl;
    }
  }
  

/* end ifelse home page */
