function JSinit( page ){

  if ($("ul#slider")){
    $("ul#slider").jcarousel({scroll: 1, animation: 3800, auto: 6, wrap: 'circular' });
  }

  if (page=="error"){setTimeout('Redirect(\'error\')',4000);}
  if (page=="thanks"){setTimeout('Redirect(\'home\')',4000);}
}

function clearField(obj){if(obj.value == obj.title){obj.value="";}}
function fillField(obj){if(obj.value.length<1){obj.value=obj.title;}}
function nonALink(obj){var dest = obj.getElementsByTagName("a");dest = dest[0].href;location.href=dest;return false;}

function textsize( elem ) {
  $("#s").attr("src", "images/txt_sm.jpg");
  $("#m").attr("src", "images/txt_md.jpg");
  $("#l").attr("src", "images/txt_lg.jpg");

  var ext = (/[.]/.exec(elem.src)) ? /[^.]+$/.exec(elem.src) : undefined;
  elem.src = elem.src.replace("."+ext, "_ovr."+ext);

  switch( elem.id ){
    case "s": textResize(-1); break;
    case "m": location.reload(); break;
    case "l": textResize(1); break;
  }
}

function textResize( amnt ){
  console.log("received" + amnt);
  $('p').each(function(){
    var fontsize = parseInt($(this).css("fontSize")) + amnt + "px";
    $(this).css("fontSize", fontsize);
  });
}

function Redirect(loc){
  switch(loc){
    case "home": location.href = 'horsfall-home'; break;
    case "error": location.href = 'contact-horsfall'; break;
  }
}

