/**
 * 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 = '/location/' + id + url; }
  window.open('http://seniorhelpers.com/tutorial/', '', 'width=600,height=400');
  return false;
}

// opens the popup window for the tutorial
function homeTestimonial() {
//  var url = '/tutorial';
//  if (id != '') { url = '/location/' + id + url; }
  window.open('/testimonials/homeTestimonial.php', '', 'width=370,height=300');
  return false;
}

// opens the popup window for the tutorial
function testPop() {
//  var url = '/tutorial';
//  if (id != '') { url = '/location/' + id + url; }
  window.open('/testimonials/dr_laura.php', '', 'width=370,height=300');
  return false;
}

// opens the popup window for the tutorial
function testimonialPop() {
  var url = '/pages/testimonial';
  window.open(url, '', 'width=400,height=300');
  return false;
}

// handles a submission to request information form
function requestInfo(id) {
  var url = '/contactus.php?';
//if (id != '') { url = '/location/' + id + url; }
  url += 'fname=' + encodeURIComponent($F('request_fname'));
   url += '&lname=' + encodeURIComponent($F('request_lname'));
  url += '&cemail=' + encodeURIComponent($F('request_cemail'));
  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;
}