jQuery.fn.label_to_value = function(){
	jQuery.each(this, function(){
		var label = jQuery('label[for=' + jQuery(this).attr('id') + ']');
		
		if(!jQuery(this).val()){ jQuery(this).val(label.html()); }
		
		label.hide();
		
		jQuery(this).blur(function(){
			if(jQuery(this).val() == '' || jQuery(this).val() == label.text()){
				jQuery(this).val(label.text());
			}
		});
		
		jQuery(this).focus(function(){ 
			if(jQuery(this).val() == label.text()){
				jQuery(this).val('');
			}else{
				this.select();
			}
		});
	});
}

$(document).ready(function(){
  $(".label_to_value").label_to_value();
  
	$('.video-player ul li a, ul#follow-england li a, .video-tabs ul li a').click(function(e){
		e.preventDefault();
		
		$(this).parents('ul').find('.embed').hide();
		$(this).siblings('.embed').show();
	});
	
	$('.news-headlines li a, .player-list li a').hover(function(){
		$(this).parents('ol').find('img').hide();
		$(this).siblings('img').show();
	});
	
	$('.menu-with-images a').hover(function(){
		$(this).parents('ul').find('img').hide();
		$(this).siblings('img').show();
	});
	
	$('#featured-news li:not(:last-child) a').hover(function(){
		$(this).parents('ol').find('img').hide();
		$(this).siblings('img').show();
	});
	
	$('.news-with-picture li, li.hentry, .playlists li').click(function(){
		var url = $(this).find('a[rel=bookmark]').attr('href');
		
		document.location = url;
	});
	
	$('.photoroll ul li a').click(function(e){
		e.preventDefault();
		
		$('.photoroll ul').find('a').removeClass('active');
		$(this).addClass('active');
		$('.photoviewer .inner').html('<img src="/phpThumb/phpThumb.php?src=' + $(this).attr('href') + '&w=550&h=350" />');
	});
	
	$('.photoroll ul li:first-child a img').ready(function(){
		$('.photoviewer .inner').html('<img src="/phpThumb/phpThumb.php?src=' + $('.photoroll ul li:first-child a').attr('href') + '&w=550&h=350" />');	
	});
	
	$('.photoroll .carousel').jCarouselLite({ 
		visible: 6,
		scroll: 5,
		speed: 800,
		circular: false,
		btnNext: '.photos-next',
		btnPrev: '.photos-previous'
	});
	
	$('ol.gallery-archive li h3').click(function(){
		if($(this).hasClass('visible')){ $(this).removeClass('visible'); }else{ $(this).addClass('visible'); }
		
		$(this).siblings('ol').toggle('fast');
	});
	
	$('.pagination.copy').html($(document).find('.pagination').html());
	
	$('#contact-form-275 textarea, #contact-form-275 input, #s').focus(function(){
		$(this).select();
	});
});
