/***********************************************************************************************************************
DESCRIPTION: Adds First / Last Child etc.
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
$(document).ready(function() {
$("ul li:last-child").addClass("last");
$("ul li:first-child").addClass("first");
$("#content table tr:last-child").addClass("last");
$("#content table tr th:first-child").addClass("th-first");
$("#content table tr td:first-child").addClass("td-first");
$("#content table tr th:last-child").addClass("th-last");
$("#content table tr:even").addClass("even");
});

/***********************************************************************************************************************
DESCRIPTION: Adds text to newsletter subscription box/ clears on focus
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
$(document).ready(function(){

$("#input_1_1").val("your email address").focus(function() {

if ($(this).val() == "your email address") {
$(this).val("")
}

});
$('#input_1_1').blur(function() {

if ($(this).val() == '') {
$(this).val("your email address");
}

});

}); 


/***********************************************************************************************************************
DESCRIPTION: Clears Search Fields
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
$(document).ready(function($) {
    $("#input_1_1").focus(function(){$(this).val("");});
});

/***********************************************************************************************************************
DESCRIPTION: Adds a class "focus" to inputs, select, etc while active.
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
function focusfix(selector, className) {
$(selector).focus(function() {
$(this).addClass(className);
});

$(selector).blur(function() {
$(this).removeClass(className);
});
}

jQuery(document).ready(function($) {
focusfix('input', 'focus');
});

jQuery(document).ready(function($) {
focusfix('textarea', 'focus');
});

jQuery(document).ready(function($) {
focusfix('select', 'focus');
});

/***********************************************************************************************************************
DESCRIPTION: Filetype icons and external links
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
$(document).ready(function() {					   
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf").attr("target", "_blank");	
	// Add email icons to email links
	$("a[href$='.doc']").addClass("doc").attr("target", "_blank");
	$("a[href$='.MyCharity.ie']").addClass("mycharity").attr("target", "_blank");
	$("a[href$='.mycharity.ie']").addClass("mycharity").attr("target", "_blank");
	$("a[href$='.mycharity.ie/']").addClass("mycharity").attr("target", "_blank");
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");
	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");	
	 
});

/***********************************************************************************************************************
DESCRIPTION: jCarousel Configuration
DEVELOPED BY: 
NOTE: 
************************************************************************************************************************/
function sponsorcarousel_initCallback(carousel)
{
// Disable autoscrolling if the user clicks the prev or next button.
carousel.buttonNext.bind('click', function() {
carousel.startAuto(0);
});

carousel.buttonPrev.bind('click', function() {
carousel.startAuto(0);
});

// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
};

jQuery(document).ready(function() {
jQuery('#sponsorcarousel').jcarousel({
auto: 3,
wrap: 'last',
initCallback: sponsorcarousel_initCallback
});
});

