﻿///////////////////////////////////////////////////////////////////////////////
//
//  csSplashManager.js
//
// © 2007-2009 Wco iEnterprise Solutions Pty Ltd. ALL RIGHTS RESERVED.
// This file is licensed as part of the DataPortal 2.0 Managed Web Presence Solution, for details look here: http://www.wco.com.au
//
///////////////////////////////////////////////////////////////////////////////

//--------------------------------------------------------------------------------
HtmlSplashObject = function(parentObject) {
  this.parent = parentObject;
  
  var html = '<div id="splashPanel" style="position:absolute; top:0px; left:0px; width:956px; height:742px; z-index:100; background-image:url(\'ssl/images/bkg_splash_1.png\'); background-repeat:repeat; display:none; cursor:default;">';
  
    html += '<div id="splashContent" style="position:absolute; top:0px; left:0px; width:956px; height:742px;">';
  
      html += '<div id="splashBubble" style="position:absolute; top:18px; left:159px; width:797px; height:704px; background-image:url(\'ssl/images/bkg_splashcontent_1.png\'); background-position:left top; background-repeat:no-repeat;">';
      html += '<p class="SplashHeading" style="margin:60px 0 0 260px;">';
      html += 'I have questions...';
      html += '</p>';
      html += '';
      html += '<p class="SplashNormalText" style="margin:10px 0 0 158px;">';
      html += 'From our location on Macquarie Street in Sydney, Australia, <span class="SplashLargeText">Contraceptive</span>';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 183px;">';
      html += '<span class="SplashLargeText">Services has been providing answers to our patients\'</span>';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 195px;">';
      html += '<span class="SplashLargeText">questions for over 50 years</span> with safe, caring, and affordable abortion';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 205px;">';
      html += 'counselling, pregnancy termination and specialist female medical services.';
      html += '</p>';
      html += '';
      html += '<p class="SplashNormalText" style="margin:10px 0 0 210px;">';
      html += 'Our mission is to deliver the highest standards of care and advice for women';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 210px;">';
      html += 'regarding abortions and all female reproductive health issues. As a part of this';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 208px;">';
      html += 'commitment, our clinic is open 6 days per week and our telephones are';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 200px;">';
      html += 'attended 7 days per week. And, now, this online knowledgebase is available a full';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 195px;">';
      html += '24 hours per day, 364 days per year – delivering the answers to all your important';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 170px;">';
      html += 'questions <span class="SplashLargeText">from a trusted, reliable source and from the privacy</span>';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 180px;">';
      html += '<span class="SplashLargeText">of your own computer screen.</span>';
      html += '</p>';
      html += '';
      html += '<p class="SplashNormalText" style="margin:10px 0 0 180px;">';
      html += 'Please select your preferred language from the menu at the top of each page and';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 225px;">';
      html += 'begin browsing this knowledgebase, discovering the relevant answers to';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 255px;">';
      html += 'your questions on abortion and pregnancy termination. Then, when';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 263px;">';
      html += 'you\'re ready to talk, call our abortion hotline on (02) 9221-1933.';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 267px;">';
      html += '<span class="SplashLargeText">Your call will be answered by another</span>';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 272px;">';
      html += '<span class="SplashLargeText">woman</span> and you are guaranteed to be treated with';
      html += '</p>';
      html += '<p class="SplashNormalText" style="margin:0 0 0 273px;">';
      html += 'the utmost kindness and respect.';
      html += '</p>';
      html += '</div>';
      html += '';
      html += '<div id="splashImage" style="position:absolute; top:121px; left:0px; width:421px; height:621px;">';
      html += '<img src="ssl/images/cs_splashimg.png" style="width:421px; height:621px; border:none 0px;" />';
      html += '</div>';
      html += '';
      html += '<div id="btnCloseSplash" style="position:absolute; top:63px; left:900px; width:21px; height:21px; display:none;">';
      html += '<img id="ssl/images/btn_close_up.gif|ssl/images/btn_close_dn.gif|" src="ssl/images/btn_close_up.gif" style="width:21px; height:21px; border:none 0px; cursor:pointer;" />';
      html += '</div>';
      html += '';
      html += '<div id="btnStartApp" style="position:absolute; top:600px; left:515px; width:108px; height:22px; display:none;">';
      html += '<img id="ssl/images/btn_start_up.gif|ssl/images/btn_start_dn.gif|" src="ssl/images/btn_start_up.gif" style="width:108px; height:22px; border:none 0px; cursor:pointer;" />';
      html += '</div>';
  
//      //html += '<div style="position:absolute; top:499px; left:487px; width:409px; height:99px; background-image:url(\'ssl/images/bkg_contactus.jpg\'); background-position:left top; background-repeat:no-repeat; cursor:default;">';
//      html += '<div style="position:absolute; top:634px; left:487px; width:409px; height:99px; background-image:url(\'ssl/images/bkg_contactus.jpg\'); background-position:left top; background-repeat:no-repeat; cursor:default;">';
//        html += '<div style="position:absolute; top:7px; left:115px; width:290px; height:92px; cursor:default;">';
//          html += '<p style="font-family:\'Tahoma\', \'Frutiger 47LightCn\', \'Arial\', \'Sans Serif\'; font-size:16pt; line-height:20pt; letter-spacing:-1pt; text-align:left; color:#ffffff; margin:0; padding:0;">';
//            html += '<b>Medical Abortion available now</b> - ';
//            html += 'call (02) 9221 1933 for<br/>';
//            html += 'full details &amp; expert advice.';
//          html += '</p>';
//        html += '</div>';
//      html += '</div>';
      html += '<div style="position:absolute; top:634px; left:10px; width:938px; height:101px; background-image:url(\'ssl/images/bkg_splashbox.jpg\'); background-position:left top; background-repeat:no-repeat; cursor:default;">';
        html += '<div style="position:absolute; top:17px; left:115px; width:823px; height:84px; cursor:default;">';
          html += '<p style="font-family:\'Arial\', \'Tahoma\', \'Frutiger 47LightCn\', \'Sans Serif\'; font-size:24pt; line-height:26pt; letter-spacing:-1pt; text-align:center; color:#ffffff; margin:0; padding:0;">';
            html += 'MEDICAL &amp; SURGICAL ABORTION available 6 days<br/>';
            html += '<span style="font-size:14pt;">For detailed information <a href="javascript:void(0);" onclick="javascript:window.open(\'http://www.ranzcog.edu.au/womenshealth/pdfs/Termination-of-pregnancy.pdf\', \'_blank\');" title="Navigate to Royal Australian and New Zealand College of Obstetricians and Gynaecologists document, \'Termination of pregnancy\'." style="color:#FFFFFF;">read this document</a> or call us on (02) 9221-1933 for expert medical advice.</span>';
          html += '</p>';
        html += '</div>';
      html += '</div>';
  
    html += '</div>';
  html += '</div>';
  var newContent = document.createElement('DIV');
  newContent.id = 'newContent';
  newContent.innerHTML = html;
  newContent.style.display = 'none';
  this.rootElement = newContent.childNodes[0];
  this.parent.contentPane.appendChild(this.rootElement);
  this.splashContent = this.rootElement.childNodes[0];
  this.splashImage = positioning.getObject('splashImage');
  this.splashBubble = positioning.getObject('splashBubble');
  this.btnClose = positioning.getObject('btnCloseSplash');
  this.btnStart = positioning.getObject('btnStartApp');
  
  this.isFirstTime = true;
  this.isCloseBtnActive = false;
  
  // and hook up the mouse events for the new menu item object
  //this.btnClose.onmouseover = positioning.createDelegate(this, this.onMouseOver);
  this.btnClose.onmouseout = positioning.createDelegate(this, this.onMouseOut);
  this.btnClose.onmousedown = positioning.createDelegate(this, this.onMouseDown);
  this.btnClose.onmouseup = positioning.createDelegate(this, this.onMouseUp);
  
  this.btnStart.onmouseout = positioning.createDelegate(this, this.onMouseOut);
  this.btnStart.onmousedown = positioning.createDelegate(this, this.onMouseDown);
  this.btnStart.onmouseup = positioning.createDelegate(this, this.onMouseUp);
  
  this.rootElement.onmouseup = positioning.createDelegate(this, this.onMouseUp);
}

HtmlSplashObject.prototype = {
  redoLayout: function() {
    var w = windowGeometry.getViewportWidth();
    var h = windowGeometry.getViewportHeight();
    
    positioning.setObjectWidth(this.rootElement, w);
    positioning.setObjectHeight(this.rootElement, h);
    positioning.setObjectLeft(this.splashContent, (w/2)-(956/2));
  },
  
  show: function() {
    if (!this.isFirstTime) {
      // replace the Start button with the Continue button
      this.btnStart.childNodes[0].id = 'ssl/images/btn_continue_up.gif|ssl/images/btn_continue_dn.gif';
      this.btnStart.childNodes[0].src = 'ssl/images/btn_continue_up.gif';
    }
    positioning.showObject(this.rootElement);
  },
  
  hide: function() {
    if (this.isFirstTime) {
      this.parent.sitemenu.select(0);
      this.isFirstTime = false;
    }
    positioning.hideObject(this.rootElement);
  },
  
  showButtons: function() {
    positioning.showObject(this.btnClose);
    positioning.showObject(this.btnStart);
    this.isCloseBtnActive = true;
  },
  
  hideButtons: function() {
    positioning.hideObject(this.btnClose);
    positioning.hideObject(this.btnStart);
    this.isCloseBtnActive = false;
  },
  
  onMouseOver: function(e) {
    var element;

    if (!e) var e = window.event;
    if (e.target) element = e.target;
    else if (e.srcElement) element = e.srcElement;
    if (element.nodeType == 3) element = element.parentNode;
  },
  
  onMouseOut: function(e) {
    var element;

    if (!e) var e = window.event;
    if (e.target) element = e.target;
    else if (e.srcElement) element = e.srcElement;
    if (element.nodeType == 3) element = element.parentNode;
    
    var props = element.id.split('|');
    upImg = props[0];
    dnImg = props[1];
    cmd = props[2];
    
    element.src = upImg;
  },
  
  onMouseDown: function(e) {
    var element;

    if (!e) var e = window.event;
    if (e.target) element = e.target;
    else if (e.srcElement) element = e.srcElement;
    if (element.nodeType == 3) element = element.parentNode;
    
    var props = element.id.split('|');
    upImg = props[0];
    dnImg = props[1];
    cmd = props[2];
    
    element.src = dnImg;
  },
  
  onMouseUp: function(e) {
    // only execute this method if the Close button is active
    if (this.isCloseBtnActive == true) {
      var element;

      if (!e) var e = window.event;
      if (e.target) element = e.target;
      else if (e.srcElement) element = e.srcElement;
      if (element.nodeType == 3) element = element.parentNode;
      
      if (element.id.indexOf('|') > -1) {
        var props = element.id.split('|');
        upImg = props[0];
        dnImg = props[1];
        cmd = props[2];
        
        element.src = upImg;
      }
      
      this.hide();
    }
  } 
   
}

