

// Copyright Organic, Inc. 2000.  All rights reserved.  This

// source code file contains proprietary and confidential information

// and trade secrets of Organic, Inc. 



function resizeFix()  

{

  if(widthCheck != window.innerWidth || heightCheck != window.innerHeight)

  {

    window.location.reload(true)

  }

}



  var elm = ns4 ? document : document.all

function layerObj(id, arg_width, url)

{

  this.x = 0

  this.y = 0

  this.w = arg_width

  this.h = 0

  this.color = null

  this.html = ""

  this.label = ""

  this.arrow = ""

  this.zIndex = 1

  this.id = id

  if(url) this.url = url

  this.css

  this.elm

  this.doc

  this.create = createLayer

  this.create()

  

  this.setPos = setPos

  this.setHtml = setHtml

  this.setSize = setSize

  this.setVis = setVis

  this.setColor = setColor

  this.setArrow = setArrow

  this.setZindex = setZindex

  this.isVisible = isVisible

}



function createLayer()

{

  var lyr

  if (ns4)

  {

    lyr = new Layer(this.w)

    this.css = lyr

    this.doc = lyr.document

    this.elm = lyr

    this.css.visibility = "inherit"

    this.doc.label = this.id

    this.doc.url = this.url

  }

  else if (ns5)

  {

	var node = document.createElement("div");

	node.setAttribute("id", this.id);

	node.style.position   = "absolute";

	node.style.visibility = "hidden";

	document.getElementsByTagName("body").item(0).appendChild(node);

	//lyr = document.getElementById(this.id);

    this.css = node.style

    this.doc = document

    this.elm = node

    this.elm.label = this.id

  }

  else

  {

    var code = "<div id=\""+ this.id + "\" style=\"position:absolute;top:0px;left:0px;width:0px;height:0px;visibility:hidden\"></div>"

    document.body.insertAdjacentHTML("beforeEnd", code)

	lyr = document.all[this.id]



    this.css = lyr.style

    this.doc = document

    this.elm = lyr

    this.elm.label = this.id

  }

}



function setHtml(html)

{

  if (!arguments[1]) this.html = html

  if (ns4)

  {

    if(html.match('img') && !html.match('href'))

    {

      tempHtml = html

      html = '\<a href=\"#\" onClick=\"return false\"\>' + tempHtml + '\<\/a\>'

    }

    this.doc.open()

    this.doc.write(html)

    this.doc.close()

  }

  else

  {

    this.elm.innerHTML = html

  }

}



function setSize(w,h)

{

  this.w = w

  this.h = h

  if (ns4)

  {

    this.css.clip.width = w

    this.css.clip.height = h

  }

  else

  {

    this.css.clip = "rect(0px " + w + "px " + h + "px 0px)"

    this.css.width = w

    this.css.height = h

  }

}



function isVisible()

{

	if (ns4)

	{

		return this.css.visibility == "inherit"

	}

	else

	{

		return this.css.visibility == "visible"

	}

}

function setVis(bool)

{

  if (ns4)

  {

    this.css.visibility = (bool) ? "inherit" : "hide"

  }

  else

  {

    this.css.visibility = (bool) ? "visible" : "hidden"

  }

}



function setColor(color)

{

  this.color = color

  if (ns4) { this.css.bgColor = color }

  else { this.css.backgroundColor = color }

}



function setZindex(zIndex)

{

  this.zIndex = zIndex

  this.css.zIndex = zIndex

}



function setPos(x,y)//position of the on-state image that spawns the menus

{

  this.x = x

  this.y = y



  if (ns4) { 

	this.elm.moveTo(x+1,y) 

  }

  else 

  {

	  if (ie4) {

	    this.css.pixelLeft = x 

	    this.css.pixelTop = y//show over item & menu this #of pixels from top of off item

	  }

	  else

	  {

		this.css.left = x + 1

		this.css.top  = y

	  }

  }

}



function setArrow()

{

this.arrow = ""

+"<img src=\"http://www.qwest.com/global/images/menu_arrow.gif\" width=9 height=19 border=0 hspace=5 vspace=0 align=\"right\">"  

+ this.html

this.setHtml(this.arrow)

}



function getInfo(whichObject, name)

{

    if(ns4)

    {

      if(document[name].document)

      { 

        whichDiv = document[name]

      }

      else {return}

      whichObject.parentImage = whichDiv

      if(section == 'homePage') 

      {

        whichObject.x = whichDiv.pageX

        if(name == 'home' || name == 'home2') whichObject.y = whichDiv.pageY

        else whichObject.y = whichDiv.pageY + whichObject.img.height

      }

      else 

      {

        whichObject.x = whichDiv.pageX + whichObject.img.width - whichObject.w

        whichObject.y = whichDiv.pageY + whichObject.img.height

      }

      whichObject.parentImage.wVal = whichDiv.document.width

      whichObject.parentImage.hVal = whichDiv.document.height - 12

      whichObject.parentImage.xVal = whichDiv.pageX

      whichObject.parentImage.yVal = whichDiv.pageY

    }

    else

    {



      if(document.all[name])

      {

        whichDiv = document.all[name]

      }

	  else if (document.getElementById(name)) {

		whichDiv = document.getElementById(name)

	  }

      else {return}

      whichObject.parentImage = whichDiv

      if (section == 'homePage')

      {

        whichObject.x = whichDiv.offsetLeft

        if(name == 'home' || name == 'home2') whichObject.y = whichDiv.offsetTop

        else whichObject.y = whichDiv.offsetTop + whichObject.img.height

      }

      else 

      {

        whichObject.x = whichDiv.offsetLeft + whichObject.img.width - whichObject.w

        whichObject.y = whichDiv.offsetTop + whichObject.img.height

      }

      whichObject.parentImage.wVal = whichDiv.offsetWidth

      whichObject.parentImage.hVal = whichDiv.offsetHeight

      whichObject.parentImage.xVal = whichDiv.offsetLeft

      whichObject.parentImage.yVal = whichDiv.offsetTop

    }

}



function buildOptions()

{

  getMenus()

	getPositions()



    for(each in menus)

    {

      thisMenu = menus[each]

      thisMenu.build(thisMenu)

    }

  buildSearch()

  buildTools()

  if(section == 'homePage') buildExplanations()

  

  if(ns4) 

  {

    widthCheck = window.innerWidth

    heightCheck = window.innerHeight

    window.onresize = resizeFix

  }

  else

  {

    widthCheck = document.body.scrollWidth

	heightCheck = document.body.scrollHeight

  }

  buildMask()

}    



var openMenu = null

var openSubMenu = null



function buildMask()

{

  namer='mask'

  mask = new layerObj(namer, widthCheck*2)

  mask.setVis(false)

  mask.w = widthCheck

  mask.h = heightCheck

  mask.setSize(mask.w, mask.h)

  mask.setPos(0, 0)

  mask.setZindex(0)

  mask.elm.onmouseover =

    function()

    {      

        if(problemForm && openMenu)

        {

          for (x in problemForm)

          {

            if (problemMenu && ((openMenu.label == problemMenu[x])))

					elm[problemForm[x]].visibility = 'visible'

          }

        }

        if(openMenu) 

        {

          openMenu.visHide()    

        }

        else

        {

          for (each in menus) menus[each].visHide()

          

        }

        openMenu = null

        if(openSubMenu) openSubMenu.visHide()

        openSubMenu = null

       // if(searchObj) 

       // {

       //   searchObj.setVisibility(false)

       //   searchFormElm.blur()

       // }

        mask.setVis(false)

    }

}



// Copyright Organic, Inc. 2000.  All rights reserved.  This

// source code file contains proprietary and confidential information

// and trade secrets of Organic, Inc. 



var menuCounter=0



function makeMenu()

{  

  var itemArray = new Array()

  for(var i=0; i<arguments.length; i++)

  {

    itemArray[i] = new menuItem(arguments[i])

  }

  return new menu(itemArray)

}



function menuItem()

{

  var itemDesc = arguments[0]  

  this.label = itemDesc[0]

  this.url = null

  this.submenu = null

  if(itemDesc.length == 2)

  {

   if(typeof itemDesc[1] == 'string') 

   {

     this.url = itemDesc[1]

   }

   else

   {

     this.submenu = itemDesc[1]

   }

  }



  if(itemDesc.length == 3)

  {

    this.url = itemDesc[1]

    this.submenu = itemDesc[2]

  }

}



function menu(arg_items)

{

  this.parent = null

  this.menuItems = arg_items

  this.menuNum = menuCounter++

  this.topPos = 0

  this.leftPos = 0

  this.menuWidth = 200

  this.menuHeight = 19

  this.bgColor = '#FFFFFF'

  this.overColor = '#A0B5C5'

  this.textClass = 'dslMenuLink'

  this.borderWidth = 1

  this.borderColor = '#CCCCCC'

  

  this.Imglyr = null

  this.visShow = 

    function() 

    { 

      if(this.Imglyr) this.Imglyr.setVis(true)

      for(x in this.menuItems)

      {

        if(this.menuItems[x].lyr)this.menuItems[x].lyr.setVis(true)

      }

      if(this.border) this.border.setVis(true)

    }

    

  this.visHide = 

    function() 

    { 

      if(this.Imglyr) this.Imglyr.setVis(false)

      for(x in this.menuItems)

      {

        if(this.menuItems[x].lyr)this.menuItems[x].lyr.setVis(false)

      }

      if(this.border) this.border.setVis(false)

    }

  this.build = buildMenus

  this.isVisible = 

	function()

	{

		return this.Imglyr.isVisible()

	}

      

  for (i in this.menuItems)

  {

    if (this.menuItems[i].submenu) 

    {

      this.menuItems[i].submenu.parentMenu = this

      this.menuItems[i].submenu.parentMenuItem = this.menuItems[i]

    }

  }

}



function getPositions() //position menus

{

  for(each in menus)

  {

    thisMenu = menus[each]

    thisMenu.label = each

    if(ns4)

    {

      thisMenu.parentImage = document[each]

      thisMenu.leftPos = document[each].pageX+1

      thisMenu.topPos = document[each].pageY + thisMenu.menuHeight+3

    }

    if(ie4)

    {

      thisMenu.parentImage = document.all[each]

      thisMenu.leftPos = document.all[each].offsetLeft+1

      thisMenu.topPos = document.all[each].offsetTop + thisMenu.menuHeight+3

    }

	else if(ns5)

	{

      thisMenu.parentImage = document.getElementById(each)

      thisMenu.leftPos = document.getElementById(each).offsetLeft+1//perfect

      thisMenu.topPos = document.getElementById(each).offsetTop + thisMenu.menuHeight+17//fine

	}    

	for(i in menus[each].menuItems)

    {

      if(thisMenu.menuItems[i].submenu)

      {

        thisSubMenu = thisMenu.menuItems[i].submenu

        thisSubMenu.leftPos = thisMenu.leftPos + thisMenu.menuWidth+1


        thisSubMenu.topPos = thisMenu.topPos + (i * (thisMenu.menuHeight+1))

      }

    }

  }

}



function buildMenus(thisMenu)

{

	var menuVSkew = 0;

	if (ie4) { menuVSkew = 0 }

	else {

		if (ns5) menuVSkew = 14;

	}



    if(this.borderWidth && this.borderColor)

      {

        this.border = new layerObj('menu' + this.menuNum + 'border', this.menuWidth+(this.borderWidth*2))

        this.border.w = this.menuWidth+(this.borderWidth*2)

        this.border.h = ((this.menuHeight+1)*this.menuItems.length)+(this.borderWidth)

        this.border.setSize(this.border.w, this.border.h)

        this.border.setVis(false)

        this.border.setColor(this.borderColor)

        this.border.setPos(this.leftPos-this.borderWidth, (this.topPos - this.borderWidth - menuVSkew))

        this.border.setZindex(2)

      }

  

  for(i in this.menuItems)

  {

    this.menuItem = this.menuItems[i]

    this.menuItem.ident = 'menu' + thisMenu.menuNum + 'item' + i

    itemId = this.menuItem.ident

    this.menuItem.menu = thisMenu

    this.menuItem.lyr = new layerObj(itemId, thisMenu.menuWidth, this.menuItem.url)

    this.menuItem.lyr.setSize(thisMenu.menuWidth, thisMenu.menuHeight)

    this.menuItem.lyr.setVis(false)

    this.menuItem.lyr.setColor(thisMenu.bgColor)

    if(!this.menuItem.url) this.menuItem.url = '#'

    this.menuItem.lyr.setHtml('<a href=\"' + this.menuItem.url + '\" class=\'' + thisMenu.textClass + '\' name=\"' + this.menuItem.ident + 'Link' + '\">' + this.menuItem.label + '</a>')

    this.menuItem.lyr.setPos(thisMenu.leftPos, (thisMenu.topPos + ((thisMenu.menuHeight+1)*i) - menuVSkew))

    this.menuItem.lyr.elm.label = this.menuItem.ident

    this.menuItem.lyr.elm.menu = thisMenu

    this.menuItem.lyr.elm.menuItem = this.menuItem

    this.menuItem.lyr.setZindex(3)

    this.menuItem.lyr.css.paddingLeft=5

    this.menuItem.lyr.css.paddingTop=3



    if(this.menuItem.submenu) 

    {

      this.menuItem.lyr.setArrow()

      this.menuItem.submenu.build(this.menuItem.submenu)

      this.menuItem.lyr.elm.subMenu = this.menuItem.submenu

      this.menuItem.lyr.elm.onmouseover = function() 

      { 

        if(openSubMenu && (this.subMenu != openSubMenu)) 

        {

          openSubMenu.visHide()

          openSubMenu = null

        }

        this.subMenu.visShow()

        openSubMenu = this.subMenu

        this.menuItem.lyr.setColor(this.menu.overColor)

      }

    }

    else

    {

      this.menuItem.lyr.elm.onmouseover = 

      function()

      {

        this.menuItem.lyr.setColor(this.menu.overColor)

        if(openSubMenu && (this.menu != openSubMenu)) 

        {

          openSubMenu.visHide()

          openSubMenu = null

        }

      }

    }

    

	if (ns4 || ie4)

    this.menuItem.lyr.elm.onmouseout = 

		function()

    	{        

		  this.menuItem.lyr.setColor(this.menu.bgColor)

    	}

	else

    this.menuItem.lyr.elm.onmouseout = 

      function(event)

      {        

        this.menuItem.lyr.setColor(this.menu.bgColor)



		if (event.target == this) {

			var px = event.pageX;
//			alert(px)


			var py = event.pageY;

			var ml = this.menu.border.x + 2;

			var mr = ml + this.menu.border.w;

			var mt = this.menu.border.y;

			var mb = mt + this.menu.border.h;

			if(px < ml || px > mr) { this.menu.visHide(); return; }

			if(py < mt || py > mb) { this.menu.visHide(); return; }

		}

      }

    

    

    if(ns4) this.menuItem.lyr.elm.captureEvents(Event.CLICK)

    this.menuItem.lyr.elm.onclick = 

      function()

      {

        if(this.menuItem.url) goTo(this.menuItem.url)

      }

    

  }

  

  if(!thisMenu.parentMenu)

  {

    nameSplit = thisMenu.label.split("Menu")

    itemId= thisMenu.menuNum + 'menuImageMask'

    thisMenu.Imglyr = new layerObj(itemId, (document.images[nameSplit[0] + 'Img'].width+8), thisMenu.url)

    thisMenu.Imglyr.setSize((document.images[nameSplit[0] + 'Img'].width+10), (document.images[nameSplit[0] + 'Img'].height))

    thisMenu.Imglyr.setVis(false)

    if(ns4) thisMenu.Imglyr.setPos((thisMenu.parentImage.pageX), (thisMenu.parentImage.pageY))

    else thisMenu.Imglyr.setPos((thisMenu.parentImage.offsetLeft), (thisMenu.parentImage.offsetTop))

    imgName = nameSplit[0] + 'On.gif'

    if(this.url == null) this.url = '#'

    thisMenu.Imglyr.setHtml('\<a href=\"' + this.url + '\" onMouseOver="return"><img src=\"http:\/\/www.qwest.com\/imgs\/' + imgName + '\" border=0 name=\"' + thisMenu.label + 'OverGif\"\></a>')

    thisMenu.Imglyr.setZindex(1)

    thisMenu.Imglyr.elm.parentMenu = thisMenu

    thisMenu.Imglyr.elm.url = thisMenu.url

    if(ns4) thisMenu.Imglyr.elm.captureEvents(Event.CLICK)

    thisMenu.Imglyr.elm.onclick = 

      function()

      {

        goTo(this.url)

      }

    thisMenu.Imglyr.elm.onmouseover = 

    function()

    {

        if(openMenu != this.parentMenu)

        {

          for(each in menus)

          {

            menus[each].visHide()

          }

          openMenu = null

        }

        if(openMenu == null) openMenu = this.parentMenu

        if(mask.css.visibility == 'hidden' || mask.css.visibility == 'hide') mask.setVis(true)

        if(openSubMenu) openSubMenu.visHide()

    }

  }

}    



function showMenu(whichMenu)

{

  if(menus[whichMenu]) 

  {

    if(ns4) elm = document

    else if(ns5) elm = document.getElementById

	else elm = document.all



	if (ie4 || ns5) hideOtherMenus(whichMenu)



    if(problemForm != null)

    {

      for (x in problemForm)

      {

        if (problemMenu && ((whichMenu == problemMenu[x]))) elm[problemForm[x]].visibility = 'hidden'

      }

    }

    openMenu = menus[whichMenu]

    menus[whichMenu].visShow()

  }

}

