/*ADDON TO TALK - SOUND ON EVENT (Se interface)*/
var flash;

/*ADDON TO TALK - TOOGLE BY COOCKIES*/
var talkNeverExpanded = true;
var talkExpanded = false;
var onlineUpdated = false;
var historyUpdated = false;
var str_domain = getDomain();

function expandTalk(){
	talkExpanded = true;
	talkNeverExpanded = false;
	
	Cookie.dispose( 'talk_expandedMode' );
	Cookie.write( 'talk_expandedMode', 'expanded', {duration:1, domain:str_domain, path:'/', secure:false} );	
	
	obj_talk.className = 'expanded';
	obj_history.scrollTop = obj_history.scrollHeight;
}
function collapseTalk(){
	talkExpanded = false;
	
	Cookie.dispose( 'talk_expandedMode' );
	Cookie.write( 'talk_expandedMode', 'collapsed', {duration:1, domain:str_domain, path:'/', secure:false} );	
	
	obj_talk.className = 'collapsed';
}
function toggleTalk(){
	talkExpanded ? collapseTalk(): expandTalk();
}
function getDomain(){
	str_tmp = document.location.href;
	str_tmp = str_tmp.substring( str_tmp.indexOf( '://' ) + 3 ).split( '/' )[0];
	if( str_tmp.indexOf( ':' ) > -1 ){
		str_tmp = str_tmp.substring( 0, str_tmp.indexOf( ':' ) );	
	}
	if( str_tmp.indexOf( 'www' ) == 0 ){
		str_tmp = str_tmp.substring( 3 );	
	}
	return str_tmp;
}

/*INTERFACE FROM TALK*/
num_maxMessageHistory = 20;
boo_descHistory = true;

func_talkStartedCallback = function(){
	flash = window.soundfx ? window.soundfx: window.document.soundfx	
	
	if( Cookie.read( 'talk_expandedMode' ) ){
		talkNeverExpanded = false;
		if( Cookie.read( 'talk_expandedMode' ) == 'expanded' ){
			expandTalk();
		}	
	}
};
func_onlineUpdatedCallback = function(){
	if( onlineUpdated && ( talkExpanded || talkNeverExpanded ) ){	
		try{
			flash.playSound( 'http://www.bazooka.se/wp-content/themes/bazooka/sound/select.mp3', true );
		}catch( e ){
		}		
	}
	onlineUpdated = true;
};

func_historyUpdatedCallback = function(){
	if( historyUpdated && talkNeverExpanded ){
		expandTalk();
	}
	if( historyUpdated && ( talkExpanded || talkNeverExpanded ) ){	
		try{
			flash.playSound( 'http://www.bazooka.se/wp-content/themes/bazooka/sound/beep.mp3', true );
		}catch( e ){
		}
	}
	historyUpdated = true;
};