// JavaScript Document

function setActionAndSubmit(action, inForm){
//function setActionAndSubmit(){
	//alert(action);
	document.getElementById(inForm).action = action;
	document.getElementById(inForm).submit();
}

/*
	saveNewsStoryForm
	-this attempts to save and redirect to story edit page
*/
function saveClassifiedForm(next_value, formName){

	var bErrors = false;
	var bErrorStr = '';
	
	var xform = getObject(formName);

	//error checking
	if(xform.clist_title){
		if(edit_form.clist_title.value==''){
			bErrors = true;
			bErrorStr = 'The Headline field is required.';
			xform.clist_title.className = 'jserror';
		}
	}

	//this value tells the form where to redirect after saving
	//edit_form.cm_next.value = next_value;
	//document.getElementById("cm_next").value = next_value;
	
	//TODO: do some error checking
	
	//submit xform POST
	if(bErrors){
		alert(bErrorStr);
	}else{
		//disable all the news story form buttons
		//disableNewsStoryButtons(xform);
	
		//alert('submit');
		xform.submit();
	}

}

function deleteClassified(survey_id){
	url = "/access/account.php?m=classifieds&cm=delete&cid="+survey_id;
	message = "Are you sure you want to delete this ad?";
	confirmAction(url,message);
}
function deleteClassifiedCat(survey_id){
	url = "/access/account.php?m=classifieds&cm=s_cdelete&ccid="+survey_id;
	message = "Are you sure you want to delete this ad?";
	confirmAction(url,message);
}


/* 	###############################
	place ad forms
	############################## */
	
/*
	saveNewsStoryForm
	-this attempts to save and redirect to story edit page
*/
function savePlaceAdForm(next_value){

	var bErrors = false;
	var bErrorStr = '';
	
	var xform = getObject('edit_form');

	//error checking
	if(xform.news_title){
		if(xform.news_title.value==''){
			bErrors = true;
			bErrorStr = 'The Headline field is required.';
			xform.news_title.className = 'jserror';
		}
	}

	//this value tells the form where to redirect after saving
	xform.nm_next.value = next_value;
	
	//TODO: do some error checking
	
	//submit xform POST
	if(bErrors){
		alert(bErrorStr);
	}else{
		//disable all the news story form buttons
		disableNewsStoryButtons(xform);
	
		//alert('submit');
		xform.submit();
	}

}

function placeAdProcessUpload(next_value){
		var xform = getObject('edit_form');
		xform.nm_next.value = next_value;
		xform.submit();
}
