$(document).ready(function() {
	// TT styles
	$.fn.qtip.styles.te_left = {
		width: {
			min: 50,
			max: 200
		},
		background: 'black',
		'font-size': 12,
		color: 'white',
		textAlign: 'center',
		border: {
			width: 3,
			radius: 3,
			color: '#444'
		},
		tip: {
			corner: 'rightMiddle',
			size: {
				x: 4,
				y: 4
			}
		},
	   name: 'dark'
	}
	$.fn.qtip.styles.te_right = {
		width: {
			min: 50,
			max: 200
		},
		background: 'black',
		'font-size': 12,
		color: 'white',
		textAlign: 'center',
		border: {
			width: 3,
			radius: 3,
			color: '#444'
		},
		tip: {
			corner: 'leftMiddle',
			size: {
				x: 4,
				y: 4
			}
		},
	   name: 'dark'
	}
	$.fn.qtip.styles.te_top = {
		width: {
			min: 50,
			max: 200
		},
		background: 'black',
		'font-size': 12,
		color: 'white',
		textAlign: 'center',
		border: {
			width: 3,
			radius: 3,
			color: '#444'
		},
		tip: {
			corner: 'bottomMiddle',
			size: {
				x: 4,
				y: 4
			}
		},
	   name: 'dark'
	}
	$.fn.qtip.styles.te_bottom = {
		width: {
			min: 50,
			max: 200
		},
		background: 'black',
		'font-size': 12,
		color: 'white',
		textAlign: 'center',
		border: {
			width: 3,
			radius: 3,
			color: '#444'
		},
		tip: {
			corner: 'topMiddle',
			size: {
				x: 4,
				y: 4
			}
		},
	   name: 'dark'
	}
	// tooltips
	$('.podcast-title').each(function() {
		$(this).qtip({
			content: $(this).attr('rel'),
			style: 'te_left',
			position: {
			      corner: {
			         target: 'leftMiddle',
			         tooltip: 'rightMiddle'
			      }
			   }
		});
	});
	$('.podcast-icons, .podcast-latest').each(function() {
		$(this).qtip({
			content: $(this).attr('rel'),
			style: 'te_right',
			position: {
			      corner: {
			         target: 'rightMiddle',
			         tooltip: 'leftMiddle'
			      }
			   }
		});
	});
	$('.content-subscribe-element, .footerButtons a, .navButtons a, .subButton_element a').each(function() {
		$(this).qtip({
			content: $(this).attr('rel'),
			style: 'te_top',
			position: {
				target: "mouse",
				adjust: {
					x: -6
				},
			    corner: {
					target: 'topMiddle',
					tooltip: 'bottomMiddle'
				}
			}
		});
	});
	$('.top-menu-title').each(function() {
		$(this).qtip({
			content: $(this).attr('rel'),
			style: 'te_bottom',
			position: {
			      corner: {
			         target: 'bottomMiddle',
			         tooltip: 'topMiddle'
			      }
			   }
		});
	});
	
	// events
	$('#podcast-list').mouseover(function() {
		$('#podcast-listing').show();
	});
	
	$('#podcast-list').mouseout(function() {
		$('#podcast-listing').hide();
	});
	$('#headerButtons').show();
	$('#headerButtons').css({
		"margin-left": (640-37-$('#headerButtons').width())
	});
	
	// stuff
	$('#tt_newsletter').mouseup(function() {
		TINY.box.show('http://thirdear.dk/workspace/assets/subscribe.php',1,300,175,1)
	});
	//alert($('#headerButtons').width());
	//$('#subButtons').show();
	$('#tt_embed').click(function() {
		$('#embedbox').slideToggle('slow', function() {
		    // Animation complete.
		  });
	});
	$('#select_320').click(function() {
		$('.select').removeClass("active");
		$('#select_320').addClass("active");
		generateEmbed(320);
	});
	$('#select_466').click(function() {
		$('.select').removeClass("active");
		$('#select_466').addClass("active");
		generateEmbed(466);
	});
	$('#select_640').click(function() {
		$('.select').removeClass("active");
		$('#select_640').addClass("active");
		generateEmbed(640);
	});	
});
