	$(document).ready(function(){

		//Put the element here to turn TAPS into TaPS
		$("h2, li a").each(function (i) {
			$(this).html($(this).html().toLowerCase().replace('taps','T<span style="text-transform:lowercase !important;">a</span>PS'));
		});

		$("h3.download a").click(function(e){
				e.preventDefault();
			});

		$("h3.download").click(function(){
			window.open($(this).find("a").attr("href"),"_blank");
		});

		
		$("a.iframe").fancybox({
			'width' : 589,
			'height' : 600
		});

		$("a.feedback").fancybox({
			'type' : 'iframe',
			'autoDimensions' : false,
			'width' : 640,
			'height' : 420
		});
		
		$(".video_fancybox").fancybox({
			'type' : 'inline',
			//'padding' : 0,
			//'margin' : 0,
			//'onComplete' : function(){
			//	$.fancybox.resize();
			//	console.log("loaded");
			//},
			'autoScale' : true,
			'scrolling':false,
			'showNavArrows':false
		});
		
		$('#tabs div').css('display','none');
		
		$('#toptabs ul li.ta').click(function(){
			
			// Cache the clicked div ref
			var ref = $(this);
			var refDiv = $(this).attr('rel');
			
			if($(refDiv).css('display') == 'block'){
				// Hide all content
				$('#tabs').slideUp(function(){
					$('#tabs').find('div').css('display','none');
					$('#toptabs ul li.ta').removeClass('tab-over');
				});
			}else{
				// Hide all content
				$('#tabs').slideUp(function(){
					$('#tabs').find('div').css('display','none');
					$('#toptabs ul li.ta').removeClass('tab-over');
					// Show content we want
					$(ref).addClass('tab-over');
					$(refDiv).css('display','block');
					$('#tabs').slideDown();
				});
			}
			
		});
    
    if (window.location.hash == '#login') $('#green').click();
    
		$('#share > img').click(function(){
			$('#share > div').toggle(function(){
				if($('#share > div').css('display') == 'none'){
					$('#share > img').attr('src','/images/share-open.png');
				}else{
					$('#share > img').attr('src','/images/share-close.png');
				}
			});
		});

		$('.addfriend').click(function(){
			count = $('#share .friends input[type=text]').length / 2;
			extraForm = '<input type="text" name="txtFriendName'+count+'" id="txtFriendName'+count+'" placeholder="Please enter your friends name" /> <input type="text" name="txtFriendEmail'+count+'" id="txtFriendEmail'+count+'" placeholder="Please enter your friends email" />';
			$('#share .friends').append(extraForm);
		});

		$('#emailto').submit(function(e){
			e.preventDefault();
			pathname = window.location.pathname;
			errFlag = false;
			$('#emailto input[type=text]').each(function(e){
				$(this).css('background-color','#FFFFFF');
				if($(this).val() == ''){
					$(this).css('background-color','#FFFFCC');
					errFlag = true;
				}
			}); 

			if(errFlag == false){
				console.log('submit it all');
				$('#share div:first').load('/ajax/share.php',$('#emailto').serialize()+'&url='+pathname);
				console.log('complete');
			}else{
				alert('Please correct fields in yellow');
			}
		});

		$('#contact-form').submit(function(e){
			e.preventDefault();
			errFlag = false;
			$('#contact-form input[type=text]').each(function(e){
				$(this).css('background-color','#FFFFFF');
				if($(this).val() == ''){
					$(this).css('background-color','#FFFFCC');
					errFlag = true;
				}
			}); 

			if(errFlag == false){
				$('#contact-form').load('/ajax/email.php',$('#contact-form').serialize());
			}else{
				alert('Please correct fields in yellow');
			}
		});

		if(!Modernizr.input.placeholder){

			$('[placeholder]').focus(function() {
			  var input = $(this);
			  if (input.val() == input.attr('placeholder')) {
				input.val('');
				input.removeClass('placeholder');
			  }
			}).blur(function() {
			  var input = $(this);
			  if (input.val() == '' || input.val() == input.attr('placeholder')) {
				input.addClass('placeholder');
				input.val(input.attr('placeholder'));
			  }
			}).blur();
			$('[placeholder]').parents('form').submit(function() {
			  $(this).find('[placeholder]').each(function() {
				var input = $(this);
				if (input.val() == input.attr('placeholder')) {
				  input.val('');
				}
			  })
			});

		}

		$('.sub-tabs a').click(function(e){
			e.preventDefault();
			$('.sub-tabs a').removeClass('active');
			$(this).addClass('active');
			$('.tab-holder .tab-contain').css({'display':'none'});
			$('.tab-holder .' + $(this).attr('rel')).css({'display':'block'});
		});

		$('.tab-holder .tab-contain:first').css({'display':'block'});

		$('.quarterholder:first .quarter').hover(function(){
			$('.quarterholder:first .quarter').css({ 'opacity' : '0.5' });
						//$(this).fadeTo('slow', 1);
						//$('.quarterholder:first .quarter').fadeTo('fast', 0.5);

			
			
			
			
			
			$(this).css({ 'opacity' : '1' })
			
			
			
		}, function(){
			$('.quarterholder:first .quarter').css({ 'opacity' : '1' })
						//$('.quarterholder:first .quarter').fadeTo('slow', 1);

			
			
		});
		
		
		
/*	var productionthumbnails = $('.quarter');
	
	$('.quarter').live('mouseover mouseout', function(event){
		var active = $(this);
		if(event.type == 'mouseover'){
			$('.quarter').each(function(){
				if($(this).attr('id') != active.attr('id')){
					$(this).stop().fadeTo(300, 0.3);
				}
			});
		}else{
			$('.quarter').each(function(){
				if($(this).attr('id') != active.attr('id')){
					$(this).stop().fadeTo(300, 0.95);
				}
			});
		}
	});*/


		



	});
