$.fn.qtip.styles.dixie = { // Last part is the name of the style
	width: 100,
	corner: {
		target: 'leftMiddle',
		tooltip: 'bottomMiddle'
	},
	name: 'light',
	tip: 'leftTop',
	width: {max: 300},
	border: {
		width: 3,
		radius: 2,
		color: '#879EBC'
	}
}
$.fn.qtip.styles.dixie_error = { // Last part is the name of the style
	width: 100,
	corner: {
		target: 'leftMiddle',
		tooltip: 'bottomMiddle'
	},
	name: 'light',
	tip: 'leftTop',
	width: {max: 300},
	border: {
		width: 3,
		radius: 2,
		color: '#760F12'
	}
}
function create_tooltips(obj_id){
	
//	console.log("running create_tooltips for " + obj_id);
	$("#" + obj_id + " .form_tooltip").each(function(){
			input_name = $(this).parent().attr('id').replace(/(.*?)_div/,'$1');
			style_name = 'dixie';
			if(this.className.search('tooltip_error') > 0)
			{
//				console.log(input_name + " has error");
				style_name = 'dixie_error';
			}
			$(this).parent().find("*[id='"+input_name+"_input']").qtip({
				content: this.innerHTML.replace(/&nbsp;/g,' '),
				show: "focus",
				hide: "blur",
				style: style_name
			});
		});
	$("#" + obj_id + " .form_checkbox_tooltip, #" + obj_id + " .form_radio_tooltip").each(function(){
//		input_name = $(this).parent().attr('id').replace(/(.*?)_div/,'$1');
		style_name = 'dixie';
		if(this.className.search('tooltip_error') > 0)
		{
			style_name = 'dixie_error';
		}
		$(this).parent().find("div").qtip({
			
				content: this.innerHTML.replace(/&nbsp;/g,' '),
				show: "mouseover",
				hide: {delay:1000, when:"mouseout", fixed: true},
				style: style_name
		});
	});
//	console.log("done running create_tooltips for " + obj_id);
}
function destroy_tooltips(obj_id){
//	console.log("destroying tooltips from "+obj_id);	
	$("#" + obj_id + " .form_tooltip").each(function(){
			input_name = $(this).parent().attr('id').replace(/(.*?)_div/,'$1');
//			console.log("deleting " + input_name);
			$(this).parent().find("*[id='"+input_name+"_input']").qtip("destroy");
		});
	//because qtips were created differently for radios and checkboxes, need to destroy them differently too
	$("#" + obj_id + " .form_checkbox_tooltip, #" + obj_id + " .form_radio_tooltip").each(function(){
		$(this).parent().find("div").qtip("destroy");
	});
//	console.log("finished destroying tooltips from "+obj_id);
}
function attach_session_changer(obj_id,calling_page)
{
	if(!calling_page)
	{
		calling_page = document.referrer;//not sure if this works
	}
//	console.log("attach_session_changer("+obj_id+","+calling_page+")");
	$("#"+obj_id+" input:not(:checkbox), #"+obj_id+" textarea, #"+obj_id+" select").bind('change',function(e){
//		console.log($(this));
		ajax(calling_page,null,'&ajax=true&update_session=true&input='+ $(this).attr('rel') +'&value=' + this.value.replace(/&/g,'%26'),null,true);
	});
	$("#"+obj_id+" input:checkbox").bind('change',function(e){
		var values = new Object();
		var serial_values = "";
		$(this).parent().parent().find(".form_checkbox > input").each(function(){
			if(this.checked)
			{
				values[this.value] = true;	
			}
		});
		serial_values = serialize(values).replace(/&/g,"%26");
//		console.log(serial_values,"serial_values");
		ajax(calling_page,null,'ajax=true&update_session=true&input='+ $(this).attr('rel') +'&value=' + serial_values,null,true);
	});
//	console.log("end attach_session_changer calling_page: " + calling_page);
}
function confirm_reset(message)
{
	if(!message)
	{
		message = "Reset all form fields?";
	}
	return window.confirm(message);
}
function focus_id(obj_id)
{
	var this_input = document.getElementById(obj_id);
//	console.log(this_input.nodeName);
	this_input.focus();	
}
function error_window(content)
{
//maybe I'll do this later
}