var minFontSize=8;
var maxFontSize=18;
var currFontSize=11;
var defaultFontSize=currFontSize;
var ie=0;

function fixFrames() {
  if(ie && ie < 5){
    /* Don't use frames if < IE5.5 */
  }
  else {
    if (parent.location.href == self.location.href)
    {
      window.location.href = 'puremed.htm';
    }
    var topPath = top.location.href;
    var topPath = topPath.substring(topPath.lastIndexOf('/') + 1);
    if (topPath != 'puremed.htm')
    {
      top.location.href = 'puremed.htm';
    }
  }
};

function getScrollTop()
{
  var ScrollTop = document.body.scrollTop;
  if (ScrollTop == 0)
  {
      if (window.pageYOffset)
      {
        ScrollTop = window.pageYOffset;
      }
      else
      {
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
      }
  }
  if(parseInt(ScrollTop)>262)
  {
		var closeXObj = new getObj("closeContactX");
		var closeX2Obj = new getObj("closeContactX2");
		if(closeXObj.obj && closeX2Obj.obj)
		{
			closeXObj.style.display="none";
			closeX2Obj.style.display="block";
		}
  }
  else
  {
		var closeXObj = new getObj("closeContactX");
		var closeX2Obj = new getObj("closeContactX2");
		if(closeXObj.obj && closeX2Obj.obj)
		{
			closeXObj.style.display="block";
			closeX2Obj.style.display="none";
		}
  }
  var gettingScroll = setTimeout("getScrollTop()",100);
  return ScrollTop;
};

window.onload=getFontSize;

function writeFontControls()
{
  document.write('<div id="page_options"><p><a href="javascript:void(0);" tabindex="0" onclick="fontplus()" title="increase font size">&nbsp;[+]&nbsp;</a> font size <a href="javascript:void(0);" tabindex="0" onclick="fontminus()" title="reduce font size">&nbsp;[-]&nbsp;</a> <a href="javascript:void(0);" tabindex="0" onclick="fontreset()" title="reset font size">&nbsp;[reset]&nbsp;</a></p></div>');
};

function getFontSize()
{
  if(cookies) {
    //alert("if(cookies)=true");
    GetCookie('fontsize');
    var fontSize = GetCookie('fontsize');
    //alert("fontSize = " + fontSize);
    if(fontSize == null) {
      SetCookie('fontsize',currFontSize);
      //alert("fontSize = null; set to: " + currFontSize);
    }
    else if (parseInt(fontSize)<=18 && parseInt(fontSize)>=8) {
      currFontSize = fontSize;
      //alert("currFontSize = fontSize: " + fontSize);
    }
  }
  else if(top.fraVariables)
  {
    //alert("if(cookies)=false; top.fraVariables=true");
    currFontSize = top.fraVariables.pageFontSize;
  }
  setFontSize();
  getScrollTop();
};

function setFontSize()
{
  document.body.style.fontSize = currFontSize+'px';
  if(cookies) {
    SetCookie('fontsize',currFontSize);
  }
};

function fontplus()
{
  if(currFontSize<maxFontSize)
    { currFontSize++; }
  if(top.fraVariables)
  {
    top.fraVariables.pageFontSize = currFontSize;
  }
  setFontSize();
};

function fontreset()
{
  currFontSize=defaultFontSize;
  if(top.fraVariables)
  {
    top.fraVariables.pageFontSize = currFontSize;
  }
  setFontSize();
};

function fontminus()
{
  if(currFontSize>minFontSize)
    { currFontSize--; }
  if(top.fraVariables)
  {
    top.fraVariables.pageFontSize = currFontSize;
  }
  setFontSize();
};

/***************************************************************/

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var args = arguments;
  var argl = arguments.length;
  var expires = (argl > 2) ? args[2] : null;
  var path = (argl > 3) ? args[3] : null;
  var domain = (argl > 4) ? args[4] : null;
  var secure = (argl > 5) ? args[5] : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var expDays = 364;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

var cookies;
SetCookie('test','true');
if (GetCookie( 'test' )) {
	cookies = 1;
	DeleteCookie('test');
}
else{	
  cookies = 0;
}


