// JavaScript Document

if (typeof jQuery.data_creator.teams == 'undefined') {jQuery.data_creator.teams = {}} ;

jQuery.data_creator.teams.name_word = function(jElement, options) {
	this.jElement = jElement ;
	this.options = jQuery.extend({}, jQuery.data_creator.teams.name_word.settings, options) ;
	this.page = 0 ;
	
	if (this.options.name == '') {
		this.options.name = 'teams-name_word#' + Math.random() ;	
	}
	jQuery.data_creator.teams.name_word.stack[this.options.name]=this ;
}

jQuery.data_creator.teams.name_word.prototype.update = function(_id) {
	name_word_self = this ;
	$.ajax({
		type:'POST',
		data: {group_id:_id},
		url:name_word_self.options.data_dir+'teams/name_word/fetch_info.php',
		success:function(data) {
			name_word_self.jElement.find('.name').html(data.getElementsByTagName('name')[0].childNodes[0].nodeValue) ;
			
			name_word_self.jElement.find('.creation_time').html(data.getElementsByTagName('creation_time')[0].childNodes[0].nodeValue) ;
			
			if (data.getElementsByTagName('favorite_sentence')[0].childNodes.length != 0) {
				name_word_self.jElement.find('.favorite_sentence').html(data.getElementsByTagName('favorite_sentence')[0].childNodes[0].nodeValue) ;
			}
		}
	}) ;
}

jQuery.data_creator.teams.name_word.stack = {} ;

jQuery.data_creator.teams.name_word.settings = {
	w_index: -1,
	name: '',
	data_dir:''
} 