$(document).ready(function() {
  var form = $(".disable-on-submit");
  form.submit(function() {
    form.find("input[type='submit']").each(function() {
      $(this).hide();
      $(this).after('<input type="button" class="cta-4 gf-btn" value="' + $(this).val() + '" />');
    });
  });
});

function clearText(el) { 
    el.value=''; 
}
function noAuto(elem) {
  elem.setAttribute("autocapitalize", "off");
  elem.setAttribute("autocorrect", "off");      
}
function fixIpad() {
  var inputs = document.getElementsByTagName("input");
  var i;
  for (i = 0; i < inputs.length; i++) {
    if (inputs[i].getAttribute("type") == "text") {
      noAuto(inputs[i]);
    }
  }
}
function netfactor() {
  var CN = "netfactor";
  var OPTS = { path: '/', expires: 7 };

  var doms = new Array ( /\/affiliate/i );
  var uri = window.location.pathname;

  var matched = false;
  for( i=0; i<doms.length; i++ ) {
    if ( uri.match( doms[i] ) ) {
      matched = true;
      break;
    }
  }

  if ( matched ) {
    $.cookie( CN, '1', OPTS );
  }

  if ( $.cookie( CN ) ) {
    var x, pageurl, tzo, ver, id, rp, prot, imgsrc, bn;
    id = 358;
    ver = 2.0;
    pageurl = document.URL;
    rp = document.referrer;
    prot = location.protocol;
    bn = navigator.appName + ' v' + navigator.appVersion;
    x = new Date();
    tzo = x.getTimezoneOffset()/60;
    imgsrc = prot + '//www.visitor-track.com/admin/loghit.asp?' + 'id=' + id + '&rp=' + escape(rp) + '&sw=' + screen.width + 
      '&sh=' + screen.height + '&pa=' + escape(pageurl) + '&bn=' + escape(bn) + '&tz=' + tzo + '&vr=' + ver;
    document.write( '<img border="0" alt="" src="' + imgsrc + '" />' );
  }

}

$(function(){
  // break out of iframes
  if (self != top) {
    top.location = self.location;
  }

  // turns off auto-capitalization and auto-correction
  fixIpad();
  
  //Smooth scrolling on internal links
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
      && location.hostname == this.hostname) {
        
        var $target = $(this.hash);
        $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
        if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 1000);
        return false;
        
      }
    }
  });
  
});

