function Delete(id,formname)
{
	if (formname.length==0)
	{
		formname='SubAction';
	}
	document.formname.sub_action.value	= 'delete';
	document.formname.thing_id.value	= id;
	document.formname.submit();
}

function Save(formname)
{
	if (formname.length==0)
	{
		formname='SubAction';
	}
	document.formname.sub_action.value	= 'save';
	document.formname.submit();
}

function View(id,formname)
{
	if (formname.length==0)
	{
		alert (1);
		formname='SubAction';
	}
	document.forms[formname].elements.sub_action.value	= 'view';
	document.forms[formname].thing_id.value	= id;
	document.forms[formname].submit();
}


function Change(id,formname)
{
	if (formname.length==0)
	{
		formname='SubAction';
	}
	document.formname.sub_action.value	= 'edit';
	document.formname.thing_id.value	= id;
	document.formname.submit();
}

function AddRow(formname, row_type)
{
	if (formname.length==0)
	{
		formname='SubAction';
	}
	if (row_type == "cv_ed")
	{
		document.forms[formname].sub_action.value	= "add_education_row";
	}
	if (row_type == "cv_work")
	{
		document.forms[formname].sub_action.value	= "add_work_row";
	}
	document.forms[formname].submit();
}

function DeleteRow(row_id,formname, row_type)
{
	if (formname.length==0)
	{
		formname='SubAction';
	}
	if (row_type == "cv_ed")
	{
		document.forms[formname].sub_action.value	= "delete_education_row";
		document.forms[formname].row_id.value	= row_id;
	}
	if (row_type == "cv_work")
	{
		document.forms[formname].sub_action.value	= "delete_work_row";
		document.forms[formname].row_id.value	= row_id;
	}
	document.forms[formname].submit();
}

function AddFavorite(formname,thing_id)
{
	if (formname.length==0)
	{
		return;
	}
	document.forms[formname].sub_action.value	= "add_favorite";
	document.forms[formname].thing_id.value		= thing_id;
	document.forms[formname].submit();
}
function RemoveFavorite(formname,thing_id)
{
	if (formname.length==0)
	{
		return;
	}
	document.forms[formname].sub_action.value	= "remove_favorite";
	document.forms[formname].thing_id.value		= thing_id;
	document.forms[formname].submit();
}
/*
function RunFor(windowCh, woid, popup)
{
	if (woid==0)
	{
		if (popup)
		{
			windowCh.focus();
		}
		return;	
	}
	
	document.WOSearch.sub_action.value	= "run_for";
	document.WOSearch.thing_id.value	= woid;
	if (popup)
	{
		windowCh.close();
	}
	document.WOSearch.submit();
}

function CancelRunFor(windowCh, woid, popup)
{
	if (woid==0)
	{
		if (popup)
		{
			windowCh.focus();
		}
		return;	
	}
	
	document.WOSearch.sub_action.value	= "cancel_run_for";
	document.WOSearch.thing_id.value	= woid;
	if (popup)
	{
		windowCh.close();
	}
	document.WOSearch.submit();
}
*/
function Set(formname, fieldname, fieldvalue, submit)
{
	document.forms[formname].elements[fieldname].value	= fieldvalue;
	if (submit)
	{
		document.forms[formname].submit();
	}
	return;	
}

function SetDelete(text, formname, fieldname, fieldvalue, submit){
  if(confirm(text))
    Set(formname, fieldname, fieldvalue, submit)
  
  return;
}

function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}

function fillDefault(el, str) {
	if (el.value=="") el.value = str
}

