
function doSlider(selector, style_in, style_out, speed_in, speed_out) {
    jQuery(document).ready(function () {
        //Custom settings
        //var style_in = 'easeOutBounce';
        //var style_out = 'jswing';
        //var speed_in = 1000;
        //var speed_out = 300;

        //Calculation for corners
        var neg = Math.round(jQuery(selector).width() / 2) * (-1);
        var pos = neg * (-1);
        var out = pos * 2;

        jQuery(selector).each(function () {
            url = jQuery(this).find('a').attr('href');
            img = jQuery(this).find('img').attr('src');
            alt = jQuery(this).find('img').attr('img');

            jQuery('img', this).remove();
            jQuery(this).append('<div class="topLeft"></div><div class="topRight"></div><div class="bottomLeft"></div><div class="bottomRight"></div>');
            jQuery(this).children('div').css('background-image', 'url(' + img + ')');

            jQuery(this).find('div.topLeft').css({ top: 0, left: 0, width: pos, height: pos });
            jQuery(this).find('div.topRight').css({ top: 0, left: pos, width: pos, height: pos });
            jQuery(this).find('div.bottomLeft').css({ bottom: 0, left: 0, width: pos, height: pos });
            jQuery(this).find('div.bottomRight').css({ bottom: 0, left: pos, width: pos, height: pos });

        }).hover(function() {

            jQuery(this).find('div.topLeft').stop(false, true).animate({ top: neg, left: neg }, { duration: speed_out, easing: style_out });
            jQuery(this).find('div.topRight').stop(false, true).animate({ top: neg, left: out }, { duration: speed_out, easing: style_out });
            jQuery(this).find('div.bottomLeft').stop(false, true).animate({ bottom: neg, left: neg }, { duration: speed_out, easing: style_out });
            jQuery(this).find('div.bottomRight').stop(false, true).animate({ bottom: neg, left: out }, { duration: speed_out, easing: style_out });

        },

	function() {

	    jQuery(this).find('div.topLeft').stop(false, true).animate({ top: 0, left: 0 }, { duration: speed_in, easing: style_in });
	    jQuery(this).find('div.topRight').stop(false, true).animate({ top: 0, left: pos }, { duration: speed_in, easing: style_in });
	    jQuery(this).find('div.bottomLeft').stop(false, true).animate({ bottom: 0, left: 0 }, { duration: speed_in, easing: style_in });
	    jQuery(this).find('div.bottomRight').stop(false, true).animate({ bottom: 0, left: pos }, { duration: speed_in, easing: style_in });

	}).click(function() {

	    if (jQuery(this).find('a').length > 0) {
	        if (jQuery(this).find('a').attr('target') != "_blank") {
	            window.location = jQuery(this).find('a').attr('href');
	        }
	        else {
	            window.open(jQuery(this).find('a').attr('href'));
	        }
	    }
	});
    });
}

