/*global small js only*/
$(document).ready(function() {
$(document).on('keyup keypress',  function(e){  
  if(e.keyCode == 13) {
     if( $(e.target).hasClass('noSubmit')) {
          e.preventDefault();
          return false;
    }
  }
  
});
/*dynamically bring in HI content into metatag title*/
var str = $('h1:first').text() + ' | Safercar | National Highway Traffic Safety Administration (NHTSA)';
document.title =str; 


    /*print button*/
    $('.print').click(function() {  
    window.print();  
    return false;  
    });  
    
    /*left nav highlights*/
function setActive() {
  aObj = document.getElementById('navSection').getElementsByTagName('a');
  for(i=0;i<aObj.length;i++) {
    if(document.location.href.indexOf(aObj[i].href)>=0) {
      aObj[i].className='active';
    }
  }
}

//window.onload = setActive;

/* skip link patch for chrome, mainly */
  jQuery('#jumpLinks').click(function() {
    var selector=jQuery(this).attr('href');
    if(selector) {
      jQuery(selector).attr('tabindex','-1').focus();
    }
  });
  
// Accessibility issue fix webkit browsers  keyboard events
(function(a,b,c,d) {
	for (c in a) {
		if ((d=a[c].hash)&&a[c].href==b+d&&a[c].addEventListener) {
			a[c].addEventListener('click',function(e,f,g,h) {
				if (e=(f=document).getElementById(g=this.hash.slice(1))||f.getElementsByName(g)[0]) {
					if (h=!e.getAttribute(f='tabindex')) e.setAttribute(f,-1);
					e.focus();
					if (h) e.removeAttribute(f);
				}
			});
		}
	}
})(document.links,location.href.split('#')[0]);
// -->/*Used in email a friend pop-up to allow special characters to pass*/
function openSafercarEmailWin() {
	var winLoc = window.location.href;
	document.forms["nhtsaemailform"].pageURL.value = winLoc;
	_target = document.nhtsaemailform.target;
	_colon = _target.indexOf(":");
	if (_colon != -1) {
		document.nhtsaemailform.target = _target.substring(0, _colon);
		document.nhtsaemailform.args = _target.substring(_colon + 1);
	} else if (typeof (document.nhtsaemailform.args) == "undefined") {
		document.nhtsaemailform.args = "";
	}
	if (document.nhtsaemailform.args.indexOf("{") != -1) {
		_args = document.nhtsaemailform.args.split("{");
		document.nhtsaemailform.args = _args[0];
		for ( var i = 1; i < _args.length; i++) {
			_args[i] = _args[i].split("}");
			document.nhtsaemailform.args += eval(_args[i][0]) + _args[i][1];
		}
	}
	document.nhtsaemailform.args = document.nhtsaemailform.args.replace(/ /g,
			"");
	_win = window.open('', document.nhtsaemailform.target,
			document.nhtsaemailform.args);
	if (typeof (focus) == "function")
		_win.focus();
	return true;
}
});

 // Used in email a friend pop-up to allow special characters to pass
  function openSafercarEmailWin() {
    var winLoc = window.location.href;
    document.forms["nhtsaemailform"].pageURL.value = winLoc;
    _target = document.nhtsaemailform.target;
    _colon = _target.indexOf(":");
    if (_colon != -1) {
      document.nhtsaemailform.target = _target.substring(0, _colon);
      document.nhtsaemailform.args = _target.substring(_colon + 1);
    } else if (typeof (document.nhtsaemailform.args) == "undefined") {
      document.nhtsaemailform.args = "";
    }
    if (document.nhtsaemailform.args.indexOf("{") != -1) {
      _args = document.nhtsaemailform.args.split("{");
      document.nhtsaemailform.args = _args[0];
      for ( var i = 1; i < _args.length; i++) {
        _args[i] = _args[i].split("}");
        document.nhtsaemailform.args += eval(_args[i][0]) + _args[i][1];
      }
    }
    document.nhtsaemailform.args = document.nhtsaemailform.args.replace(/ /g,
        "");
    _win = window.open('', document.nhtsaemailform.target,
        document.nhtsaemailform.args);
    if (typeof (focus) == "function")
      _win.focus();
    return true;
  }  
