// JavaScript Document

// hover fix for IE 6

sfHover = function(){
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for(var i=0; i<sfEls.length; i++){
		sfEls[i].onmouseover=function(){
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function(){
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(document).ready(function(){
													 
	// FANCYBOX - Gallery
	if (typeof jQuery.fn.fancybox == 'function') {
		$('a.gallery-item').fancybox({
			'overlayOpacity': 0.7,
			'overlayColor':		'#000'
		});
	}
	
	// DATEPICKER - Calendar
	if (typeof jQuery.fn.datepicker == 'function')
		$('input.selectdate').datepicker({dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '/skin/images/icon-calendar.gif', buttonImageOnly: true});
		
	// SLIDER - FAQ Categories
		// Hide all records except the first
	$(".record").not(':first').hide();

	// Setup handler to fade in each record when the recordlink is clicked.
	$(".recordlink").click(
		function(e){
			var idField = $(this).attr('id');
			var idNum = 0;
			if (idField.match(/(\d+)$/))
			{
				idNum = RegExp.$1;
			}
				
			$('.record').hide();
			$('#record_'+idNum).fadeIn("slow");
			e.stopPropagation();
			return false;
		}
	);
	
	$('.clicknclear').click(function() {
    $(this).attr('rel', $(this).val());
    $(this).val('');
		}).blur(function() {
		if ($(this).val().length < 1)
			$(this).val($(this).attr('rel'));
  });
	
});
