$(function() {
	
	
	// Add print header to top of page
		    //$("body").prepend("<h5 class=\"print\">Cornerstone Technologies</h5>");
		$("body").prepend("<h5 class=\"print\">Streamline Automation</h5>");
		
		// Add print footer to bottom of page
			    $("body").after("<h6 class=\"print\"><strong>Streamline Automation</strong><br />9192 52nd Avenue SE | Calgary, Alberta | Canada | T2C 5A9</h5>");



	

	$("ul#nav_487777").supersubs({ 
		minWidth:    12,   // minimum width of sub-menus in em units 
		maxWidth:    27,   // maximum width of sub-menus in em units 
		extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
			                               // due to slight rounding differences and font-family 
			}).superfish();  // call supersubs first, then superfish, so that subs are 
			                         // not display:none when measuring. Call before initialising 
			                         // containing tabs for same reason.


	$('#masthead ul li a:last').addClass('last');
	
	// Make the magic happen
	$('#slides').show();
		if($('#slides').length) {
		$('#slides').after('<div id="pager">').cycle({
			fx:     'fade',
			speed:  'slow',
			timeout: 8000,
			pager:  '#pager',
			before: function() { if (window.console) console.log(this.src); }
		});
	}

// Add a class to each slide's link			
if($('#pager').length) {
	$("#pager a:nth-child(1)").addClass('thumb-one');
	$("#pager a:nth-child(2)").addClass('thumb-two');
	$("#pager a:nth-child(3)").addClass('thumb-three');
	$("#pager a:nth-child(4)").addClass('thumb-four');
	$("#pager a:nth-child(5)").addClass('thumb-five');
	$("#pager a:nth-child(6)").addClass('thumb-six');
	$("#pager a:nth-child(7)").addClass('thumb-seven');
	$("#pager a:nth-child(8)").addClass('thumb-eight');
	$("#pager a:nth-child(9)").addClass('thumb-nine');
		$("#pager a:nth-child(10)").addClass('thumb-ten');		
		
} 


if($('.case').length) {
											// Add Class to case studies items
$('.case').hover(function() {
  $(this).addClass('hover');
}, function() {
  $(this).removeClass('hover');
});

$(".case").click(function(){
		window.location=$(this).find("a").attr("href"); return false;
	});
}


// Format date on home news callout
if($('.date').length) {
$('.date').each(function() {
var dateArray = $(this).text().split('-');
var newDay = dateArray[0];
var newMonth = dateArray[1];
var newYear = dateArray[2];
var newDateFormat = "<div class=\"month\">" + newMonth + "</div> <div class=\"day\">" + newDay + "</div> <div class=\"year\">" + newYear + "</div>";
$(this).html(newDateFormat);
});


var el = $('#news .inside');
el.html(el.html().replace(/Article:/ig, "<strong>Article:</strong><br />"));
el.html(el.html().replace(/News Release:/ig, "<strong>News Release:</strong><br />"));
el.html(el.html().replace(/Case Studies:/ig, "<strong>Case Studies:</strong><br />"));
el.html(el.html().replace(/Newsletter:/ig, "<strong>Newsletter:</strong><br />"));
el.html(el.html().replace(/Media Coverage:/ig, "<strong>Media Coverage:</strong><br />"));
}
});