function add_tags(){
	$('.item-tags')
		.load(
			base_path+'/tag/add_tag',
				{
					item_id: $('#current-item-id').val(),
					data_set: $('#current-data-set').val()
				}
		);
}

function exec_add_tags(){
	$('.item-tags')
		.load(
			base_path+'/tag/exec_add_tag',
				{
					item_id: $('#current-item-id').val(),
					update_tags: $('#edit-tags').val(),
					data_set: $('#current-data-set').val()
				}
		);
}

function add_youtube(){
	$('#add-youtube').hide();
	$('#more-youtube-video').hide();
	$('#add-youtube-form').show();
}

function change_pub_mode(id){
	var temp_array = id.split('-');
	var id_number = temp_array.pop();
	var pub_or_no = temp_array.shift();
	if(pub_or_no == "public"){
		$("#public-"+id_number).empty();
		$("#public-"+id_number).text("公開");
		$("#not-public-"+id_number).empty();
		$('<a href="">非公開</a>').appendTo("#not-public-"+id_number);
	}
	if(pub_or_no == "not"){
		$("#public-"+id_number).empty();
		$('<a href="">公開</a>').appendTo("#public-"+id_number);
		$("#not-public-"+id_number).empty();
		$("#not-public-"+id_number).text("非公開");
	}
	$.ajax({
		url: base_path+'/users_homepage/update_public',
		type: "POST",
		data: {
			news2user_id: id_number,
			pub_or_no: pub_or_no
		},
		cache: false,
		dataType: 'text',
		scriptCharset: "UTF-8",
		success: function(text) {
			//alert(text);
		}
	});
	return false;
}

function change_getnews_mode(id){
	var temp_array = id.split('_');
	var id_number = temp_array.pop();
	var get_or_no = temp_array.shift();
	if(get_or_no == "getnews"){
		$("#getnews_"+id_number).empty();
		$('<img src="/img/user/btn_news_n.gif" alt="更新情報を受け取る" title="更新情報を受け取る">').appendTo("#getnews_"+id_number);
		$("#not_getnews_"+id_number).empty();
		$('<a href=""><img src="/img/user/btn_news_not_f.gif" alt="受け取らない" title="受け取らない"></a>').appendTo("#not_getnews_"+id_number);
	}
	if(get_or_no == "not"){
		$("#getnews_"+id_number).empty();
		$('<a href=""><img src="/img/user/btn_news_f.gif" alt="更新情報を受け取る" title="更新情報を受け取る"></a>').appendTo("#getnews_"+id_number);
		$("#not_getnews_"+id_number).empty();
		$('<img src="/img/user/btn_news_not_n.gif" alt="受け取らない" title="受け取らない">').appendTo("#not_getnews_"+id_number);
	}
	$.ajax({
		url: base_path+'/users_homepage/update_getnews',
		type: "POST",
		data: {
			item2user_id: id_number,
			get_or_no: get_or_no
		},
		cache: false,
		dataType: 'text',
		scriptCharset: "UTF-8",
		success: function(text) {
			//alert(text);
		}
	});
	return false;
}
		
// for top page topics view

function switch_topics_panel(no) {
	for(i=1;i<=6;i++) {
		$('a#top-tab-0'+i)
			.empty()
			.append('<img src="/img/top/tab_nv0'+i+'_df.gif" />');
		set_topics_tab_rollover(i);
	} 
	$('a#top-tab-0'+no)
		.empty()
		.append('<img src="/img/top/tab_nv0' + no + '_ac.gif" />');
	$('.topics-view').hide();
	$('#topics-panel'+no).show();
	$('.news_channel_link').hide();
	$('#news_channel_link'+no).show();
	return false;
}

function set_topics_tab_rollover(no) {
	$('a#top-tab-0'+no+' img').hover(
		function(){
			$(this).attr('src', '/img/top/tab_nv0'+no+'_ov.gif');
		},
		function(){
			$(this).attr('src', '/img/top/tab_nv0'+no+'_df.gif');
		}
	);
}

$(function(){
	$("span.public-select").click(function(){
		var id = $(this).attr('id');
		return change_pub_mode(id);
	});
	
	$("span.getnews_select").click(function(){
		var id = $(this).attr('id');
		return change_getnews_mode(id);
	});

	// for top page topics view
	for(i=2;i<=6;i++) {
		set_topics_tab_rollover(i);
	} 
	
	// youtube section of artist
	$('#add-youtube-form').hide();
	

});