function getPrice()
{
	var sum = 0;
	
	sum += resources['traffic'][$( '#trafficcustom' ).val()];
	sum += resources['disk'][$( '#diskcustom' ).val()];
	sum += resources['db'][$( '#dbcustom' ).val()];
	sum += resources['sites'][$( '#sitescustom' ).val()];
	sum += resources['mail'][$( '#mailcustom' ).val()];
	
	if( $( '#shellcustom[@checked]' ).length )
	{
		sum += resources['shell'][1];
	}
	
	if( $( '#cvscustom[@checked]' ).length )
	{
		sum += resources['cvs'][1];
	}
	
	return sum;
}

var months = [1,3,6,12];

$( '#trafficcustom,#diskcustom,#dbcustom,#sitescustom,#mailcustom,#shellcustom,#cvscustom' ).bind( 'change', function()
{
	calculatePrice();
});

function calculatePrice()
{
	var price = getPrice();
	
	var html = '';
	var count = 0;
	for( i in months )
	{
		if( ( months[i] * price ) >= 90 )
		{
			count++;
			html += '<option value="' + months[i] + '">' + months[i] + '</option>';
		}
	}
	
	if( count != $( '#monthscustom option' ).length )
	{
		$( '#monthscustom' ).html( html );
	}
	
	$( '#price' ).html( Math.round( price * $( '#monthscustom' ).val() ) );
}


$( '#monthscustom' ).bind( 'change', function()
{
	$( '#price' ).html( Math.round( getPrice() * $( this ).val() ) );
});

calculatePrice();