function sbm(){
	if(document.MF.text.value == '' && document.MF.title.value == '' && document.MF.music.value == '' && document.MF.mood.value == ''){
		alert('Вы не можете добавить абсолютно пустую запись!');
		return false;
	}
	document.MF.sbm_btn.disabled=true;
	document.MF.sbm_btn.value="Идет добавление/обновление";
	return true;
}

function ch_color(color){
	document.MF.color.value="#"+color;
	expand(findObj('clr_sel'));
}
	
function test(color){
	tc = findObj('test_color');
	tc.innerHTML = "<span style='color:#"+color+"'>#"+color+"</span>";
	td = findObj('test_td');
	td.setAttribute('bgcolor', color, false);
}

function AddText(NewCode) {
document.MF.text.value+=NewCode
}

function email() {
	var txt=prompt("Введите адрес.","");
	bbfontstyle("[email="+txt+"]","[/email]");
}

function bold() {
	bbfontstyle("[b]","[/b]")
}
function italic() {
	bbfontstyle("[i]","[/i]");
}
function del() {
	bbfontstyle("[del]","[/del]");
}
function underline() {
	bbfontstyle("[u]","[/u]");
}

function acenter() {
	bbfontstyle("[center]","[/center]");
}
function aleft() {
	bbfontstyle("[left]","[/left]");
}
function aright() {
	bbfontstyle("[right]","[/right]");
}

function cut() {
	bbfontstyle("[cut=cокращено]","[/cut]");
}

function showsize(size, sel, di) {
	bbfontstyle("[size="+size+"]","[/size]");
	sel.options[di].selected=true;
}

function showfont(font, sel, di) {
	bbfontstyle("[font="+font+"]","[/font]");
	sel.options[di].selected=true;
}

function showcolor(color) {
	bbfontstyle("[color="+color+"]","[/color]");
}

function showcode() {
	bbfontstyle("[code]","[/code]");
}

function hyperlink() {
	var url=prompt("Введите URL.","http://");      
	bbfontstyle("[url="+url+"]", "[/url]");
}

function image() {
	var txt=prompt("Введите URL картинки","http://");
	var alt=prompt("Введите текст, который будет показан при наведении на картинку.","");
	if(txt!=null) {            
		bbfontstyle("[img="+'"'+txt+'"'+"]"+alt+"[/img]","");
	}	
}

function video(){
	var url = prompt("Введите URL видео","http://");
	bbfontstyle("[video]"+url,"[/video]");
}



<!-- // cloak
var submitted = 0;
// -->

function colorSelector(){
	clr = new Array();
	clr[0] = '00';
	clr[1] = '20';
	clr[2] = '40';
	clr[3] = '60';
	clr[4] = '80';
	clr[5] = 'a0';
	clr[6] = 'c0';
	clr[7] = 'ff';
	for (var i=0;i<8;i++){
	if(i==4){
			document.write('</tr><tr><td><table cellpadding="0" cellspacing="0">');
		}else{
			document.write('<td><table cellpadding="0" cellspacing="0">');
		}
		for (var j=0;j<8;j++) {
			document.write('<tr>');
			for (var k=0;k<8;k++) {
				document.write('<td bgcolor="#'+clr[i]+clr[j]+clr[k]+'"><a onmouseover="test('+"'"+clr[i]+clr[j]+clr[k]+"'"+')" href="JavaScript: ch_color('+"'"+clr[i]+clr[j]+clr[k]+"'"+')"><img src="/images/shim.gif" width="20" height="10" border="0"></a></font></td>'); 
			}
			document.write('</tr>');
		}
		document.write('</table></td>');
	}
}

function photoStoreDialog(album_id){
	divDialog.setTitle('Фото архив');
	divDialog.setSize(180,400);
	setWaitDialog(true, "Открываем фото архив");
	doLoadParser(true, 
		{'album_id':album_id != null?album_id:null}, 
		'/user/photo_store/dialog_chooser.html',
		function(debug,res){ 
			setWaitDialog(false);
			if(res.ok == 1){
			    divDialog.setContent(res.html);
			    divDialog.show();
			}else{
			    alert(res.error);
			}
		}
	);
}

function addPSImage(url, title){
	bbfontstyle('[img="'+url+'"]'+title+'[/img]', "");
	//AddText('[img="'+url+'"]'+title+'[/img]');
}


function list() {
	txt=prompt("Введите '1' для нумерованого списка или оставьте поле пустым маркированного списка.","");
	while ((txt!="") && (txt!="1") && (txt!=null)) {
		txt=prompt("ERROR!\n Неверное значение, введите '1' или оставьте поле пустым.","");
	}
	if (txt!=null) {
		if (txt=="") {
			AddTxt="\r[list]\r\n";
		} else {
			AddTxt="\r[list="+txt+"]\r";
		} 
		txt="1";
		while ((txt!="") && (txt!=null)) {
			txt=prompt("Введите элемент списка\nОставьте поле пустым для окончания списка.",""); 
			if (txt!="") {             
				AddTxt+="[*]"+txt+"\r"; 
			}                   
		} 
		AddTxt+="[/list]\r\n";
		//AddText(AddTxt); 
		bbfontstyle(AddTxt,"");
	}
}


function arrayUnique(a) {  
	var temp = [];  
   	var temp2 = [];  
   	for (c in a)  
   	temp[a[c]] = c  
	for (c in temp)  
   	temp2.push(c);  
	return temp2;  
}  

(function($){
	$(function(){
		/* Tag list container */
		$('div#userTagsCont')
		.attr('class', 'textBlock')
		.css({
			display: 'none',
			position: 'absolute',
			width: '200px',
			height: '300px'
			
		})	
		.click(function(){return false;});
				
		/* Show tags */
		$('a#showUserTags').click(function(event){
			$('#userTagsCont')
			.css({
				left: event.pageX,
				top: event.pageY
			})		
			.fadeIn();
			return false;
		});
		
		/* Tag animation, tag clicking */		
		$('div#userTagsCont li')
		.hover(
			function(){
				$(this).addClass('textBlock');
				$(this).css('font-weight', 'bold');
			},
			function(){
				$(this).removeClass('textBlock');
				$(this).css('font-weight', 'normal');
			}
		)
		.css({cursor: 'pointer'})
		.click(function(){
			var cv = $('input[name=tag]').val();
			cv = cv+','+$(this).html();
			cv = cv.replace(/,+/g, ",");
			cv = cv.replace(/^,+/, "");
			cv = cv.replace(/,+$/, "");
			
			var utags = new Array();
			var allTags = cv.split(",");
			for(var i = 0; i < allTags.length; i++){
				allTags[i] = $.trim(allTags[i]);
			}
			allTags = arrayUnique(allTags);
			$('input[name=tag]').val(allTags.join(', '));
		});
				
		/* global body onclick */
		$('body').click(function(){
			$('#userTagsCont').fadeOut();
		});
	});
})(jQuery)
