/* CM_js.js
	Created 2/1/06
	JavaScripts for Content Manager
	Copyright 2006 by Bob Merrill
	
*/

function hideshowelement(which) {
	//assumes a div, but will probably work with any element
	//the element must be passed as an object
	if (document.getElementById) {
		editdiv = document.getElementById(which);
		whichstate = editdiv.className;
		if(whichstate == "shown") {
			whichstate = "hidden";
		} else {
			whichstate = "shown";
		}
		editdiv.className = whichstate;
	}
}

function clicksubmit(formname,elementname,whichvalue,msg,addtarget) {

	if(elementname == "Submit") {
		var updatesubmit = formname+"."+elementname+".value='"+whichvalue+"'";
		var submitstr=formname+".submit()";
		if(addtarget) {
			var targetstring = formname+".action+=\"#\"+addtarget";
			eval(targetstring);
			//eval("alert("+formname+".action);");
		}

		//alert(updatesubmit+"\n"+submitstr);
		//is there a confirm message? if so, confirm
		if(msg) {
			if(msg.length == 0) {
				alert("Error: Confirm message with zero length. No action taken.");
				return false;
			}
			confirmthis = confirm(msg);
			if(confirmthis == true) {
				//update the value of Submit
				eval(updatesubmit);
				//submit the form
				//eval(submitstr);
				return true;
			} else {
				return false;
			}
		} else {
			//no confirm message
			//update the value of Submit
			eval(updatesubmit);
			//submit the form

			return true;
		}
	}
	return false;
}
		
		
		

