// copy to clipboard 
var clip_html;
var clip_bbcode;

function initClipboard()
{
	clip_html = new ZeroClipboard.Client();
	clip_html.setHandCursor(true);
	clip_html.addEventListener('mouseOver', copyClipboard('html'));	
	clip_html.addEventListener('complete', my_complete);
	clip_html.glue('clip_button_html');

	clip_bbcode = new ZeroClipboard.Client();
	clip_bbcode.setHandCursor(true);
	clip_bbcode.addEventListener('mouseOver', copyClipboard('bbcode'));
	clip_bbcode.addEventListener('complete', my_complete);
	clip_bbcode.glue('clip_button_bbcode');
}			

function copyClipboard(type)
{	
	var url = $F('url');
	var title = document.title;
	if (type == 'html') 
	{
		text = '<a href="' + url + '">' + title + '</a>';
		clip_html.setText(text);
	}
	else 
	{
		text = '[url=' + url + ']' + title + '[/url]';
		clip_bbcode.setText(text);
	}
}

function my_complete()
{
	$('url').select();	
}


//copy to clipboard  - my account page
function initClipboardMyAccount()
{
	clip = new ZeroClipboard.Client();
	clip.setHandCursor(true);
	clip.addEventListener('mouseOver', copyClipboardMyAccount);	
	clip.addEventListener('complete', my_completeMyAccount);
	clip.glue('clip_button');
}			

function copyClipboardMyAccount()
{			
	//copy to clipboard
	clip.setText($('url').href);		
}

function my_completeMyAccount()
{
	// nada
}

function add_reply(com_id, com_name)
{
	$('reply_com_id').value = com_id;
	$('reply_to_name').update(com_name);
	$('reply_to_id').update(com_id);
	$('reply_to').show();
	return true;
}

function hide_reply()
{
	$('reply_com_id').value = 0;
	$('reply_to').hide();
	return true;
}

function show_comment_report(id)
{
	var container_name = 'comment_report_' + id;
	new Ajax.Updater(container_name, '/bloguri/report_comment.php?com_id='+id, { method: 'post', evalScripts: true, onComplete: function(){$(container_name).show()} });
}

function close_comment_report(id)
{
	var container_name = 'comment_report_' + id;
	$(container_name).hide();
}

function send_comment_report(id)
{
	var container_name = 'comment_report_' + id;
	var rep_text = $('rep_text_'+id).value;

	if ( id == '' || id == 0 )
	{
		alert('Eroare: id-ul comentariului este gresit. Încearcă să reîncarci pagina.');
		return false;
	}

	if ( rep_text == '' )
	{
		alert('Eroare: nu a fost completat motivul!');
		$('rep_text_'+id).focus();
		return false;
	}

	var myHash = new Hash();
	myHash.set('nfo[rep_text]', rep_text);

	new Ajax.Updater('', '/bloguri/report_comment.php?com_id='+id, { method: 'post', parameters: myHash, evalScripts: true, onComplete: function(){$(container_name).show()}, onSuccess: function(transport) { $(container_name).update(transport.responseText); } });
}