
/* Text resize from devedge.netscape.com */

function ndeSetTextSize(chgsize,rs) 
{

  if (!document.documentElement || !document.body)
  {
    return;
  }

  var newSize;
  var startSize = parseInt(ndeGetDocTextSize());

  if (!startSize)
  {
    startSize = 14;
  }

  switch (chgsize)
  {
  case 'incr':
    newSize = startSize + 2;
    break;

  case 'decr':
    newSize = startSize - 2;
    break;

  case 'reset':
    if (rs) 
    {
      newSize = rs;
    } 
    else 
    {
      newSize = 14;
    }
    break;

  default:
    newSize = parseInt(ndeReadCookie('nde-textsize', true));
    if (!newSize)
    {
      newSize = startSize;
    }
    break;

  }

  if (newSize < 14) 
  {
    newSize = 14;
  }
  if (newSize > 20) 
  {
    newSize = 20;
  }

  newSize += 'px';

  document.documentElement.style.fontSize = newSize;
  document.body.style.fontSize = newSize;

  ndeCreateCookie('nde-textsize', newSize, 365, true);
}

function ndeGetDocTextSize() 
{
  if (!document.body)
  {
    return 0;
  }

  var size = 0;
  var body = document.body;

  if (body.style && body.style.fontSize)
  {
    size = body.style.fontSize;
  }
  else if (typeof(getComputedStyle) != 'undefined')
  {
    size = getComputedStyle(body,'').getPropertyValue('font-size');
  }
  else if (body.currentStyle)
  {
    size = body.currentStyle.fontSize;
  }
  return size;
}

function ndeCreateCookie(name,value,days,useLang) 
{
  var langString = '';

  var cookie = name + langString + '=' + value + ';';

  if (days) 
  {
    var date = new Date();
    var ndeMilliSecondsInDay = 86400000; // 24*60*60*1000
    date.setTime(date.getTime()+(days*ndeMilliSecondsInDay));
    cookie += ' expires=' + date.toGMTString() + ';';
  }
  cookie += ' path=/';

  document.cookie = cookie;
}

function ndeReadCookie(name, useLang) 
{
  var langString = '';

  var nameEQ = name + langString + '=';
  var ca = document.cookie.split(';');

  for(var i = 0; i < ca.length; i++) 
  {
    var c = ca[i];
    while (c.charAt(0) == ' ') 
    {
      c = c.substring(1, c.length);
    }

    if (c.indexOf(nameEQ) == 0) 
    {
      return c.substring(nameEQ.length,c.length);
    }
  }
  return null;
}

/* Set up init functions */

/*window.onload = function(e) {
  ndeSetTextSize();
 
}*/

if (window.addEventListener) //DOM method for binding an event
	window.addEventListener("load", ndeSetTextSize, false)
else if (window.attachEvent) //IE exclusive method for binding an event
	window.attachEvent("onload", ndeSetTextSize)
else if (document.getElementById) //support older modern browsers
	window.onload=ndeSetTextSize


function toggleOther(selectField, otherField)
{
	//if (selectField.options[selectField.selectedIndex].value == "- Other -")
	if (selectField.selectedIndex == (selectField.options.length - 1))
	{
		document.getElementById(otherField).style.display = "block";
		
	}
	else
	{
		document.getElementById(otherField).style.display = "none";
	}	
}

function setDateFromPopUp(aVar, aYear, aMon, aDay)
{
    setSelectedVal(eval('opener.document.getElementById(\'year' + aVar + '\')'), aYear);
    setSelectedVal(eval('opener.document.getElementById(\'month' + aVar + '\')'), aMon);
    setSelectedVal(eval('opener.document.getElementById(\'day' + aVar + '\')'), aDay);
    window.close();
    return false;
}

function setSelectedVal(aElement, aVal)
{
    for (x = 0; x < aElement.options.length; x++)
    {
        if (aElement.options[x].value == aVal)
        {
            aElement.options[x].selected = true;
            return;
        }
    }
}

function getSelectedVal(aElement)
{
    for (x = 0; x < aElement.options.length; x++)
    {
        if (aElement.options[x].selected == true)
        {
            return aElement.options[x].value;
        }
    }
    return false;
}

function popUpCalender(aVar, aYear, aMon)
{
    if ( getSelectedVal(eval('document.getElementById(\'year' + aVar + '\')')) )
    {
        aYear = getSelectedVal(eval('document.getElementById(\'year' + aVar + '\')'));
    }
    if ( getSelectedVal(eval('document.getElementById(\'month' + aVar + '\')')) )
    {
        aMon = getSelectedVal(eval('document.getElementById(\'month' + aVar + '\')'));
    }
    rest='toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars=no,resizable=no,width=300,height=180';
    newWindow=window.open('/_js/calendar/beekeeper_cal.php?var=' + aVar + '&year=' + aYear + '&month=' + aMon, 'calender_popup', rest);
    newWindow.focus();
    return false;
}

function showMap(business_id)
{
	var x = window.open('http://www.betterbankside.co.uk/map/index.php?x=532004&y=180352&showbiz=1&bizid=' + business_id, 'TravelMap', 'width=800, height=600');
	if (window.focus) {x.focus();}
	//return false;
}