﻿// JScript File
function absPosition(obj) { 
      var x = y = 0; 
      while(obj) { 
            x += obj.offsetLeft; 
            y += obj.offsetTop; 
            obj = obj.offsetParent; 
      } 
      return {x:x, y:y}; 
}
function windowHeight() {/*var de = document.documentElement;return self.innerHeight || ( de && de.clientHeight ) || document.body.clientHeight;*/
var window_Height;
       if (self.innerHeight) { // all except Explorer
            window_Height = self.innerHeight;}
        else if (/*navigator.appVersion.lastIndexOf("MSIE 6")<0 &&*/ document.documentElement && document.documentElement.clientHeight>0) { // Explorer 6 Strict Mode
            window_Height = document.documentElement.clientHeight;}
        else if (/*navigator.appVersion.lastIndexOf("MSIE 6")>=0 &&*/ document.body) { // other Explorers
            window_Height = document.body.clientHeight;}
       return window_Height
}


var stop=false;

function init(xdropdown, xddimg, xddimghover, xddins, mp)
{
    dd = document.getElementById(xdropdown);
    ddins = document.getElementById(xddins);
    dd.style.display = "block";
    dd.style.visibility = "hidden";
    h=dd.offsetHeight;
    if (h<40) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv030.gif)";}
    else
    if (h<70){ ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv060.gif)";  }     
    else
    if (h<110) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv100.gif)";}
    else
    if (h<160){ ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv150.gif)"; }      
    else
    if (h<200) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv200.gif)";}
    else
    if (h<250){ ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv250.gif)"; }      
    else
    if (h<300) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv300.gif)";}
    else
    if (h<350){ ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv350.gif)"; }      
    else
    if (h<400) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv400.gif)";}
    else
    if (h<500) {ddins.style.backgroundImage = "url("+mp+"img/CustomDDL_bkgrndv500.gif)";}
    dd.style.height = 0;
    //ddimgh.style.left = absPosition(ddimg).x;
    DDLx = new Object();
    DDLx.dd = document.getElementById(xdropdown);
    DDLx.ddimg = document.getElementById(xddimg);
    DDLx.ddimgh = document.getElementById(xddimghover);
    y_top = absPosition(DDLx.ddimg).y;
    DDLx.ddimgh.style.top = y_top;
    DDLx.ddimgh.style.display = "none";
    DDLx.y_top = y_top;
    DDLx.h = h;
    DDLx.eshow = eshow;
    DDLx.ehide = ehide;
    DDLx.startHide = startHide;
    DDLx.stopHide = stopHide;
    DDLx.toClose;
    DDLx.bShow = false;
    DDLx.ddimg.bInit = true;
    DDLx.ddimg.DDL = DDLx;
}

function eshow()
{
    if (!stop&&!this.bShow)
    {
        this.ddimgh.style.display = "block";
        this.dd.style.display = "block";
        stop=true;
        show(this,  this.y_top, this.h, 10);
    }
}

function ehide(ddl)
{
    if (ddl.bShow)
    {
        hide(ddl, ddl.y_top, ddl.h, 5);
    }
}

function show(obj, btm, h, step)
{
    obj.dd.style.height = 0;
    resize.target = obj;
    resize.height = 0;
    resize.step_y = h/step;
    resize.step = step;
    resize.bottom = windowHeight() - 5 - btm;
    if (navigator.appVersion.lastIndexOf("MSIE 6")>=0)
    { resize.bottom += document.documentElement.scrollTop;//= document.body.clientHeight - btm;
    }
    obj.dd.style.visibility = "visible";
    resize.timer = window.setInterval(resize, 20);
//    window.status=
//    "documentElement.clientHeight=" + document.documentElement.clientHeight +
//    "  body.clientHeight=" + document.body.clientHeight +
//    "  documentElement.scrollTop=" + document.documentElement.scrollTop +
//    "  TopOfTheDDL="+ btm+ 
//    "  computed=" + (resize.bottom+3) +
//    "  browser:" + navigator.appVersion;
}

function resize()
{
    resize.target.dd.style.height = Math.round(resize.height += resize.step_y);
    resize.target.dd.style.bottom = resize.bottom;
    if (--resize.step <= 0){ 
    window.clearInterval(resize.timer);
    resize.target.bShow = true;
    }
}

function hide(obj, btm, h, step)
{
    resize.target = obj;
    resize.height = h;
    resize.step_y = h/step;
    resize.step = step;
    resize.bottom = windowHeight() - 3 - btm;
    if (navigator.appVersion.lastIndexOf("MSIE 6")>=0)
    {
        resize.bottom += document.documentElement.scrollTop;//= document.body.clientHeight - btm;
    }
    resize.timer = window.setInterval(resize1, 20);
}

function resize1()
{
    resize.target.dd.style.height = Math.round(resize.height -= resize.step_y);
    resize.target.dd.style.bottom = resize.bottom;
    if (--resize.step<=0){
        window.clearInterval(resize.timer);
        resize.target.ddimgh.style.display = "none";
        resize.target.dd.style.display = "none";
        stop=false;
        resize.target.bShow = false;
    }
}


function unhover()
{
}

var LinkAnchors = new Array("http://www.hawaiiantel.com/");

function redirectTo(place)
{
    document.location.href = LinkAnchors[place];
}
function redirectTo1(place)
{
    document.location.href = LinkAnchors1[place];
}

function startHide()
{
    DDL = this;
    this.toClose=setTimeout(function(){this.ehide(DDL)}, 250);
}

function stopHide()
{
    if(this.toClose!=undefined){clearTimeout(this.toClose);}
}