$(document).ready(function(){

	function pretty_price(id_a_modifier, duree) {
		affichage = '' ;
		duree= parseInt(duree) ;
		s = duree % 60 ;
		m = (duree-s)/60 % 60 ;
		h = (duree-m*60-s)/3600 ;
		affichage = ''+h+' h '+(m<10?'0':'')+m+' m '+s+' s' ;
		$(id_a_modifier).html(affichage) ;

	}

	function cal_price() {
		var info_price = $('#infos_price').attr("value") ;
		var price = '' ;
		var pack_price = 10 ;

		price = parseFloat(info_price.substring(0, info_price.indexOf(' '))) ;
		pack_price = parseFloat($('input[name=pack][type=radio]:checked').val());

		pretty_price('#duree_appel', pack_price/price*60) ;
	}

	$("#feedback ul").innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 3500,
		type: 'random',
		containerheight: '1em',
		controlBox : 'auto'
	});

	$("#infos_price").change(function() {
		cal_price();
	}) ;
		 
	if ($('#pack li input').is(':checked')){
		$('#pack li input:checked').parent().addClass('selected');
		cal_price();
	}
	
	$('#pack li').click(function() {
		$(this).find('input').attr('checked', 'checked');
		$(this).addClass('selected');
		$(this).siblings().removeClass('selected');
		cal_price();
	}) ;
		 
	$("#firstContactDest").change( function() {

		$.ajax({
			async: false,
			type: "GET",
			url: "/fr/fr/index/getPrefix?iso=" + $("#firstContactDest").val(),
			dataType: 'text',
			success: function(status) {
				$("#firstContactIndScreen").val('+' + status);
				$("#firstContactInd").val(status);
			}
		});
	});
	/* cal_price(); */
});
