TOS = {
  //if passed null for declineTarget, don't go anywhere
  init: function(targetObj){
    TOS.acceptTarget = targetObj.acceptTarget;
    TOS.declineTarget = targetObj.declineTarget;
    screenWidthObj = document.getElementById('screenwidth');
    screenWidth_osh = screenWidthObj.offsetHeight;
    semiTransLayerObj = document.createElement("DIV");
    semiTransLayerObj.id = "semitranslayer2";
    semiTransLayerObj.style.position = "absolute";
    semiTransLayerObj.style.top = "0px";
    semiTransLayerObj.style.left = "0px";
    semiTransLayerObj.style.height = 9000 + "px";
    semiTransLayerObj.style.width = "100%";
    semiTransLayerObj.style.background = "#333";
    semiTransLayerObj.style.zIndex = "1000000";
    YAHOO.util.Dom.setStyle(semiTransLayerObj,"opacity",".9");
    document.body.appendChild(semiTransLayerObj);

    ieFrameObj = document.createElement("IFRAME");
    ieFrameObj.style.position = "absolute";
    ieFrameObj.frameBorder = 0;
    ieFrameObj.src = "javascript:false";
    ieFrameObj.style.zIndex = "1000001";
    ieFrameObj.style.top = "0px";
    ieFrameObj.style.left = "0px";
    ieFrameObj.style.width = "100%";
    ieFrameObj.style.height = screenWidth_osh + "px";
    YAHOO.util.Dom.setStyle(ieFrameObj,"opacity","0");
    document.body.appendChild(ieFrameObj);

    formdiv = document.createElement("DIV");
    formdiv.style.position = "absolute";
    formdiv.id = 'div-emailthispage2';
    formdiv.style.width = '550px';
    formdiv.style.zIndex = "1000002";
    formdiv.innerHTML = '<div style="background:#ffffff;border:3px solid #ccc;width:500px;height:455px;border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px;">' +
                        '<img style="float:left;margin:20px 0 0 20px;" src="/images/base/logo_300x57.gif" width="200" alt="Healthline, Inc"/>' +
                        '<div style="margin:10px 10px 0 0;float:right;background:url( /images/debug_winClose.jpg) no-repeat left top;width:15px;height:15px;cursor:pointer;" onclick="TOS.close();"></div><div class="clear"></div>' +
                        '<div id="success1" style="width:460px;margin:10px 20px 20px;font-size:16px;clear:both;">' +
                        '<p style="font-size:22px;line-height:1.4em;text-align:left;margin:0;"><em style="font-style:normal;font-weight:bold;">Just one more click...</em><br/>Please confirm the Terms of Use to proceed.</p>' +
                        '<div><textarea readonly="true" style="padding:3px;margin-bottom:10px;font-size:11px;border:2px solid #aaa;width:452px;height:209px;margin-top:10px;background-color:#f2f2f2;">' +
                        'END USER LICENSE AGREEMENT\n\nPLEASE READ THIS AGREEMENT CAREFULLY.  THIS IS AN AGREEMENT BETWEEN YOU AND INGENIX, INC. (&quot;LICENSOR&quot;) REGARDING ACCESS TO, AND USE OF, THE [DATA PRODUCTS] (THE &quot;PRODUCT&quot;).  THESE TERMS ARE IN ADDITION TO ANY OTHER TERMS CONTAINED ON THE HEALTHLINE WEBSITE.  You are referred to below as &quot;User.&quot;\n\nIF YOU DO NOT AGREE WITH THESE TERMS, DECLINE WHERE INSTRUCTED, AND YOU WILL NOT BE ABLE TO ACCESS OR USE THE PRODUCTS.\n\n1. LICENSE: INTELLECTUAL PROPERTY RIGHTS. Licensor grants to User a nonexclusive, nontransferable license to access and use the Product from the United States solely for your personal healthcare management use.  User may submit queries to for the purpose of obtaining information but not in order to create new or competitive products.  Notwithstanding any terms to the contrary in any Site Policies, all right, title, and interest in and to the Product, including all intellectual property rights, are the sole and exclusive property of Licensor.  All rights not expressly granted to You in these terms are reserved by Licensor.\n\n2. CONFIDENTIAL INFORMATION.  User agrees that the Product contains confidential and trade secret, information owned by this Licensor or its vendors.  User agrees not to use or disclose the Product, except, as permitted by this Agreement.  User agrees to take all reasonable precautions to protect the confidential nature of the Product, and agrees not to appropriate the confidential or trade secret material to his/her own use or to the use of any other person or entity.  Notwithstanding the foregoing, User may retain and disclose copies of information downloaded from the Product to the extent the same relates specifically to User&#039;s personal healthcare management.\n\n3. EXCESSIVE USE.  Excessive use or abuse of the Product resources by one user may have a negative impact on all other users.  User shall not misuse his/her access to the Product in a manner that impairs performance of the Product or impairs the ability of other users to access the Product.  User agrees not to attempt to obtain a copy of the Product or of the information contained in the Product through screen scraping, multiple queries, proxy servers, computer generated queries, or other unauthorized means.\n\n4. RESTRICTIONS.  User may not copy the Product or any of its content, except to copy a response from the Product to a query submitted by User for personal healthcare management purposes.  User shall not replicate, sublicense, assign, share or transfer this license or the Product.  User agrees not to attempt to obtain a copy of the Product through screen scraping, multiple queries, proxy servers, computer generated queries, or other unauthorized means.\n\n5. LIMITED WARRANTY AND REMEDIES.  USER IS OBTAINING THE PRODUCT &quot;AS-IS&quot;. LICENSOR AND ITS VENDORS PROVIDE THE PRODUCT WITHOUT WARRANTY OF ANY KIND, AND DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\n\n6. LIMITATION ON DAMAGES.  IN NO EVENT WILL LICENSOR OR ITS VENDORS BE LIABLE TO USER FOR ANY LOST PROFITS, LOST SAVINGS OR ANY IDIRECT, INCIDENTIAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES ARISING OUT OF THE USE, OR INABILITY TO USE THE PRODUCT EVEN IF LICENSOR OR A VENDOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY THIRD PARTY.  Licensor&#039;s and its vendors&#039; liability to User for direct damages under this Agreement shall not exceed the greater of the price User paid for the product or $1,000.' +
                        '</textarea>' +
                        '<div style="float:left;width:200px;text-align:left;"><a class="underlineless" href="javascript:void(0);" onclick="window.open(\'/popup_ingenixlicense-print.jsp\',\'_blank\',\'location=0,resizable=1,status=1,scrollbars=1,menubar=1,titlebar=1,width=600,height=800\');return false;" style="background:url( /images/icon_print_black.gif ) no-repeat left center;padding-left:21px;margin-right:15px;font-size:12px;color:#006599;">Print</a><a  class="underlineless" href="javascript:void(0);" onclick="window.open(\'/popup_ingenixlicense-save.jsp\',\'_blank\',\'location=0,resizable=1,status=1,scrollbars=1,menubar=1,titlebar=1,width=600,height=800\');return false;"  style="color:#006599;background:url( /images/icon_save_black.gif ) no-repeat left center;padding-left:21px;font-size:12px;">Save to disk</a></div>' +
                        '<div style="float:right;text-align:right;"><ul id="confirmUL" style="width:auto;"><li id="confirmLI" style="list-style:none;width:auto;"><a href="javascript:TOS.confirm();" style="background:#C83F1F none;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;padding:5px 10px;line-height:1.5em;color:white;text-decoration:none;font-size:14px;display:block;font-weight:bold;width:auto;box-shadow:3px 3px 4px 1px #aaa;-moz-box-shadow:3px 3px 4px 1px #aaa;-webkit-box-shadow:3px 3px 4px 1px #aaa;">Agree and Continue</a></li></ul><div style="padding-top:15px;"><a  class="underlineless" style="color:#006599;font-size:14px;" href="javascript:TOS.close();">Disagree</a></div></div>' +
                        '<div class="clear"></div>' +
                        '</div>'
                        '</div>' +
                        '<div>';
    document.body.appendChild(formdiv);
    TOS.positionDiv();
  },
  positionDiv: function(){
    if (formdiv.offsetWidth < YAHOO.util.Dom.getViewportWidth()){
      formdiv.style.left = (YAHOO.util.Dom.getViewportWidth() - formdiv.offsetWidth)/2 + "px";
    } else {
      formdiv.style.left = '0px';
    }
    if (formdiv.offsetHeight < YAHOO.util.Dom.getViewportHeight()){
      formdiv.style.top = ((YAHOO.util.Dom.getViewportHeight() - formdiv.offsetHeight)/2 + YAHOO.util.Dom.getDocumentScrollTop()) + "px";
    } else {
      formdiv.style.top = '0px';
    }
  },
  close: function(){
    document.body.removeChild(semiTransLayerObj);
    document.body.removeChild(ieFrameObj);
    document.body.removeChild(formdiv);
    if(TOS.declineTarget != null){
      document.location.href = TOS.declineTarget;
    }
  },
  confirm:function(){
    //write cookie with current timestamp
    YAHOO.util.Cookie.set(TOS.cookie, new Date().valueOf(),{expires: new Date("January 12, 2025"),path:"/"});
    //cookieString = TOS.cookie+"="+escape(new Date().valueOf())+";expires="+new Date("January 12, 2025").toGMTString() + ";path=/";
    //document.cookie = cookieString;
    if(TOS.acceptTarget =="_self"){
      document.body.removeChild(semiTransLayerObj);
      document.body.removeChild(ieFrameObj);
      document.body.removeChild(formdiv);
      return;
    }
    else{
      document.location.href = TOS.acceptTarget;
    }
  },
  checkForCookie:function(targetObj){
    TOS.acceptTarget = targetObj.acceptTarget;
    TOS.declineTarget = targetObj.declineTarget;
    var tosCookie = YAHOO.util.Cookie.get(TOS.cookie);
    if(tosCookie == null){
      TOS.init(targetObj);
      return;
    }
    else{
      if(targetObj.acceptTarget =="_self"){
        return false;
      }
      else{
        document.location.href = TOS.acceptTarget;
      }
    }
  },
  launchEULA:function(incomingDeclineTar){
    if(incomingDeclineTar == null){
      if(qs.getValue("pid")!="")
        var declineTar = (location.pathname.indexOf("_")!= 0)?location.pathname.replace("_doctors",""):"/treatments/";
      if(qs.getValue("compare")!="")
        var declineTar = location.pathname;
      if(location.pathname.indexOf("_costs")!=-1 )
        var declineTar = (location.pathname.indexOf("_")!= 0)?location.pathname.replace("_costs",""):"/treatments/";
    }
    else{
      declineTar = incomingDeclineTar;
    }
    YAHOO.util.Event.onContentReady('screenwidth', TOS.init,{acceptTarget:document.location.href, declineTarget:declineTar});
  }
}
TOS.cookie = "txsTOS";
TOS.acceptTarget = "";
TOS.declineTarget = "";
