$(escn);

if (!window.console) {
	window.console = {
		log: function() {}
	};
}

function escn() {
	var i = -1;
	var selected = $('#tabs').attr('name');
	
	$('#tabs').tabs({selected: parseInt(selected)});	
	$(".projectDetail select").each(function() {
		$(this).selectbox().bind('change', function(){
			$("#total").html(updateTotal()); 
		});
	});
	$("#total").html(updateTotal());
}

function updateTotal() {
	var s = $(".projectDetail .jquery-selectbox-currentItem"), result = 0, divider=0;
	for(i=0; i<s.length; i++) {
		var int = $(s[i]).html();
		if(int != "Rating") {
			result += parseInt(int);
			divider++;
		}
	}
	if(divider === 0) return "0";
	return Math.round(result / divider);
}
