$(document).ready(function() {

	$(".open_code_line").click(function(){
		var rel = $(this).attr("rel");
		$("#"+rel).toggle(200);
		return false;
	});


	$("textarea").focus(function(){
		if(this.value == this.defaultValue){
			this.select();
		}
	});
	
	$(".add_to_playlist").click(function(){
		var p_title = $(this).attr("p_title");
		var p_url = $(this).attr("p_url");
		open_main("http://"+location.host+"/player/index.htm");
		setTimeout(function () {
                       opener.window.add_to_playlist(p_title, p_url);
                }, 1000);
		return false;
	});

	$(".play_now").click(function(){
		var p_title = $(this).attr("p_title");
		var p_url = $(this).attr("p_url");
		open_main("http://"+location.host+"/player/index.htm");
		setTimeout(function () {
                       opener.window.play_now(p_title, p_url);
                }, 1000);
		return false;
	});

	$(".more-link").click(function(){
		var rel = $(this).attr("rel");
		$("#more_podcasts-"+rel).toggle("slow");
		return false;
	});
	
	
});

	
	var window_handle;
	
	function open_main(page) {
		if (!opener || opener.closed) {
			var check_if_exists = window.open("",'player_popup');
			if (check_if_exists.window.location == page) {
				opener = check_if_exists;
			} else {
				opener = window.open(page,'player_popup');
			}
		}
		return true;
	}
