function _npdNewWindow(URL,name,width,height) {
	if(screen) {
		var thisWidth = screen.width - 100;
		var thisHeight = screen.height - 150;
	} else {
		var thisWidth = 700;
		var thisHeight = 450;
	}
	if (width) thisWidth=width;
	if (height) thisHeight=height;
	if (!name) var name = 'newWindow';
	// Ensure that the popup dimensions are under 800x600
	if(thisWidth >= 800)
		thisWidth = 700;
	if(thisHeight >= 600)
		thisHeight = 450;
	window.open(URL,name,'top=50,left=50,width=' + thisWidth + ',height=' + thisHeight + ',resizable=1,scrollbars=1,location=0,toolbar=0');
}

function _npdPopupImage(image) {
	_npdNewWindow('handler.cfm?event=utilities,popupimage,main&image=' + image);
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
        if(pos=="random"){
                LeftPosition=(screen.width)?Math.floor(Math.random()*((screen.width-w)-75)):100;
                TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){
                LeftPosition=(screen.width)?(screen.width-w)/2:100;
                TopPosition=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!="center" && pos!="random") || pos==null){
                LeftPosition=0;
                TopPosition=20}

        settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
        win=window.open(mypage,myname,settings);
        if(win.focus){win.focus();}}


// this function is used for the new patient Welcome Letter		
var win=null;
function NewWindowSome(mypage,myname,w,h,scroll,pos){

        if(pos=="random"){
                LeftPosition=(screen.width)?Math.floor(Math.random()*((screen.width-w)-75)):100;
                TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){
                LeftPosition=(screen.width)?(screen.width-w)/2:100;
                TopPosition=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!="center" && pos!="random") || pos==null){
                LeftPosition=0;
                TopPosition=20}

        settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
        win=window.open(mypage,myname,settings);
        if(win.focus){win.focus();}}
		
var win=null;
function NewWindowAll(mypage,myname,w,h,scroll,pos){

        if(pos=="random"){
                LeftPosition=(screen.width)?Math.floor(Math.random()*((screen.width-w)-75)):100;
                TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){
                LeftPosition=(screen.width)?(screen.width-w)/2:100;
                TopPosition=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!="center" && pos!="random") || pos==null){
                LeftPosition=0;
                TopPosition=20}

        settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,toolbar=1,status=1,location=1,menubar=1,directories=1';
        win=window.open(mypage,myname,settings);
        if(win.focus){win.focus();}}

var win=null;
function NewWindowConstellation(mypage,myname,w,h,scroll,pos){
        if(pos=="random"){
                LeftPosition=(screen.width)?Math.floor(Math.random()*((screen.width-w)-75)):100;
                TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){
                LeftPosition=(screen.width)?(screen.width-w)/2:100;
                TopPosition=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!="center" && pos!="random") || pos==null){
                LeftPosition=0;
                TopPosition=20}

        settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,menubar=1,toolbar=1,status=1,location=1';
        win=window.open(mypage,myname,settings);
        if(win.focus){win.focus();}}		
		
// dictionary submit - new - with empty submit capture
function ClickRedirect() {
if (document.dictionary.dictsearch2.value != "")
	{
	var urlvar="handler.cfm?event=utilities,dictionary&linkWord="+document.dictionary.dictsearch2.value;
	window.open(urlvar,'NorthPoint',"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=1");
	}
else
	{
	alert("Please enter a term or phrase to search.");
	}
 }

// dictionary submit - TEMPORARY HACK FOR www.cvimed.com until they move to template9
function ClickRedirect_CVIMD() {
if (document.dictionary1.dictsearch2.value != "")
	{
	var urlvar="handler.cfm?event=utilities,dictionary&linkWord="+document.dictionary1.dictsearch2.value;
	window.open(urlvar,'NorthPoint',"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=1");
	}
else
	{
	alert("Please enter a term or phrase to search.");
	}
 }

	
// dictionary submit - original - without empty submit capture
//function ClickRedirect(){ 
//var urlvar="handler.cfm?event=utilities,dictionary&linkWord="+document.dictionary.dictsearch2.value;
//window.open(urlvar,'NorthPoint',"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=1");
//}

function goOffsite(url) {
if (confirm('This link is provided as a service, but is not part of our website. Continue?'))
	{
	offsiteWin = window.open(url,'offsiteWin','width=640,height=480,top=0,left=0,screenX=0,screenY=0,menubar=1,location=1,toolbar=1,resizable,scrollbars=1');
	}
}

/*** start code for error catching ***/
// Netscape fix resize bug Ns4
function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth ||
        document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight)
	{
     document.location = document.location;
    }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
       document.WM = new Object;
       }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
       document.WM.WM_netscapeCssFix = new Object;
       document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
       document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
       }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn();

// catch all errors...
function stopError() {return true;}
window.onerror=stopError;

/*** end code for error catching ***/

/****** begin function to display layers ******/
function showLayers(hs_layer) {
	if(document.layers)    										
		document.layers[hs_layer].visibility = "show";	 		
	else if(document.getElementById)  						   
		document.getElementById(hs_layer).style.visibility = "visible";
	else 	 													
	  	document.all[hs_layer].style.visibility = "visible";   
}	
/****** end function to display layers ******/		
	
/****** begin function to hide layers ******/
function hideLayer(hs_layer) {
	if(hs_layer != "") {
		if(document.layers)	 										
			document.layers[hs_layer].visibility = "hide";			
		else if(document.getElementById)  							
			document.getElementById(hs_layer).style.visibility = "hidden";
		else	  													
			document.all[hs_layer].style.visibility = "hidden";	 
	}	
}	
/****** end function to hide layers ******/
   
/****** begin code to display layer according to mouse coords ******/
var x,y;	
 

function doCapture() {
	if(document.layers || document.getElementById && !document.all) { 
		document.captureEvents(Event.CLICK); 
		document.captureEvents(Event.MOUSEMOVE);
	}
}
function doRelease() {
	if(document.layers || document.getElementById && !document.all) { 
		document.releaseEvents(Event.CLICK); 
		document.releaseEvents(Event.MOUSEMOVE);
	}
}

document.onmousemove = handlerPDO;
if (!document.getElementById) {
	document.onclick = handlerPDO;
}

var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1); 
var is_ie4 = (is_ie && (parseInt(navigator.appVersion) == 4) && (navigator.userAgent.toLowerCase().indexOf("msie 5.5")==-1) && (navigator.userAgent.toLowerCase().indexOf("msie 5.0")==-1) && (navigator.userAgent.toLowerCase().indexOf("msie 6.0")==-1)); 
var is_ie6 = (is_ie && (parseInt(navigator.appVersion) == 4) && (navigator.userAgent.toLowerCase().indexOf("msie 6.0")!=-1) && (navigator.userAgent.toLowerCase().indexOf("msie 5.0")==-1));
var is_mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1);  
	
function handlerPDO(evt){ 
	if(is_ie4 && !is_mac) { x = event.x; y = event.y; }
	else if(document.all) { x = event.x+document.body.scrollLeft; y = event.y+document.body.scrollTop; }
 	else { x = evt.pageX; y = evt.pageY; }
}

function clickLayer(layer_n,left_o,top_o) {	
	if(top_o == null) { top_o = 0; }
	if(left_o == null) { left_o = 0; }
	
	if(layer_n != "") {
		if (document.all) {
			document.all[layer_n].style.posLeft = x + left_o;
			document.all[layer_n].style.posTop = y + top_o;
			document.all[layer_n].style.visibility = "visible";
			
		}
		if (document.layers) {
			document.layers[layer_n].left = x + left_o;
			document.layers[layer_n].top = y + top_o;
			document.layers[layer_n].visibility = "visible";
		}
		if(document.getElementById) {
			document.getElementById(layer_n).style.left = x + left_o + "px";
			document.getElementById(layer_n).style.top = y + top_o + "px"; 							
			document.getElementById(layer_n).style.visibility = "visible";
		} 
	}
}

// Check all/uncheck all checkboxes
function CheckRows(type, field)
{
	if (type == 'checkall')
	{
		for (i = 0; i < field.length; i++)
		field[i].checked = true;
	}
	
	else if (type == 'clearall')
	{
		for (i = 0; i < field.length; i++)
		field[i].checked = false ;
	}
}
/****** end code to display layer according to mouse coords ******/	

/* Function that swaps images. */
function di20(id, newSrc) {
      var theImage = FWFindImage(document, id, 0);
      if (theImage) {
          theImage.src = newSrc;
      }
}
   
/* Functions that track and set toggle group button states. */
function FWFindImage(doc, name, j) {
      var theImage = false;
      if (doc.images) {
          theImage = doc.images[name];
      }
      if (theImage) {
          return theImage;
      }
      if (doc.layers) {
          for (j = 0; j < doc.layers.length; j++) {
              theImage = FWFindImage(doc.layers[j].document, name, 0);
              if (theImage) {
                  return (theImage);
              }
          }
      }
      return (false);
}



/*
 * Mapquest $
 */


/*
 * Browser detection code
 */
function Browser ()
{
    var name = navigator.appName;
    if (name == "Netscape")
        this.name = "ns";
    else if (name == "Microsoft Internet Explorer")
        this.name = "ie";

    this.version = navigator.appVersion;
    this.vMajor  = parseInt(this.version);
    this.isNS    = (this.name =="ns" && this.vMajor >= 4);
    this.isNS4   = (this.name =="ns" && this.vMajor == 4);
    this.isNS6   = (this.name =="ns" && this.vMajor == 5);
    this.isIE    = (this.name =="ie" && this.vMajor >= 4);
    this.isIE4   = (this.version.indexOf ('MSIE 4')   >0);
    this.isIE5   = (this.version.indexOf ('MSIE 5')   >0);
    this.isDOM   = (document.createElement
                    && document.appendChild
                    && document.getElementsByTagName) ? true : false;

    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf ("win") > - 1)
        this.platform = "win";
    else if (ua.indexOf("mac") > -1)
        this.platform = "mac";
    else
        this.platform="other";
}
var browser = new Browser;

/*
 * Map control code
 */
function Map (id, level, sessionId)
{
    this.id        = id;
    this.level     = level;
    this.sessionId = sessionId;
    this.element   = document.getElementById (id);
    this.offset_x  = 0;
    this.offset_y  = 0;

    if (this.element) {
        var el = this.element;
        this.url = el.src;
        if (browser.isDOM && !browser.isIE) {
            while (el.offsetParent) {
                this.offset_x += el.offsetLeft;
                this.offset_y += el.offsetTop;
                el = el.offsetParent;
            }
        }
    }

    this.recenter = function (x, y)
    {
        if (this.element) {
            this.element.src = this.url + "&mapbrowse=center&x=" + (x - this.offset_x) + "&y=" + (y - this.offset_y) + "&rand=" + Math.random ();
        }
    };
    this.zoom = function (level)
    {
        if (this.element) {
            this.element.src = this.url + "&mapbrowse=zoom_" + level + "&rand=" + Math.random ();
            this.level = level;
        }
    };

    this.pan = function (dir)
    {
        if (this.element) {
            this.element.src = this.url + "&mapbrowse=pan_" + dir + "&rand=" + Math.random();
        }
    };

    this.recenterzoom = function (x, y)
    {
        if (this.element) {
           this.element.src = this.url + "&mapbrowse=center_zoom&x=" + (x - this.offset_x) + "&y=" + (y - this.offset_y) + "&rand=" + Math.random ();
            if (map.level < 10) {
                ++this.level;
                showZoomState ();
                showVendor ();
            }
        }
    };

    this.identify = function (x, y)
    {
        url = window.location.protocol + "//"
            + window.location.host + window.location.pathname
            + '?template=identify&transaction=locMap&identifyIcon='
            + this.sessionId
            + '&x=' + (x - this.offset_x) + '&y=' + (y - this.offset_y);

        var width  = 255;
        var height = 255;
        infoWindow = window.open (url,
                   Math.floor (Math.random () * 100000),
                   "height=" + height + ",width=" + width + ",toolbar=no,scrollbars=no,resize=yes");
        infoWindow.moveTo ((screen.width - width) / 2, (screen.height - height) / 2);
    };
}

var map;
function mqaMapClick (e)
{
    var x, y;
    if (browser.isIE) {
        if (!(event.button == 1 || (browser.platform == "mac" && event.button == 0))) return;
        x = event.offsetX;
        y = event.offsetY;
    } else if (browser.isDOM) {
        if (e.which != 1) return;
        x = e.pageX;
        y = e.pageY;
    }

    if (document.mapClick.clickAction[0].checked) {
        // Zoom
        mqaMapZoomIn ();
    } else if (document.mapClick.clickAction[1].checked) {
        // Recenter
        map.recenter (x, y)
    } else if (document.mapClick.clickAction[2].checked) {
        // Identify Icon
        if (document.mapClick.clickAction[2].value == 'identify') {
            map.identify (x, y);
        } else {
            map.recenterzoom (x, y);
        }
    }
}

function mqaMapInit (id, level, sessionId)
{
    map = new Map (id, level, sessionId);
    if (map.element) {
        if (browser.isIE) {
            map.element.onmouseup = mqaMapClick;
        } else if (browser.isDOM) {
            map.element.addEventListener ("mouseup", mqaMapClick, true);
        }
        showZoomState ();
        showVendor ();
    }
}

function mqaMapZoom (level)
{
    if (! map) {
        alert ('you must call mqaMapInit(mapurl) before you can call this function');
    } else {
        map.zoom (level);
        showZoomState ();
        showVendor ();
    }
}

function mqaMapZoomIn (name)
{
    if (map.level < 10)
        mqaMapZoom (map.level + 1);
}
function mqaMapZoomOut (name)
{
    if (map.level > 1)
        mqaMapZoom (map.level - 1);
}

function showZoomState ()
{
    for (var i = 1; i <= 10; ++i) {
        var image = i == map.level ? 'zoom_on.gif' : 'zoom.gif';
        eval ("document.zoom" + i + ".src='images/" + image + "'");
    }
}

function showVendor ()
{
    if (! document.vendor) return;

    if ((map.level <= 10) && (map.level >= 6))
    {
      var vendImage = 'navteq.gif';
    } else {
      var vendImage = 't.gif';
    }
    eval ("document.vendor.src='images/" + vendImage + "'");
}

function mqaMapPan (dir)
{
    if (! map) {
        alert ('you must call mqaMapInit(mapurl) before you can call this function');
    } else {
        map.pan (dir);
    }
}

function wink(thecat,thestate) {	// simple show/hide div function, Alex Rehm 3/20/6
	target = document.getElementById ? document.getElementById(thecat) : document.all[thecat]
	if (thestate=='flip')	// accepted states: block, none or flip
		{	thestate= target.style.display=='block' ? 'none' : 'block';	}
	target.style.display = thestate
}
function popWin(url,w,h) {	// popup script, Alex 4/13/6
	w=window.open(url,"w","resizable=1,scrollbars=1,width="+w+",height="+h) 
	if (w)	{	w.focus()	}	// IF put in to prevent JS errors on browsers with popup blockers
	}



//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AX_RunContent(){
  var ret = AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  return ret;
}
