/** set vars **/
var urllink;
var relink;
var addthis_config = {data_use_flash: false, data_use_cookies: false}
var addthis_share = {templates: {blogger: '{{lurl}}', twitter: '{{lurl}}', typepad: '{{lurl}}', wordpress: '{{lurl}}'}}
//ZeroClipboard.setMoviePath('/assets/flash/zeroclipboard.swf');
//alert (relink);
	var thingy;
var clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
			clip.addEventListener('load', my_load);
			clip.addEventListener('mouseOver', my_mouse_over);
			clip.addEventListener('complete', my_complete);


		function my_load(client) {
			debugstr("Flash movie loaded and ready.");
		}
		
		function my_mouse_over(client) {
			// we can cheat a little here -- update the text on mouse over
			clip.setText( $('fe_text').value );
		}
		
		function my_complete(client, text) {
			debugstr("Copied text to clipboard: " + text );
		}
		
		function debugstr(msg) {
			var p = document.createElement('p');
			p.innerHTML = msg;
			$('d_debug').appendChild(p);
		}


/** format functions **/
function changeFormat(type)
{
    type = jQuery.trim(type).toLowerCase();
	switch (type)
	{
		case 'forum':
	    relink = '[URL]' + urllink + '[/URL]';
		break;
		case 'html':
	    relink = '<a href="' + urllink + '" />' + urllink + '</a>';
		break;
	    default:
		relink = urllink;
	}
    $('#link').val(relink);
    
    clip.setText(relink);
}


$('.label').live('click', function(){
var self = $(this);
$('.radio').removeClass('on');
$(this).prev('.radio').addClass('on');
changeFormat($(this).text());
});

$('.radio').live('click', function(){
var self = $(this);
$('.radio').removeClass('on');
$(this).addClass('on');
changeFormat($(this).next('.label').text());
});



/** check if username is available **/
function check_username(doc)
{
    $.get("register.php", { task: 'checkUsername',  username: doc.value },
    function(data){ $("#result").html(data) });
}