

$(function() {
	
	$(".btn_rollover").hover(
		function () {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		}, function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		}
	);
	
	$('.header_splash_contain').cycle({
		fx: 'fade',
		timeout: 4000,
		speed: 1000
	});
	

	
	var fileMax = 3;
	
	if('input.upload'){
		$('input.upload').after('<div id="files_list"><strong>Files (maximum '+fileMax+'):</strong></div>');
	
		$("input.upload").livequery('change', function(){
			doIt(this, fileMax);
		});
		
		$("#date_complete").datepicker({
			showOn: 'button',
			buttonImage: 'calendar.gif',
			buttonImageOnly: true,
			changeMonth: true,
			changeYear: true
		});
	}

});


function doIt(obj, fm) {
	if($('input.upload').size() > fm) {alert('Max files is '+fm); obj.value='';return true;}
	$(obj).hide();
	$(obj).parent().prepend('<input type="file" class="upload" name="fileX[]" />');
	var v = obj.value;
	if(v != '') {
		$("div#files_list").append('<div>'+v+'<input type="button" class="remove" value="Delete" /></div>')
		.find("input.remove").click(function(){
			$(this).parent().remove();
			$(obj).remove();
			return true;
		});
	}

};


