	
	function inputLabel(id, defValue, value)
	{
		var elem = document.getElementById(id);
		if(elem.value == defValue)
		{
			elem.value = value;
		}
	}

	function passwordFocus()
	{
		document.getElementById('txtPassword').style.display = 'none';
		document.getElementById('pswdPassword').style.display = '';
		document.getElementById('pswdPassword').focus();
	}
	
	function passwordBlur()
	{
		var elem = document.getElementById('pswdPassword');
		if(elem.value == '')
		{
			document.getElementById('pswdPassword').style.display = 'none';
			document.getElementById('txtPassword').style.display = '';
		}
	}
	

	function toggle(id)
	{
		var elem = document.getElementById(id);
		if(elem)
		{
			elem.style.display = (elem.style.display == 'none') ? '' : 'none';
		}
	}
	
	
	function priceChange()
	{
		var comment = document.getElementById('spnPriceComment');
		if(document.getElementById('rFree').checked)
		{
			document.getElementById('divPriceValues').style.display = 'none';
		}
		else
		{
			document.getElementById('divPriceValues').style.display = '';
			if(document.getElementById('rPerFollower').checked)
			{
				if(document.getElementById('rPriceForFollowers_100').checked)
				{
					comment.innerHTML = 'Price (per 100 followers):';	
				}
				else if(document.getElementById('rPriceForFollowers_10').checked)
				{
					comment.innerHTML = 'Price (per 10 followers):';	
				}
				else
				{
					comment.innerHTML = 'Price (per follower):';				
				}
				document.getElementById('divPrice').className = 'line em wline';
				document.getElementById('divFollowerPriceOptions').style.display = '';
			}
			else
			{
				comment.innerHTML = 'Price (per tweet):';
				document.getElementById('divPrice').className = 'line em';
				document.getElementById('divFollowerPriceOptions').style.display = 'none';
			}
		}
	}
	
	
	// Add fee counter
	$.fn.initFeeCounter = function(params)
	{
		var resultContainer = $(params.resultContainer);
		
		var showResult = function(o, result)
		{
			result = result.toFixed(2);
			o.html(result).show();
		}
		
		var updateFee = function(o)
		{
			var amount = (o.val()) ? parseFloat(o.val()) : 0;

			var fee = Math.ceil(amount * params.feeRelative * 100) / 100 + params.feeAbsolute;
			if(params.feeMax && fee > params.feeMax)
			{
				fee = params.feeMax;
			}
			
			// show result
			showResult(resultContainer, fee);
		}
		
		return this.each(function(){
			$(this).keyup(function(){
				var elem = $(this);
				updateFee(elem);
			});
			updateFee($(this));
		});
	}

	
	// init
	$(function(){
		$('#txtAddFunds').initFeeCounter({ 
			resultContainer: '#spnFeeCounter',
			feeRelative: PP_ADD_FEE_RELATIVE,
			feeAbsolute: PP_ADD_FEE_ABSOLUTE
		});
		
		$('#txtWithdrawFunds').initFeeCounter({ 
			resultContainer: '#spnFeeCounter',
			feeRelative: PP_WITHDRAW_FEE_RELATIVE,
			feeMax: PP_WITHDRAW_FEE_MAX,
			feeAbsolute: 0
		});
		
		// Add form fee
		$('#frmAddFunds').submit(function(){
			$('#txtAddFunds').val( parseFloat($('#txtAddFunds').val()) + parseFloat($('#spnFeeCounter').html()) );
		});
	});
	