$(document).ready(function(){
	$.datePicker.setDateFormat('myd', '/');
	$('input.datePicker').datePicker({startDate:'01/01/2008'});
	$('a.loader').click(function(){
		var container = $(this).attr('rel');
		var path = $(this).attr('href');
		$("#" + container).load(path);
		return false;
	});
	$("a.delete").click(function(){
		var title = $(this).attr('title');
		var doDelete = confirm("Are you sure you want to remove this " + title + "?");
		if(doDelete)
		{
			return true;
		}else{
			return false;
		}
	});
	
	var currentId = $('#pageLinks #pageId').val();
	var detailLocation = '/submission/index/id/' + currentId;
	var submitLocation = '/submission/finish/id/' + currentId;
	var buttons = "";
	$('#pageLinks').html(buttons);
	$("#goToDetail").click(function(){
		window.location = detailLocation;
	});
	$("#sendSubmission").click(function(){
		window.location = submitLocation;
	});
	
	$("table.striped tr:odd").addClass('odd');
	$("input.radioGroup").click(function(){
		var name = $(this).attr('name');
		$("span#" + name).html($(this).val());
		var sum = 0;
		$("span.score").each(function(){
			var score = parseInt($(this).html());
			if(score > 0){
				sum += score;
			}
		});
		$("span#totalScore").html(sum);
	});
	$("a#searchToggler").click(function(){
		$('#additionalSearchOptions').removeClass('hidden');
	});
});