// JavaScript Document

// Make sure the document is ready
$(document).ready(function() {
	
	/**
	* Adds the IE6 warning to the document
	*/
	if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
		
		$("body").prepend("<div id=\"ie6-warning\"></div>");
		$("#ie6-warning").load("/templates/default/templates/custom/ie6.php");
		
	}
	
	
	
	/**
	* Sets the date picker field
	*/
	$("input.birthdate").each(function() {
		
		var date = new Date();
		year = date.getFullYear();
		
		$(this).datepicker({
		
			changeMonth : true,
			changeYear 	: true,
			dateFormat 	: 'dd/mm/yy',
			yearRange 	: (year - 25)+':'+(year - 15),
			
			beforeShow: function(input, inst) {
				
				inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: (input.offsetWidth + 10) + 'px', zIndex: 999 });
				
			}
			
		});
		
	});
	
	
	
	/**
	* Sets the date picker field
	*/
	$("input.licencedate").each(function() {
		
		var date = new Date();
		year = date.getFullYear();
		
		$(this).datepicker({
		
			changeMonth : true,
			changeYear 	: true,
			dateFormat 	: 'dd/mm/yy',
			yearRange 	: (year - 10)+':'+year,
			
			beforeShow: function(input, inst) {
				
				inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: (input.offsetWidth + 10) + 'px', zIndex: 999 });
				
			}
			
		});
		
	});
	
	
	
	/**
	* Switches the stylesheet
	**/
		
	$('.styleswitch').click(function() {
		
		switchStylestyle(this.getAttribute("rel"));
		return false;
		
	});
	
});

