function btn_link(el){
	var url = $(el).find('a').attr('href');
	if( url ) {
		window.location.assign(url);
	}
}

function calculate_tax() {
	var amount = $('#taxcal_amount').val() ? parseFloat( $('#taxcal_amount').val() ) : 0.00;
	tx1 = money_round( amount * tx1_rate , 2 );
	tx2 = money_round( (amount+tx1) * tx2_rate , 2 );
	total = amount + tx1 + tx2;
	
	$('#taxcal_tx1').val( tx1.toFixed(2) );
	$('#taxcal_tx2').val( tx2.toFixed(2) );
	$('#taxcal_total').val( total.toFixed(2) );
}

function calculate_tax_revert() {
	var total = $('#taxcalr_total').val() ? parseFloat( $('#taxcalr_total').val() ) : 0.00;
	// tx2
	var tx2 = total - ( total / ( (tx2_rate) + 1 ) );
	tx2 = money_round( tx2 );
	// tx1
	var tx1 = total - tx2 - ( ( total - tx2 ) / ( (tx1_rate) + 1 ) );
	tx1 = money_round( tx1 );
	// amount
	var amount = total - tx2 - tx1;
	$('#taxcalr_tx1').val( tx1.toFixed(2) );
	$('#taxcalr_tx2').val( tx2.toFixed(2) );
	$('#taxcalr_amount').val( amount.toFixed(2) );
	//$('#taxcalr_total').val( total.toFixed(2) );
}

function calculate_tax_res() {
	var amount = $('#taxcalres_amount').val() ? parseFloat( $('#taxcalres_amount').val() ) / 2 : 0.00;
	tx1 = money_round( amount * tx1_rate , 2 );
	tx2 = money_round( (amount+tx1) * tx2_rate , 2 );
	total = amount + tx1 + tx2;
	
	$('#taxcalres_amount2').val( amount.toFixed(2) );
	$('#taxcalres_tx1').val( tx1.toFixed(2) );
	$('#taxcalres_tx2').val( tx2.toFixed(2) );
	$('#taxcalres_total').val( total.toFixed(2) );
}

function money_round( nbr ) {
	return Math.round( nbr * 100 ) / 100;
}



/************************************************************************
 *  Utils
 ************************************************************************/

function word_limit( input , max ) {
	var value = input.value.replace(/^\s*|\s*$/g, ''); // trim
	var words = value.split(' ');
	var txt = '';
	if( words.length > max ) {
		alert('Vous avez atteint la limite de ' + max + ' mots');
		for( i=0; i<max; i++ ) {
			if( txt ) txt += ' ';
			txt += words[i];
		}
		input.value = txt;
		return false;
	} else {
		return true;
	}
}

function getel( id ) {
	var id;
	return document.getElementById(id);
}

function toggle( el ) {
	var el;
	el.style.display = (el.style.display == 'block') ? 'none' : 'block';
}

function get_scroll() {
	var scroll = 0;
	if( document.body && ( document.body.scrollTop ) ) {
		//DOM compliant
		return document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		return document.documentElement.scrollTop;
	}
}

