/*********************************
	global.js for Regence.com
	code by Allan Chang (allan.chang(AT)blastradius.com)
	version 0.0.1
*********************************/

/* ON LOAD, DO THIS STUFF */
$(document).ready(function(){

  // initialize tooltips
  PopUp.init();
  nullLinks();
  
  // SEARCH FORM REMOVE/REPLACE
  $("#search #textfield").focus(function(){
	if (this.value=='Search'){
		this.value='';
	}
  }).blur(function(){
	if (this.value==''){
		this.value='Search';
	}
  });

  // popup windows
  $("a.popup").popupwindow();

  // navigation dropdowns
  $("#nav-primary li").hoverClass("sfhover");
  $("#nav-sub li").hoverClass("sfhover");
  $("#nav-topsection li").hoverClass("sfhover");
  $("#nav-topsection2 li").hoverClass("sfhover");
  
  // initialize tabs
  $('#plans-tabs').tabs({
    onClick : function(clicked) {
      if (clicked.href && clicked.href.length > 0 && clicked.href.indexOf('#') == -1) {
        window.location = clicked.href;
        return false;
      } 
    }
  });
  
  // use tabs to drive imageSwap
  $("#plans-tabs>ul a").each(function(i, a) {
    if (window.location.hash) {
            if (a.href) {
                  if (a.href.indexOf(window.location.hash) !== -1) {
                        eval(a.onclick());
                  }
            }
      }
  });
  
  // pagination
  $('#pagination a').click(function(){
    var target = $(this).attr('rel');
    $('.pagination-chunk').hide();
    $('#'+target).show();
    $('#pagination a').removeClass('on');
    $(this).addClass('on');
    return false;
  });
  
  // toggle mailing address on t10 form
  $('#useASeparateMailingAddress').click(function(){
    $('#mailingAddress').toggle();
  });

  // show/hide plan details
  /*$('.plan-detail h2 a').click(function(){
    var target = $(this).attr('rel');
    if( $(this).is('.contracted') ){
      $('#'+target).show();$(this).removeClass('contracted');$(this).addClass('expanded');
    }else{
      $('#'+target).hide();$(this).removeClass('expanded');$(this).addClass('contracted');
    }
    return false;
  });*/
  
  // Product Details pages
  
	defaultState();
  /*$('.plan-detail h2').mouseover(function(){
    $(this).css('cursor','pointer');
  });
  $('.plan-detail h2').mouseout(function(){
    $(this).css('cursor','default');
  });*/
  
  // show/hide comparison matrix table rows
  if(navigator.appName.indexOf("Microsoft") > -1){
    var canSee = 'block';
  } else {
    var canSee = 'table-row-group';
  }

  $('#comparison-matrix tbody th a').click(function(){
    var target = $(this).attr('rel');
    if( $(this).is('.contracted') ){
      $('#'+target).css("display",canSee);$(this).removeClass('contracted');$(this).addClass('expanded');
    }else{
      $('#'+target).hide().removeClass('expanded');$(this).addClass('contracted');
    }
    return false;
  });
  
  // show 'subject: other' field for email and feedback forms
  $('#frmEmail #emailSubjectSelect').change(function(){
    var messageIndex;
    messageIndex=$('#emailSubjectSelect').val();
    if (messageIndex=='other'){
      $('#other').show();
    }else{
      $('#other').hide();
    }
  });
  $('#frmFeedback #emailSubjectSelect').change(function(){
    var messageIndex;
    messageIndex=$('#emailSubjectSelect').val();
    if (messageIndex=='other'){
      $('#other').show();
    }else{
      $('#other').hide();
    }
  });
  
  // show regional offices on contact page
  $('#contact #region').change(function(){
    var messageIndex;
    messageIndex=$('#region').val();
    if (messageIndex=='wa'){
      $('#washington').show();
      $('#oregon').hide();
	  $('#idaho').hide();
	  $('#utah').hide();
    }else if (messageIndex=='or'){
      $('#oregon').show();
      $('#washington').hide();
	  $('#idaho').hide();
	  $('#utah').hide();
    }else if (messageIndex=='id'){
      $('#oregon').hide();
      $('#washington').hide();
	  $('#idaho').show();
	  $('#utah').hide();
    }else if (messageIndex=='ut'){
      $('#oregon').hide();
      $('#washington').hide();
	  $('#idaho').hide();
	  $('#utah').show();
    }
  });
  
  /* 
show google maps
  $('#contact .location a').attr('href','#');
  $('#contact .location a').click(function(){
    var target = $(this).attr('rel');
    $('select').toggle();
    $('#'+target).toggle();
    initGMap(target);
    return false;
  });

*/
  
  // press release list page
  $('.press-contacts tr:odd').addClass('alt');
  $('.press-release-list p:odd').addClass('alt');
  $('.press-release-list p').mouseover(function(){
    $(this).addClass('over');}).mouseout(function(){
      $(this).removeClass('over');}).click(function(){
/*        window.target='_blank';
        window.location=$(this).find('a').attr('href');
*/      });
  
  // glossary alphabet - add current state
  $('#alphabet a').click(function(){
    $('#alphabet a').removeClass('on');
    $(this).addClass('on');
  });
  
  // zebra striping on contact us page
  $('#contact .chunk:odd').addClass('alt');
  
  // comparison tool stuff
  //$('#comparison-tool').load('comparison-tool.jsp');
  //$('#compare-this').click(function(){
    
  //});

  // resize search page iframe
    setIframeHeight('searchFrame');
    $('#searchFrame').load(function(){
      setIframeHeight('searchFrame');
    });
  
});


// COOKIE FUNCTIONS FOR LEFT NAV
function setCurrent(item, gotoUrl){
  setCookie('CURRITEM', item, 14);
  window.location.href=gotoUrl;
  return false;
}
function setCookie(c_name,value,expiredays,path){
  var exdate=new Date()
  exdate.setDate(exdate.getDate()+expiredays)
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) + 
  ((path==null) ? ";path=/" : ";path="+path);
}


/* ON UNLOAD, DO THIS STUFF */
$(window).unload(function(){
  //GUnload();
  //saveState();
});


/* IMG SWAP FUNCTION */
function imgSwap(target,image) {
  document.getElementById(target).src=image;
}

/* jQuery Suckerfish dropdowns emulation */

$.fn.hoverClass = function(c) {
    return this.each(function(){
      if ($(this).attr('class')!='spacer'){
        $(this).hover(
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
      }
    });
};

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
**/
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/*
Popupwindow plugin for jQuery.
by: Tony Petruzzi
homepage: http://rip747.wordpress.com
plugin download: http://rip747.wordpress.com/2007/03/02/the-return-of-popupwindow-jquery-plugin/
  
Takes a link and will create a popupwindow based on the href of the link. You can
over ride the default setting by passing your own settings using the REL attribute
of the link. You can have different setting for each link if you'd like.
   
To use just include the plugin in the HEAD section of the page AFTER calling jQuery.
After that, use jQuery to find the links you want and pass any parameters you want

04/04/2007:

1) added profiles so you don't have to pass the settings for each link anymore.
2) remove resize as a setting and add the correct setting resizable
3) removed example text from this file and made an index.htm files to house example.
4) add example of using profiles to the new examples page.
5) example pulls the latest jquery library from jquery.com.

05/14/2007

1) removed trailing comma in settings that was causing IE to bottom out with an error.

*/

jQuery.fn.popupwindow = function(p)
{

	var profiles = p || {};

	return this.each(function(index){
		var setting, parameters, mysettings, b, a;
		
		// for overrideing the default settings
		mysettings = (jQuery(this).attr("rel") || "").split(",");

		
		settings = {
          height:600, // sets the height in pixels of the window.
          width:600, // sets the width in pixels of the window.
          toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
          scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
          status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
          resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
          left:0, // left position when the window appears.
          top:0, // top position when the window appears.
          centerv:0, // should we center the window vertically? {1 (YES) or 0 (NO)}. overrides top
          centerh:0, // should we center the window horizontally? {1 (YES) or 0 (NO)}. overrides left
          location:0, // show the location box with the current url (The place to type http://address) {1 (YES) or 0 (NO)}.
          directories:0, // show the extra buttons. (what's cool, personal buttons, etc...) {1 (YES) or 0 (NO)}.
          menubar:0, //show the menus at the top of the window (File, Edit, etc...) {1 (YES) or 0 (NO)}.
          copyhistory:0 //copy the old browser window's history list to the new window {1 (YES) or 0 (NO)}.
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists


		if(mysettings.length == 1 && mysettings[0].split(":").length == 1)
		{
			a = mysettings[0];
			// see if a profile has been defined
			if(typeof profiles[a] != "undefined")
			{
				settings = jQuery.extend(settings, profiles[a]);
			}
		}
		else
		{
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=0; i < mysettings.length; i++)
			{
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2)
				{
					settings[b[0]] = b[1];
				}
			}
		}

		// center the window vertically
		if (settings.centerv == 1)
		{
			settings.top = (screen.height-(settings.height + 110))/2;
		}
		
		// center the window horizontally
		if (settings.centerh == 1)
		{
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		jQuery(this).bind("click", function(){
			var name = "PopUpWindow" + index;
			window.open(this.href, name, parameters).focus();
			return false;
		});
	});

};

/*
 * Javascript fix for Safari's inability to link to named anchors (or ids of elements) inside 
 * elements with overflow: auto set
 *
 * see http://blog.deconcept.com/code/overflowsafari/overflowsafari.html
 * for more information
 *
 * by Geoff Stearns ( geoff @ deconcept.com )
 *
 */


// the id of the element with overflow: auto set, in this case the div
var targBox = '#definitions';

function init() {
	if (document.getElementById) {
		var atags = $('a');
		for (var i=0;i<atags.length;i++) {
			var ca = atags[i];
			if (ca.href.indexOf("#") > -1) {
				ca.onclick = function() {
					scrollDivToAnchor(this.href.split("#")[1]);
				}
			}
		}
	}
}

function scrollDivToAnchor(a) {

	var b = $(targBox);
	b.scrollTop = $('#'+a).offsetTop - b.offsetTop;

	// alternately, if your elements are not nested within other nodes inside the box,
	// you could use document.getElementById(a).parentNode.scrollTop
	// that way you wouldn't need to specify the id of the scrollable box

}

if (navigator.userAgent.indexOf("Safari") > -1) {
	window.onload = init;
}



/* TOOLTIPS
############
############
############
*/

var pu_event = {

  add: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.addEventListener) obj.addEventListener(etype, fp, cap);
    else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);
  }, 

  remove: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);
    else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);
  }, 

  DOMit: function(e) { 
    e = e? e: window.event;
    e.tgt = e.srcElement? e.srcElement: e.target;
    
    if (!e.preventDefault) e.preventDefault = function () { return false; }
    if (!e.stopPropagation) e.stopPropagation = function () { if (window.event) window.event.cancelBubble = true; }
        
    return e;
  }  
}

var viewport = {
	
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
}

var PopUp = {
	
    followMouse: true,
    offX: 8,
    offY: 12,
    tipID: "tipDiv",
    showDelay: 500,
    hideDelay: 100,
	Transparent: 100,
	ready:false,
	timer:null,
	tip:null,
	
	init:function(){
		if(document.createElement&&document.body&&typeof document.body.appendChild!="undefined"){
			if(!document.getElementById(this.tipID)){
				var el=document.createElement("DIV");
				el.id=this.tipID;
				document.body.appendChild(el);
			}
			this.ready=true;
		}
	},
	
	show:function(e,msg,w){
		if(this.timer){
			clearTimeout(this.timer);
			this.timer=0;
		}
		this.tip=document.getElementById(this.tipID);
		if(this.followMouse) pu_event.add(document,"mousemove",this.trackMouse,true);
		this.writeTip("");
		this.writeTip(msg);
		viewport.getAll();
		this.positionTip(e);
		this.tip.style.width=w+"px";
		this.timer=setTimeout("PopUp.toggleVis('"+this.tipID+"', 'visible')",this.showDelay);
	},
	
	writeTip:function(msg){
		if(this.tip&&typeof this.tip.innerHTML!="undefined")this.tip.innerHTML=msg;
	},
	
	positionTip:function(e){
		if(this.tip&&this.tip.style){
			var x=e.pageX?e.pageX:e.clientX+viewport.scrollX;
			var y=e.pageY?e.pageY:e.clientY+viewport.scrollY;
			if(x+this.tip.offsetWidth+this.offX>viewport.width+viewport.scrollX){
				x=x-this.tip.offsetWidth-this.offX;
				if(x<0)x=0;
			}else x=x+this.offX;
			if(y+this.tip.offsetHeight+this.offY>viewport.height+viewport.scrollY){
				y=y-this.tip.offsetHeight-this.offY;
				if(y<viewport.scrollY)y=viewport.height+viewport.scrollY-this.tip.offsetHeight;
			}else y=y+this.offY;
			this.tip.style.left=x+"px";
			this.tip.style.top=y+"px";
		}
	},
	
	hide:function(){
		if(this.timer){
			clearTimeout(this.timer);
			this.timer=0;
		}
		this.timer=setTimeout("PopUp.toggleVis('"+this.tipID+"', 'hidden')",this.hideDelay);
		if(this.followMouse)pu_event.remove(document,"mousemove",this.trackMouse,true);
		this.tip=null;
	},

	fadeout:function() {
		if(this.timer){
			clearTimeout(this.timer);
			this.timer=0;
		}
		this.tip = document.getElementById(this.tipID);
		this.Transparent -= 5;
		if (this.Transparent < 5) {
			//clearTimeout(this.timer);
			this.tip.style.visibility = "hidden";
			PopUp.setOpacity(100);
			if(this.followMouse)pu_event.remove(document,"mousemove",this.trackMouse,true);
			this.tip=null;
			return false;
		} else {
			PopUp.setOpacity(this.Transparent);
			this.timer=setTimeout("PopUp.fadeout()",50);
		}
	},
	
	toggleVis:function(id,vis){
		var el=document.getElementById(id);
		if(el) el.style.visibility=vis;
	},
	
	trackMouse:function(e){
		e=pu_event.DOMit(e);
		PopUp.positionTip(e);
	},
	
	setOpacity: function(e){
		if (this.tip) {
			this.tip.style.filter = "alpha(opacity="+ e +")";
			this.tip.style.opacity = e/100;
		}
		this.Transparent = e;
	}
};

PopUp.tipOutCheck = function(e) {
  e = pu_event.DOMit(e);
  // is element moused into contained by PopUp?
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( this != toEl && !contained(toEl, this) ) PopUp.fadeout(); 
}

PopUp.timerId = 0;
PopUp.clearTimer = function() {
	if (PopUp.timerId) { clearTimeout(PopUp.timerId); PopUp.timerId = 0; }
	PopUp.setOpacity(100);
}

PopUp.unHookHover = function () {
    var tip = document.getElementById? document.getElementById(PopUp.tipID): null;
    if (tip) {
        tip.onmouseover = null; 
        tip.onmouseout = null;
        tip = null;
	}
}
// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}
// e=event, msg=one of the above variables, w=width of popup
function doPopUp(e, msg, w) {
  if ( typeof PopUp == "undefined" || !PopUp.ready ) return;
  PopUp.clearTimer();
  var tip = document.getElementById? document.getElementById(PopUp.tipID): null;
  if ( tip && tip.onmouseout == null ) {
		tip.onmouseout = PopUp.tipOutCheck;
		tip.onmouseover = PopUp.clearTimer;
  }
  PopUp.show(e, msg, w);
}

function hideTip() {
  if ( typeof PopUp == "undefined" || !PopUp.ready ) return;
  PopUp.timerId = setTimeout("PopUp.fadeout()", 100);
}

// Removes the titles from the hover links that appear when JS is disabled
function nullLinks() {
	hoverLinks = document.getElementsByTagName("a");
	for (var i=0; i < hoverLinks.length; i++)	{
		if (hoverLinks[i].className == "rollover") { 
			//alert(hoverLinks[i].getAttribute("title"));
			hoverLinks[i].setAttribute("title","");
		}
	}
}

pu_event.add(window, "unload", PopUp.unHookHover, true);

// adjust horizontal and vertical offsets here
// (distance from mouseover event which activates PopUp)
PopUp.offX = 20;  
PopUp.offY = -2;
PopUp.followMouse = false;  // must be turned off for hover-tip

/* Handle resize event for Glossary popup */
function resizeGlossary() {
	if ($('#glossary') && $('#alphabet') && $('#definitions')) {
		var offset = 34;
		var availWidth = 0, availHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
			availWidth = window.innerWidth;
			availHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
			availWidth = document.documentElement.clientWidth;
			availHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
			availWidth = document.body.clientWidth;
			availHeight = document.body.clientHeight;
		}
		var topHeight = $('h1').height() + $('#alphabet').height();
		var bodyHeight = availHeight - topHeight - offset;
		$('#definitions').height(bodyHeight);
	}
}
$(window).load(function(e){ resizeGlossary(); });
$(window).resize(function(e){ resizeGlossary(); });

// IFRAME RESIZING FUNCTIONS
function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}
function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    var offset = 30;
    if (docHt) iframeEl.style.height = docHt + offset + "px";
  }
}    

//try{document.domain = "regence.com";} catch(e){}

