$.noConflict();
jQuery(document).ready(function(){

	jQuery(".confirmBtn").click(function(){
		//ajax function here
		var facilityName = this.id;
		var returnedData = '';
		//alert(facilityName);
		jQuery.post('updateConfirmed.php', {facility_name: facilityName}, function(data) {
			returnedData = data;
		});
		var myButton = this;
		jQuery(this).parent().parent().fadeTo(500, 0.3, function(){
			jQuery(myButton).parent().html(returnedData);
		});
	});


	jQuery(".row").mouseover(function(){
		jQuery(this).css('background-color', '#990000');
		jQuery(this).css('color', 'white');
	});
	
	jQuery(".row").mouseout(function(){
		jQuery(this).css('background-color', 'white');
		jQuery(this).css('color', 'black');
	});
	
	jQuery(".userTable-a tr:even").css("background-color", "#ddd");
	jQuery("#tabs").tabs();
	
	jQuery("#newUserForm #submit").click(function(){
		jQuery("#newUserForm").validate({
			rules:{
				username:{required: true, minlength:5, maxlength:10}, 
				password:{required:true, minlength:5, maxlength:10},
				password2:{required:true, minlength:5, maxlength:10, equalTo: "#password"}
			}
		});
	});

	jQuery('.editlink').click(function(){
		var userID = jQuery("#userID").val();
		//alert(userID);
		jQuery.ajax({
			type: "POST",
			url: "getRolesForUser.php",
			data: "userIdEdit="+userID+"&access="+1,
			success: function(response){
				jQuery('#dialog_edit').html(response);
				jQuery("#dialogEdit .userTable-a tr:even").css("background-color", "#ddd");
			}
		});
	});
	
}); //end of document ready

function setUserID(id) {
	document.getElementById('userID').value = id;
}

function removeUser(id){
	//alert(id);
	//ajax call to remove user with id of 'id'
	
	jQuery.ajax({
			type: "POST",
			url: "removeUser.php",
			data: "userID="+id,
			success: function(response){
				jQuery("#confirmation").remove();
				jQuery('#userTableDiv-a').prepend("<p id='confirmation' class='text-a'>"+response+"</p>");
			}
	});
	
	var theID = "#"+id;
	//alert(id);
	jQuery(theID).remove();
	jQuery(".userTable-a tr").css("background-color", "#fff");
	jQuery(".userTable-a tr:even").css("background-color", "#ddd");
	dijit.byId('dialogDelete').hide(); //Dojo Library command to hide lightbox
}

