﻿// JavaScript Document
var ns4 = (document.layers) ? true:false // Netscape 4.x
var ie4 = (document.all) ? true:false // IE 4.x
var ie5 = (document.getElementById) ? true:false // Browers that really matter


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//code for popup window
function popup(url){
  cuteLittleWindow = window.open(url, "littleWindow", "location=no,width=400,height=500, resizable=1"); 
}

//function to show and hide the divs
function showHideDiv(thediv)
{
if (document.getElementById(thediv).style.display=='none')
    {
    document.getElementById(thediv).style.display = 'block';
    }
    else
    {
    document.getElementById(thediv).style.display = 'none';
    }
 }
var about_pop1 = 1;
function popup(page,popupNum)
{
    switch(page)
    {
        case 'home':
            
        break;
        case 'about':
            if(about_pop1)
            {
                document.getElementById("popup1").style.visibility = "visible";
                about_pop1 = 0;
            }
            else
            {
                document.getElementById("popup1").style.visibility = "hidden";
                about_pop1 = 1;
            }
        break;
        case 'needs':
        break;
        case 'buy':
        break;
        case 'reimbursement':
        break;
        case 'ask':
        break;
        case 'glossary':
        break;
    }
}

// displays an element 
function showElement(strName)
{ 
    if (ie5)
    {
        document.getElementById(strName).style.visibility = "visible";
        //document.getElementById(strName).style.display = "block";
    }
    else if (ns4)
    {
        document.layers[strName].visibility = "show"; 
        // for this to work with ns4, you must set your div to absolute positioning
        //else if (ns4) eval('document.'+strName+'.visibility = "show"'); // alternate method 
    }
    else if (ie4)
    {
        document.all[strName].style.visibility = "visible"; 
    }
}
// hides an element
function hideElement(strName)
{
    if (ie5)
    {
        if (document.getElementById && document.getElementById(strName) !=  null)
        {
            document.getElementById(strName).style.display = "none";
            document.getElementById(strName).style.visibility = "hidden"; 
        }
    }
    else if (ns4)
    {
        document.layers[strName].visibility = "hide"; 
        // for this to work with ns4, you must set your div to absolute positioning
        //else if (ns4) eval('document.'+strName+'.visibility = "hide"'); // alternate method
    }
    else if (ie4)
    { 
        eval(strName + '.style.visibility ="hidden"');
    } 
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array;
  for(i=0;i<(a.length-2);i+=3)
  {
   if ((x=MM_findObj(a[i]))!=null)
   {
    document.MM_sr[j++]=x;
    if(!x.oSrc)
        x.oSrc=x.src; x.src=a[i+2];
   }
  }
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=0,width=400,height=500,left = 600,top = 100');");
}

function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=0,width=400,height=360,left = 600,top = 350');");
}

var warning = false
function checkWords () {
	if(document.form.caption_field.value.split(" ").length > 52) {
		alert("Please enter only 50 words or less.");
		warning = true;
		return false;	
	}
	return true;
}

function wordCounter(){
    var wordcounter = 0;
    var textField = document.form.caption_field;
    var x = textField.value.length;
   
    if (textField.value.charAt(x) != " ")
    {
        textField.value = textField.value + "\n";
    }
    // Counts the spaces and new line characters while ignoring double spaces, usually one in between each word. 
    for (x=0; x < textField.value.length; x++) 
    { 
      if ((textField.value.charAt(x) == " " && textField.value.charAt(x-1) != " ")||(textField.value.charAt(x) == "\n" && textField.value.charAt(x-1) != "\n")) 
      {
          wordcounter = wordcounter + 1; 
      }
    }
    if (wordcounter > 50)
    {
        alert("Please enter only 50 words or less.");
		return false;
	}
	return true;
}
  
function openw(URL) {
    window.open(URL, "PDFViewer", "location=yes, directories=yes, fullscreen=no, menubar=no, status=yes, toolbar=no, width=600, height=400, scrollbars=yes");
}

function stopType () {
	if ( (document.form.caption_field.value.length > 0?document.form.caption_field.value.match (/\S+/g).length:0) > 50) {
		alert ("Please enter only 50 words or less.");
		document.form.caption_field.value = document.form.caption_field.value.substr (0,document.form.caption_field.value.length-1);
	}
}

function autotab (field,nextField) {
	if (field.value.length == field.maxLength){
		nextField.focus();
			}
}

// WARN ON LEAVE CODE
function warn_on_leave(site) {
	var msg = "\nLinks which take you out of Abbott Laboratories worldwide \n"+
	"web site are not under the control of Abbott Laboratories, \n"+
	"and Abbott Laboratories is not responsible for the contents \n"+
	"of any such site or any further links from such site. Abbott \n"+
	"Laboratories is providing these links to you only as a \n"+
	"convenience, and the inclusion of any link does not imply \n"+
	"endorsement of the linked site by Abbott Laboratories.\n\n"+ 
	"Do you wish to leave this site?";
		if (confirm(msg)) {
			window.open(site);
		} else {
			return;
		}
	}
	
	
function expandChart(collapsedID, expandedID)
{
    document.getElementById(expandedID).style.display ='block';
    document.getElementById(collapsedID).style.display ='none';    
}
	
function collapseChart(collapsedID, expandedID)
{
    document.getElementById(collapsedID).style.display ='block';
    document.getElementById(expandedID).style.display ='none';
}

function showRegistrationPopup(popupID)
{
   document.getElementById(popupID).style.display ='block';     
}

function hideRegistrationPopup(popupID)
{
   document.getElementById(popupID).style.display ='none';     
}