/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

function popUp(URL,id,topicSelection,subtopicSelection) {
topicMyDoc=topicSelection;
subtopicMyDoc=subtopicSelection;

if (id == "videoWindow") {
w = "330";
//if (basefolder == "SLH") {
//h = "465";} 
//else {h = "440";}
h="440"
scrol = "0";
L = "360";
T = "10";
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pagevideoWindow.focus();");
	}
else if (id == "clientWindow") {
w = "340";
h = "450";
scrol = "1";
L = "10";
T = "10";
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pageclientWindow.focus();");
	}
else {
w = "330";
//if (basefolder == "SLH") {
//h = "465";} 
//else {h = "440";}
h="440"
scrol = "0";
L = "360";
T = "10";
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pageBMCWindow.focus();");
}
}





// THIS FUNCTION CONTROLS THE TEST ON THE FOLLOWING PAGE - services/diabetes_center/signs_symptoms.aspx
function diabetesTest() {
    
    var resultNum = 0;
    
    if (document.getElementById('question1').checked) {
        resultNum = resultNum + 1
    }
    if (document.getElementById('question2').checked) {
        resultNum = resultNum + 1
    }
    if (document.getElementById('question3').checked) {
        resultNum = resultNum + 1
    }
    if (document.getElementById('question4').checked) {
        resultNum = resultNum + 5
    }
    if (document.getElementById('question5').checked) {
        resultNum = resultNum + 5
    }
    if (document.getElementById('question6').checked) {
        resultNum = resultNum + 5
    }
    if (document.getElementById('question7').checked) {
        resultNum = resultNum + 5
    }
    
    document.getElementById('score').value = resultNum;
}




//Specify affected tags. Add or remove from list:
var tgs = new Array('p', 'body', 'td', 'div');

//Specify spectrum of different font sizes:
var szs = new Array( '9px','10px','11px','12px','13px','14px','15px','16px','18px','20px' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 10 ) sz = 10;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

/* ADDITIONAL SCRIPTS FOR BOOKMARKING AND PRINTING  */
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

function bookmarksite(title, url){
    if (document.all)
        window.external.AddFavorite(url, title);
    else if (window.sidebar)
        window.sidebar.addPanel(title, url, "")
}

function checkFocus(newLoc){
    var strold = newLoc
    
    var formWrap = document.getElementById("formWrap");
    var listItem = formWrap.getElementsByTagName("li");
    
    for (var i = 0; i < listItem.length; i++) {
        listItem[i].className = 'field_Nofocus';
    }

    newLoc.className = 'field_focus';
}

window.onLoad = function(){
    var formWrap = document.getElementById("formWrap");
    var listItem = formWrap.getElementsByTagName("input");
    
    for (var i = 0; i < listItem.length; i++) {
        listItem[i].onblur = 'checkFocus(this)';
    }
    newLoc.className = 'field_focus';
}

// SET FOCUS SCRIPT FOR FORMS
function setFocus(listItem) {    
    var strold = listItem 
    var formWrap = document.getElementById("formWrap");
    var listItem = formWrap.getElementsByTagName("li");
   
    for (var i = 0; i < listItem.length; i++) {
        listItem[i].className = 'field_Nofocus';
    }
    strold.className = 'field_focus';       
}

//BERYL CALL ME POPUP
function OpenCallBackWindow() {
	window.open("https://WebCallMeBack.beryl.net/WebCallMeBack.aspx?routeid=43&tz=c", "CallBackWindow", "toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=yes,HEIGHT=475,WIDTH=420,screenX=50,screenY=50,left=50,top=50");
}

function OpenWindowBCA(strPage, intScreenWidth, intScreenHeight) {	
	newWindow = window.open(strPage, "second_window", "toolbar=no,resizable=yes,scrollbars=yes,status=yes,width=" + intScreenWidth + ",height=" + intScreenHeight + ",screenX=35,screenY=35,left=35,top=35");
	newWindow.focus();
}	


// CALENDAR CONTROLS

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

// If this handler returns true then the "date" given as
// parameter will be disabled.  In this example we enable
// only days within a range of 10 days from the current
// date.
// You can use the functions date.getFullYear() -- returns the year
// as 4 digit number, date.getMonth() -- returns the month as 0..11,
// and date.getDate() -- returns the date of the month as 1..31, to
// make heavy calculations here.  However, beware that this function
// should be very fast, as it is called for each day in a month when
// the calendar is (re)constructed.
function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

// Body Mass Index Calculator
// copyright 28th April 2006, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration

function valButton(btn) {var cnt = -1;for (var i=btn.length-1; i > -1; i--) {   if (btn[i].checked) {cnt = i; i = -1;}}if (cnt > -1) return btn[cnt].value;else return null;}function stripBlanks(fld) {var result = "";var c = 0;for (i=0; i < fld.length; i++) {if (fld.charAt(i) != " " || c > 0) {result += fld.charAt(i);if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);}function calc(thisform) {var d = valButton(thisform.d);if (d == null) {alert("You must choose centimetres/kg or inches/lb");return false;}cv = d.split(',');;var h = stripBlanks(thisform.h.value);if (h == '') {alert("You must enter your height");thisform.h.focus();return false;}if (h != Number(h) || (h = Number(h*cv[0]/100)) < 1 || h > 2.5) {alert("Invalid height entered");thisform.h.focus();return false;}var w = stripBlanks(thisform.w.value);if (w == '') {alert("You must enter your weight");thisform.w.focus();return false;}if (w != Number(w) || (w = Number(w/cv[1])) < 25 || w > 250) {alert("Invalid weight entered");thisform.w.focus();return false;} thisform.f.value = Math.round(w / (h*h)*100)/100;}

function BMI(btn)
{
    try
    {
        var w = document.getElementById("w");
        var i = document.getElementById("in");
        var ft = document.getElementById("ft");
        var Result = document.getElementById("Result");
        var Message = document.getElementById("Message");
        var result = "";
        var W,I,F,H;

        if ((ft.value.toString().length == 0) || isNaN(ft.value))
            Message.innerHTML = "Please enter a valid number for height in feet.";
        else if ((i.value.toString().length == 0) || isNaN(i.value) || (new Number(i.value) < 0) || (new Number(i.value) > 11))
            Message.innerHTML = "Please enter 0-11 for inches.";
        else if ((w.value.toString().length == 0) || isNaN(w.value) || (new Number(w.value) < 1))
            Message.innerHTML = "Please enter a valid number for weight.";
         else
         {   
            F = new Number(ft.value);
            I = new Number(i.value);
            H = new Number(((F*12)+I));
            W = new Number(w.value);
            
            Message.innerHTML = "BMI for height and weight entered: " + (Math.round((W/(H*H)*703)*100)/100);
            Result.innerHTML = (Math.round((W/(H*H)*703)*100)/100);
        }
    }
    catch (e)
    {}
}