function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
        anchor.getAttribute("rel") == "external")
      anchor.target = "_blank";
    }
}
window.onload = externalLinks;





jQuery(document).ready(function() {                
	
	// Open links in new window
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").click(function(){this.target = "_blank";});
	
	
	


	//form text
	$('form#enquiry input[type = "text"], form#enquiry textarea').focus(function(){
		if($(this).attr("value") == $(this).attr("title")) $(this).attr("value", "");
	});
	$('form#enquiry input[type = "text"], form#enquiry textarea').blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", $(this).attr("title"));
	});

 
  
  $('.button').append('<span class="end"><!-- --></span>');
  $('li.button-container input').css("cursor","pointer").hover(function(){$(this).addClass("inputhover");return false;},function(){$(this).removeClass("inputhover");});
  $('input.freebutton').css("cursor","pointer").hover(function(){$(this).addClass("inputhover1");return false;},function(){$(this).removeClass("inputhover1");});
  $('.button').hover(function(){
    $(this).css("background-position","0 -60px");
    $(this).find("span.end").css("background-position","-274px -90px");
    return false;
  },function(){
    $(this).css("cursor","pointer");
    $(this).css("background-position","0 0");
    $(this).find("span.end").css("background-position","-274px -30px");
  });
  
  // call to action hovers and jcarousel
  $("div#call_to_actions li, div#call_to_actions a").css("cursor","pointer");
  $("div#call_to_actions li").hover(function(){$(this).addClass('cta-over');return false;},function(){$(this).removeClass('cta-over');});
  $("div#call_to_actions a#back, div#call_to_actions a#forward").hover(function(){$(this).addClass('cta-over2');return false;},function(){$(this).removeClass('cta-over2');});
  //$("div#call_to_actions li").click(function(){window.location = $(this).find('a').attr("href");});
  jQuery.easing.easeOutQuart = function (x, t, b, c, d) {return -c * ((t=t/d-1)*t*t*t - 1) + b;};
  var intval = 8000;
  jQuery('#ctas').serialScroll({
		items: 'li',
		prev:'#call_to_actions a#back',
		next:'#call_to_actions a#forward',
		queue: false,
		interval: intval,
		duration: 1200,
		start: 0,
		force:true,
		stop: true,
		lock: false,
		jump: false,
		cycle: true,
		easing: 'easeOutQuart',
		step: 1
	});
  
  var intval2 = 6000;
  jQuery('#news-headlines').serialScroll({
		items: 'li',
		interval: intval2,
		duration: 600,
		start: 0,
		force:true,
		stop: true,
		lock: false,
		jump: false,
		cycle: true,
		easing: 'linear',
		step: 1
	});
  
 
	
  
});





 
 
 
 



