$(document).ready(function(){

	$('#banner').fadeTo('slow', 1.0);
	$('.player_data_wrap').fadeTo('slow', 1.0);	


//FADE VIDEO THUMB ------------------------------------------------------------------------------------------------	

	$('div.video_thumb').fadeTo('slow',0.5);
	$('div.video_thumb').hover(function() {
		$(this).stop().animate({opacity:1},800);
		return false;
	},
	function() {
		$(this).stop().animate({opacity:0.5},500);
		return false;
	});

// FADE THUMBNAILS ------------------------------------------------------------------------------------------------	
	$('ul.player_thumbs li:not(.current) a').fadeTo('fast',0.5);
	$('ul.player_thumbs li:not(.current) a').hover(function() {
		$(this).stop().animate({opacity:1},800);
		return false;
	},

	function() {
		$(this).stop().animate({opacity:0.5},500);
		return false;
	});
	
	$('ul.player_thumbs li:not(.current) a').click(function() {
		var id = this.id;
		var logo = id.substring(0,4);
		if(logo!='logo') { 
			$('#banner').fadeTo('fast', 0);
			$('.player_data_wrap').fadeTo('slow', 0);	
		}
	});
	
	
// FADE PLAYER THUMBNAILS ------------------------------------------------------------------------------------------------	
	$('ul.player_data_thumbs li:not(.current) a img').fadeTo('fast',0.5);
	$('ul.player_data_thumbs li:not(.current) a img').hover(function() {
		$(this).stop().animate({opacity:1},800);
		return false;
	},
	function() {
		$(this).stop().animate({opacity:0.5},500);
		return false;
	});

//show/hide signup form
	$('span.signup, div#signup_form h3').click(function() {
		$('div#contact').hide();
		$('div#signup_form').slideToggle('normal');
		return false;
	});
$('span.contact, div#contact h3').click(function() {
		$('div#signup_form').hide();
		$('div#contact').slideToggle('normal');
		return false;
	});
	
$('form#signupform .submit').click(function() {
			var email = $('form#signupform #signupemail').val();
			var first_name = $('form#signupform #first_name').val();
			var last_name = $('form#signupform #last_name').val();
			var code = $('form#signupform #code').val();
			
		$.ajax({  
				type: 'POST',
				url: "/form_signup.php",   
				cache: false,
				data: 'submit=y&email='+email+'&first_name='+first_name+'&last_name='+last_name+'&code='+code+'',
			 	 success: function(html){
					$('#signup_form .error').html(html);

				}
		});
		return false;
			
	});	



$('form#contactform .submit').click(function() {
			var email = $('form#contactform #contactemail').val();
			var name = $('form#contactform #name').val();
			var message = $('form#contactform #message').val();
			var contactcode = $('form#contactform #contactcode').val();
			
		$.ajax({  
				type: 'POST',
				url: "/form_contact.php",   
				cache: false,
				data: 'submit=y&email='+email+'&name='+name+'&message='+message+'&contactcode='+contactcode+'',
			 	 success: function(html){
					$('#contact .error').html(html);

				}
		});
		return false;
			
	});	
	
	
//PLAYER BIOS, PHOTOS, and VIDEO	
	
$('#bio').click(function() {
		$('#photos').css('display', "none");
		$('#uservideo').css('display', "none");
	    $('#content_slider').css('display', "block");
	});

$('#video_link').click(function() {
		$('#photos').css('display', "none");
		$('#content_slider').css('display', "none");
		$('#uservideo').css('display', "block");
		niftyplayer('niftyPlayer').pause();

	});

$('.video_thumb').click(function() {
		$('#video').css('display', "block");
		$('#video_close').css('display', "block");
		return false;
	});


$('#video_close').click(function() {
		$('#video').css('display', "none");
		$('#video_close').css('display', "none");
		return false;
	});

//PHOTO GALLERIES
$('#photos').click(function() {
		$(this).slideToggle(300);
	});
	
$("a.photos").click(function(){
	   var url = this.id;
	    $('#uservideo').css('display', "none");
	    $('#content_slider').css('display', "none");
	    $('#photos').css('display', "none");
		$('#photos img').attr('src', ''); 
		$('#photos img').attr('src', url);
	    $('#photos').css('display', "block");
	   // $('#photos').slideToggle(1000);
	});

//SCHEDULE PAGE

$("#schedule tr").click(function(){
	  var gameid = this.id;	   
	//   $('#schedule tr td').attr({class: ""});
	  // $('#schedule tr#'+gameid+':hover').attr({style: "background:none"});
	  $('#schedule tr#'+gameid+' td').fadeTo(1, 0);
	  // $('#schedule tr#'+gameid+' td').attr({class: "selected"}).fadeTo(900, 1);
	   $('#schedule tr td.selected').attr("class", "viewed");			
	  $('#schedule tr#'+gameid+' td').attr("class", "selected").fadeTo(900, 1);

	 //  $('#schedule tr:hover').attr({style: ""});
	   $('.gameinfo').css('display', "none");
	   $('#gameinfo_'+gameid+'').css('display', "block");

	   //$('#gameinfo_'+gameid+'').slideToggle(200);
	});
	
	
});



function ReverseContentDisplay(d) {
	if(document.getElementById(d).style.display == "block") { document.getElementById(d).style.display = "none"; }
	else { document.getElementById(d).style.display = "block"; }
}

function opacity(id, millisec, transparency, otherid) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
	if(document.getElementById(id).style.display == "block") { 
		for(i = transparency; i >= 0; i--) { 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; setTimeout("document.getElementById('" + id + "').style.display = 'none' ", (millisec));
		}
		setTimeout("document.getElementById('" + otherid + "').style.display = 'block' ", (millisec));
		document.getElementById('video_close').style.display = 'none';
		niftyplayer('niftyPlayer').play();
	}
	else { 
		for(i = 0; i <= transparency; i++) { 
			timer++; setTimeout("document.getElementById('" + id + "').style.display = 'block' ", (50));
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		} 
		setTimeout("document.getElementById('" + otherid + "').style.display = 'none' ", (millisec));
		setTimeout("document.getElementById('video_close').style.display = 'block' ", (millisec));
		niftyplayer('niftyPlayer').pause();
	}
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 

}

