var display_state = "player";

function toggle_display() {
	$j.each(["player","seo_body","seo_meta","links"], function(i,display_str) {

		var div_selector = "#"+display_str+"_code";
		if(display_str == display_state) {
			$j(div_selector).show();
		}
		else {
			$j(div_selector).hide();
		}
	});
}

$j(document).ready(function(){
	
	toggle_display();
	$j("#player_id_code").focus();
	$j("#player_id_code").select();
	
    $j("#project_id_select").click(function(){
    	$j("#project_id_input").focus();
    	$j("#project_id_input").select();
    });
	
	$j('.ldt_json_link').click(function(e) {
    	e.preventDefault();
 		link = $j(e.target);
 		$j("#res_link_{{player_id}}").load(link.attr("href"));
 		$j("#res_link_{{player_id}}").show();
 		return false;
    });

    $j('#player_button').click(function(e) {
    	display_state = "player";
    	toggle_display();
    });
    $j('#seo_body_button').click(function(e) {
    	display_state = "seo_body";
    	toggle_display();
    });
    $j('#seo_meta_button').click(function(e) {
    	display_state = "seo_meta";
    	toggle_display();
    });
    $j('#links_button').click(function(e) {
    	display_state = "links";
    	toggle_display();
    });

   $j("#copy_button").click(function(e) {
 	   alert($j("#"+display_state+"_code").html());
   });
   
   $j("#player_button").click(function(){
	   $j("#player_id_code").focus();
      	$j("#player_id_code").select();
   });
	
   $j("#seo_body_button").click(function(){
   	$j("#seo_body_id_code").focus();
      	$j("#seo_body_id_code").select();
   });
   $j("#seo_meta_button").click(function(){
   	$j("#seo_meta_id_code").focus();
      	$j("#seo_meta_id_code").select();
   });
    
});


