
/**
 * jQuery functions library (must be loaded at foot of each page)
 * 
 * @package	Glide-Website
 * @author	SBF
 * @copyright	2011 Glide Utilities Ltd., all rights reserved
 */

$(document).ready(function() {
	
	// twitter js api
	(function(){
		if ('http:' == document.location.protocol) {
			var twitterWidgets = document.createElement('script');
			twitterWidgets.type = 'text/javascript';
			twitterWidgets.async = true;
			twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
			document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
		}
	})();

	//Analytics
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-134506-2']);
	_gaq.push(['_trackPageview']);
	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
	
	
	//closes all banner messages on the x been clicked
	$('.alert-message a.close').click(function(){$(this).parent().fadeOut('fast')});
	
	// apply datepicker function to text fields with class "datepicker"
	var d = new Date();
	$(function() {
		$("input.datepicker").datepicker({
			dateFormat: 'dd/mm/yy',
			changeMonth: true,
			changeYear: true,
			yearRange: d.getFullYear()+':'+(d.getFullYear()+1)
		});
	});
	
	// apply datepicker function with extended years to text fields with class "datepicker-dob"
	// does not allow dates to be picked that would make the user less than 18 years old
	var d = new Date();
	$(function() {
		$("input.datepicker-dob").datepicker({
			dateFormat: 'dd/mm/yy',
			changeMonth: true,
			changeYear: true,
			yearRange: (d.getFullYear()-75)+':'+(d.getFullYear()-18),
			maxDate: "-18Y"
		});
	});

	
	
	    $.extend($.ui.dialog.prototype.defaults, {
		closeOnEscape: true,
		modal: true,
		show: 'fade'
	    });

	
	// resize content pane
	resizeContentPane();

	// apply placeholders
	applyPlaceholders();
	
}); // ready function

