

//swap image
function swap_img(id, new_img) {
	$('#'+id).attr({'src' : new_img});
}

function swap_bg_img(id, new_img) {
	$('#'+id).css({'background' : 'url(' + new_img + ')'});
}

function add_btn_over(id) {
	$('#'+id).css('borderColor', '#336633');
}

function add_btn_out(id) {
	$('#'+id).css('borderColor', '#DDDDDD');
}

function check_if_record_exists(table, fields, values, feedback_element) {
	//send ajax call
	
	var data_string = "table="+table;
	
	for(var f = 0; f < fields.length; f++) {
		var field = fields[f];
		var value = $('#'+values[f]).val();
		data_string += "&field_" + f + "=" + field + "&value_" + f + "=" + value;
	}
	
	$.ajax({
		url: "check_if_record_exists.php",
		data: data_string,
		success: function(data) {
			$('#'+feedback_element).html(data);
			$('#'+feedback_element).css({'visibility' : 'visible'});
		}
	});
}

function toggle_link(id, state, extra_space_arg) {
	if(browser != 'ie ie7')
	{
		if(state == 'on') {
			$('#'+id).next().css({'height' : 'auto'});
			var height_tgt = $('#'+id).parent().css('height');
			$('#'+id).next().css({'height' : '0px'});
			$('#'+id).next().animate({
				height: (Number(height_tgt.substr(0, height_tgt.length-2)) + extra_space_arg) + "px"
			}, 1000, function() {
				// Animation complete.
			});
		} else {
			$('#'+id).next().css({'height' : '0px'});
		}
	}
	else
	{
		$('#'+id).next().css({'height' : 'auto'});
	}
}

function confirm_account(user, pk, row) {
	var data_string = "&user=" + user + "&pk=" + pk;
	$.ajax({
		url: "confirm_account.php",
		data: data_string,
		success: function(data) {
			if(data == "Account Confirmed") {
				$('#confirm_' + row).html("Y");
			}
		}
	});
}
