/**
 * JavaScript functionality not supported by framework
 */

// clears a form field if content is text
function clearField(field, text) {
	if (field.value == text) { field.value=  ''; }
	return;
}

// fills a form with specified text if contents are empty
function fillField(field, text) {
	if (field.value.blank()) { field.value = text; }
	return;
}

// opens the popup window for the quick contact form
function callPop(id) {
  var url = '/call';
  if (id != '') { url = '/location/' + id + url; }
  window.open(url, '', 'width=600,height=455');
  return false;
}

// opens the popup window for the tutorial
function tutorialPop(id) {
  var url = '/tutorial';
  if (id != '') { url = id + url; }
  window.open(url, '', 'width=600,height=400');
  return false;
}

// opens the popup window for the tutorial
function testimonialPop() {
  var url = '/pages/testimonial';
  window.open(url, '', 'width=400,height=300');
  return false;
}

// opens the popup window for the tutorial
function testPop() {
  var url = '/pages/testimonial-test';
  window.open(url, '', 'width=400,height=300');
  return false;
}

// handles a submission to request information form
function requestInfo(id) {
  var url = '/contact-senior-helpers?';
  if (id != '') { url = '/location/' + id + url; }
  url += 'rname=' + encodeURIComponent($F('request_name'));
  url += '&remail=' + encodeURIComponent($F('request_email'));
  url += '#form';
  location.href = url;
  return false;
}

// font size changing functions
function fontSmall() {
  $(document.body).setStyle({ fontSize: '70%' });
}

function fontMedium() {
  $(document.body).setStyle({ fontSize: '80%' });
}

function fontLarge() {
  $(document.body).setStyle({ fontSize: '95%' });
}


// focus on first form element
function formFocus() {
 var forms = $$('form');
  forms[0].focusFirstElement();
  return true;
}