﻿function window_onload() {
    window.focus();
}

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 ) {
    // helps resize (for some) if new doc shorter than previous  
    iframeEl.style.height = "auto"; 
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

function goSetHeight(iframeName) {
  if (parent == window) return;
  // no way to obtain id of iframe object doc loaded into? no parentNode or parentElement or ...
  else {
  parent.setIframeHeight(iframeName);
  }
}

function newWindow2(the_url,win_name,the_width,the_height,bars)
{
    var final_width = (the_width == 0)? (screen.width - 20) : the_width;
    var final_height = (the_height == 0)? (screen.height - 100) : the_height;
    var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',location=no,left=470,top=5,resizable';

        the_window = window.open(the_url,win_name,settings);
    

}
function newWindow3(the_url,win_name,the_width,the_height,bars, posLeft, posTop)
{
    var final_width = (the_width == 0)? (screen.width - 20) : the_width;
    var final_height = (the_height == 0)? (screen.height - 100) : the_height;
    var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',location=no,left=' + posLeft + ',top=' + posTop + ',resizable';

        the_window = window.open(the_url,win_name,settings);
    

}
function newWindow(the_url,win_name,the_width,the_height,bars)
{
    var final_width = (the_width == 0)? (screen.width - 20) : the_width;
    var final_height = (the_height == 0)? (screen.height - 100) : the_height;
    var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',location=no,left=5,top=5,resizable';
   
//    if (the_width==1000)
//        the_window = window.open(the_url,win_name,'fullscreen=yes' );
//    else
        the_window = window.open(the_url,win_name,settings);
    
}

function roller(id,source)
{       
 var elem = document.getElementById(id);
 elem.src = "../images/" + source + '.gif';
}

function iprint(ptarget) 
{ 
    ptarget.focus(); 
    ptarget.print(); 
}

function PrintNow(url,n,w,h)
{
    newWindow('Print.aspx?URL='+url,n,w,h,'yes');
}

function hideNote()
{
    if(!bolOpen)
    {
        var elem = document.getElementById('divNote');
        elem.style.display='none';
    }
} 

var bolOpen=false;
    
function showNote(noteID)
{
    //var aaa = bolOpen;
    var elem = document.getElementById('divNote');    
    elem.style.display='block';
    
    var xmlHttp;
    try
    {    // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        
    }
    catch (e)
    {    // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {      
            try
            {       
                 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
            }
            catch (e)
            {        
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    
    xmlHttp.onreadystatechange=function()
    {
      if(xmlHttp.readyState==4)
      {
        var elem = document.getElementById('pNote');
        if(document.all)
        {
            //elem.innerText for <p>,innerHTML for <div>
            elem.innerHTML=xmlHttp.responseText;
        }
        else
        {
            //elem.textContent =xmlHttp.responseText; works, but no space at all!
            elem.innerHTML=xmlHttp.responseText;
        }
      }
    }
    xmlHttp.open("GET","ShowNote.aspx?id="+noteID,true);
    xmlHttp.send(null);
}
function showComments(noteID)
{
    //var aaa = bolOpen;
    var elem = document.getElementById('divNote');    
    elem.style.display='block';
    
    var xmlHttp;
    try
    {    // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        
    }
    catch (e)
    {    // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {      
            try
            {       
                 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
            }
            catch (e)
            {        
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    
    xmlHttp.onreadystatechange=function()
    {
      if(xmlHttp.readyState==4)
      {
        var elem = document.getElementById('pNote');
        if(document.all)
        {
            //elem.innerText for <p>,innerHTML for <div>
            elem.innerHTML=xmlHttp.responseText;
        }
        else
        {
            //elem.textContent =xmlHttp.responseText; works, but no space at all!
            elem.innerHTML=xmlHttp.responseText;
        }
      }
    }
    xmlHttp.open("GET","ShowComments.aspx?id="+noteID,true);
    xmlHttp.send(null);
}
function fnStartInterval()
{
	oInterval = window.setInterval("fnRecycle()",1000);
}

function fnRecycle()
{// Code to display seconds.
   var the_para = document.getElementById('the_time');
   if (the_para != null)
   {
       if (s < 10)
	    {
		    s = s + 1;
	    }	
	    else
	    {
		    s = 0;
	    }

       if(s<10)
	    {the_para.innerHTML = '&nbsp; ' + s;}
       else
	    {the_para.innerHTML = s;}
	}
}
function roller2(id,source) //rollover function for images
{var elem = document.getElementById(id);
// var src_string = '/UWeightLoss/images/' + source + '.gif';
var src_string = '../images/' + source + '.gif';
 elem.src = src_string;
}
//function sLoad()
//{alert('ok');
//    document.execCommand('BackgroundImageCache', false, true); 
//} 
    function ShowInfo(id)
    { 
	    var sText;
	    var sImg;
	    
	    if (id == 1)
	    {
		    sText = 'Neck – Place the tape directly under the chin so that it is parallel to the floor. Apply minimal pressure as you take the measurement.';
		    sImg = 'neck';
	    }
	    if (id == 2)
	    {
		    sText = 'Shoulder - Apply the tape snugly around the largest area of the shoulder muscles and take the measurement as the client exhales.';
		    sImg = 'shoulders';
	    }	
	    if (id == 3)
	    {
		    sText = 'Chest - Have your client place the tape measure over the largest area of their chest and parallel to the floor. Take the measurement behind them at the end of a normal expiration.';
		    sImg = 'bust';
	    }	
	    if (id == 4)
	    {
		    sText = 'Waist - Place the tape snugly over the narrowest part of the torso.';
		    sImg = 'waist';	    
	    }
	    if (id == 5)
	    {
		    sText = 'Abdominal - This measurement is taken directly over the umbilicus. Make sure the tape is placed horizontally and under the clothing. Again take the measurement after a normal expiration.';
		    sImg = 'midsection';
	    }	
	    if (id == 6)
	    {
		    sText = 'Hips - Apply the tape snugly around the largest area in the hip region. Take the measurement standing at your client’s side and make sure the tape is placed parallel to the floor.';
		    sImg = 'hips';	    
	    }			
	    if (id == 7)
	    {
		    sText = 'Thigh - Have the client rest their foot on a chair or bench. Measure half way between the bent knee and the inguinal (the line that separates the buttocks from the upper hamstring) crease located at the top of the leg.  Take the measurement at this site, placing the tape securely around the thigh.';
		    sImg = 'thighs';
	    }	
	    if (id == 8)
	    {
		    sText = 'Knee - Place the tape horizontally around the knee directly above the knee cap.';
		    sImg = 'knee';
	    }	
	    if (id == 9)
	    {
		    sText = 'Calf - Have the client rest their foot on a chair or bench, place the tape horizontally around the largest girth of the calf and take the measurement.';
		    sImg = 'calf';	    
	    }	
	    if (id == 10)
	    {
		    sText = 'Ankle - Place the tape snugly around the ankle just above the inside of the ankle bone.  Have the client position their foot at a 90º angle and take the measurement.';
		    sImg = 'ankle';
	    }
	    if (id == 11)
	    {
		    sText = 'Arm - With the elbow bent to 90º but relaxed, place the tape around the arm at a level halfway between the tip of the elbow and the top of the shoulder. Take the measurement in this area facing the side of the client.';
		    sImg = 'arm';
	    }		
	    if (id == 12)
	    {
		    sText = 'Wrist - With the elbow bent to 90º and the palm facing up, place the tape around the wrist directly above the palm.';
		    sImg = 'wrist';
	    }
	    document.getElementById('ctl00_MainContentPlaceHolder_lblDescription').innerText = sText;
	    document.getElementById('ctl00_MainContentPlaceHolder_WeightImage').src = '../images/' + sImg + '.jpg';
    }
    function SetFocusForTracker()
    {
        var id = document.getElementById('ctl00_MainContentPlaceHolder_txtNeck');
        if (id != null)
        {
            id.focus();
        }
    }
