jQuery(document).ready(function() {
	jQuery('#socialMainNav a').each(function(index) {
		jQuery(this).click(function() {
			jQuery(this).addClass('currentNav').siblings('a').removeClass('currentNav');
			jQuery('.currentTab').removeClass('currentTab');			
			jQuery('.socialNetworkTab:eq(' + index + ')').addClass('currentTab');
		});
	});
	
	// twitter footer deactivate
	jQuery('#tweetFooter a.prevSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:first').hasClass('currentPage')) {
			jQuery(this).css({
				'background-position' : '0 -65px',
				'cursor' : 'default'
			})
		}
		else {
			jQuery(this).css({
				'background-position' : '0 -97px',
				'cursor' : 'pointer'
			})
		}
	});
		
	jQuery('#tweetFooter a.nextSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:last').hasClass('currentPage')) {				
			jQuery(this).css({
				'background-position' : '-182px -65px',
				'cursor' : 'default'
			})
		}
		else {			
			jQuery(this).css({
				'background-position' : '-182px -97px',
				'cursor' : 'pointer'
			})
		}
	});
	
	// facebook footer deactivate
	jQuery('#facebookFooter a.prevSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:first').hasClass('currentPage')) {
			jQuery(this).css({
				'background-position' : '0 -130px',
				'cursor' : 'default'
			})
		}
		else {
			jQuery(this).css({
				'background-position' : '0 -163px',
				'cursor' : 'pointer'
			})
		}
	});
		
	jQuery('#facebookFooter a.nextSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:last').hasClass('currentPage')) {				
			jQuery(this).css({
				'background-position' : '-182px -130px',
				'cursor' : 'default'
			})
		}
		else {			
			jQuery(this).css({
				'background-position' : '-182px -163px',
				'cursor' : 'pointer'
			})
		}
	});
	
	// youtube footer deactivate
	jQuery('#youTubeFooter a.prevSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:first').hasClass('currentPage')) {
			jQuery(this).css({
				'background-position' : '0 -195px',
				'cursor' : 'default'
			})
		}
		else {
			jQuery(this).css({
				'background-position' : '0 -227px',
				'cursor' : 'pointer'
			})
		}
	});
		
	jQuery('#youTubeFooter a.nextSocialTab').mouseover(function() {
		if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:last').hasClass('currentPage')) {				
			jQuery(this).css({
				'background-position' : '-182px -195px',
				'cursor' : 'default'
			})
		}
		else {			
			jQuery(this).css({
				'background-position' : '-182px -227px',
				'cursor' : 'pointer'
			})
		}
	});
	
	// social pagination
	
	jQuery('.socialTabFooter a').click(function(evt) {
		
		// next page
		if (jQuery(this).hasClass('nextSocialTab')) {
			if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:last').hasClass('currentPage')) {
				evt.preventDefault();	
				return false;
			} else {
				evt.preventDefault();	
				jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage.currentPage').hide().removeClass('currentPage').next('.socialPage').show().addClass('currentPage');
			}
		}
		
		//prev page
		if (jQuery(this).hasClass('prevSocialTab')) {
			if(jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage:first').hasClass('currentPage')) {
				evt.preventDefault();	
				return false;
			} else {
				evt.preventDefault();	
				jQuery(this).parent('.socialTabFooter').prev('.socialContents').children('.socialPage.currentPage').hide().removeClass('currentPage').prev('.socialPage').show().addClass('currentPage');
			}		
		}	
	});
});
