// RUDOG JS

$(function () {
	
	$('.promoinn img').css({ zIndex: '0', opacity: '0' });
	
	setTimeout( function () { rotator(1); }, 2000 );
	
	$('.teamtabs a').bind('click', changetab);
	
	$('a.lightbox').fancybox({
		'zoomSpeedIn': 500, 
		'zoomSpeedOut': 300
	}); 
	
	$('form.search input').bind('focus', function () { $(this).val('').unbind('focus'); });
	
	$('img.custom, ul.nav a.train').bind('click', alertbox);
	
});

rotator = function (num) {
	
	//$('.promoinn img').css( 'z-index', '0' );
	
	if ( num > $('.promoinn img').length) num = 1;
	
	$('#promo' + num).css({ opacity: '0', zIndex: parseInt($('#promo' + num).css('z-index')) + 1 }).fadeTo(3000, 1.0, function () {
		
		num++;
		setTimeout( function () { rotator(num); }, 5000 );
	
	});
	
}

changetab = function () {
	
	var num = $(this).attr('id').replace('fighttab', '');
	
	$('.fighter').css('display', 'none');
	
	$('#fighter' + num).css( 'display', 'block');
	
	$('.teamtabs a').removeClass('on');
	
	$(this).addClass('on');

}

alertbox = function () {
	
	$('body').append(
		
		$('<div/>').addClass('overlay').height( $(document).height() ).width( $(document).width() )
		
	);
	
	$('.overlay').css({ display: 'block', opacity: '0' }).fadeTo('slow', 0.8, function () {
		
		// Alert Box content will go here in the <div> with class "alert"
		
		$('body').append(
						 
			$('<div/>').addClass('alertwrap').height( $(document).height() ).width( $(document).width() ).append(

				'<div class="alert"><p>This feature is not available yet. Click <a href="http://barkandbite-rudog.blogspot.com/2009/09/features-coming-soon-to-rudog.html" target="_blank">here</a> for more information.</p></div>'
				
			)
			
		);
		
		var scrolls = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;	
		$('.alert').css({ top: scrolls + 50, display: 'block' });
		
		$('.alertwrap').bind('click', closeout);
		
	});
	
}

closeout = function () {
	
	$('div.overlay, div.alertwrap').remove();
	
}
