$(function() {
	$("#accordion").accordion({ header: '.event_h2', collapsible: true, autoHeight: false, active: false });
	$("#accordion2").accordion({ header: '.event_h3_2', collapsible: true, autoHeight: false, active: false });
	$("#accordion3").accordion({ header: '.event_h3_2', collapsible: true, autoHeight: false, active: false });
		
	$("form").submit(function () {
	if ($("#bid_amount").attr("value").length>0) {
		if (parseInt($("#bid_amount").attr("value"))<parseInt($("#min_bid").attr("value"))) {
			alert('Please enter a bid of $'+$("#min_bid").attr("value")+' or more.');
			return false;
		}
		else {
			var regExp = /[^\d]/;
			var amt = $("#bid_amount").attr("value");
			if (regExp.test(amt)) { 
				alert ('Please enter whole numbers only (i.e. '+$("#min_bid").attr("value")+').');
				return false;
			}
			else {
				var bid_confirm = confirm('Do you really want to submit this bid of $'+$("#bid_amount").attr("value")+'?');
				if (bid_confirm==true) { return true; }
				else { return false; }
			}
		}
	}
	else {
		alert('Please enter a bid of $'+$("#min_bid").attr("value")+' or more.');
		return false;
	}
	});
	
	$("#bid_amount").keyup(function() {
		var regExp = /[^\d]/;
		var amt = this.value;
		if (regExp.test(amt)) {
			$("#bid_error").html('Please enter whole numbers only (i.e. '+$("#min_bid").attr("value")+').');
			$("label").css({'color' : 'red', 'font-weight' : 'bolder'});
		}
		else {
			$("#bid_error").empty();
			$("label").css({'color' : '#000', 'font-weight' : 'normal'});
		}
	});

});

	function startBid() {
		window.location.reload();
	}
	function endBid() {
		window.location.reload();
	}
	function serverTime() { 
	    var time = null; 
	    $.ajax({url: 'http://www.portcitychurch.org/includes/serverTime.php', 
	        async: false, dataType: 'text', 
	        success: function(text) { 
	            time = new Date(text); 
	        }, error: function(http, message, exc) { 
	            time = new Date(); 
	    }}); 
	    return time; 
	}
	function refresh_bid(id)
	{
		window.location.href='http://portcitychurch.org/auction/bid.php?item='+id;
	}
