$(document).ready(function() {
	// Apply date picker if loaded
	if (typeof jQuery.fn.datepicker == 'function')
		$('input.selectdate').datepicker({dateFormat: 'dd/mm/yy', showOn: 'both', buttonImage: '/skin/images/icon-calendar.gif', buttonImageOnly: true});


	$('.clicknclear').click(function() {
		$(this).attr('rel', $(this).val());
		$(this).val('');
	}).blur(function() {
		if ($(this).val().length < 1)
			$(this).val($(this).attr('rel'));
	});

	/* TABS */
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	if (location.hash && location.hash.match(/^#tab/)) {
		// Activate selected tab 
		var selectedTab = location.hash;
		// Selected tab link (add active to surrounding li) - <ul class="tabs"><li><a href="#tabX">My Tab</a></li></ul>
		$("ul.tabs li a[href='" + selectedTab + "']").parent().addClass("active").show();
		// Selected tab content
		$(selectedTab).addClass('active').show();
	} else {
		// Activate first tab
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
	}

	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class from other <li>
		$(this).addClass("active"); //Add "active" class to selected tab <li>
		$(".tab_content").hide(); //Hide all tab content 

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show().fadeIn('slow'); //Fade in the active ID content
		return false;
	});

		
	

	// Expandable content areas
	$('.expand-content').hide();
	$('#expand-link').click(function (e) {
		e.preventDefault();
		$('.expand-content').fadeToggle();
	});



}); 


sfHover = function() {
	var sfEls = document.getElementById("menu").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);


