
function validateFormClass(form,requiredObj,skip_submit,userAdditions) {
	//var requiredObj = '".$this->require_list."';

	var error=false;
	var missing_elements='';

	for (i in requiredObj) {
		var e = document.getElementById(i);
		if( e == null ) {
			continue;
		}
		if (e.type != 'radio') {
		    var fckFrame = document.getElementById(i+'___Frame');
		    if( fckFrame ) {
		        fckFrame.contentWindow.FCK.UpdateLinkedField();
		    }
			if (e.value == '') {
				missing_elements += '\n  - ' + requiredObj[i];
				e.style.backgroundColor='#FCC';
				e.style.border='1px solid red';
				error=true;
			}
		} else {
			var list_error=false;
			if (e.length != null) {
				found = false;
				for (var j = 0 ; j < e.length ; j++) {
					if(e[j].checked) { found=true; break; }
				}
				if (found == false) {
					missing_elements += '\\n  - radio options';
					error=true;
				}
			}
		}
	}

	if (error) {
		alert('Please fill in all required fields (marked with a red *).\nMissing:'+missing_elements);
		return false;
	} else {
		if (!skip_submit) {
			if (userAdditions()) {
				return true;
			} else {
				return false;
			}
		}
	}
	return true;
}


/* deprecated leftovers from CES 1 */
function save_return(myForm,myWhere) {
	//alert('In an effort to better our platform, the use of save_return() javascript has been deprecated. This will continue to work but please update the code to the newer method. (see Jeff).\n (remove this warning on live server!)');
	var vf = "validateFormClass('"+myForm+"',{},true,function(){ return true; });";
	var check = eval(vf);
	if (check) {
		// if verification passed then keep going
		document[myForm]["goto"].value = myWhere;
		document[myForm].submit();
	}
}


var colour_picker;
var win_width = 600;
var win_height = 340;
function colour_picker_popup(win_url) {
	colour_picker = window.open(win_url,'colour_picker_window','left='+((screen.width-win_width)/2)+',top='+((screen.height-win_height)/2)+',height='+win_height+',width='+win_width+',menubar=no,toolbar=no,locationbar=no,resizable=yes,scrollbars=yes');
	if(javascript_version> 1.0) { setTimeout('colour_picker.focus();',250); }
}

function colour_picker2_popup(rWidth,rHeight) {
	rWidth = rWidth+10; //scrollbars
	rHeight = rHeight+10; //scrollbars
	var max_width=screen.width-150;
	var max_height=screen.height-300;
	if(rWidth<max_width) max_width=rWidth;
	if(rHeight<max_height) max_height=rHeight;

	var win_left = ((screen.width-max_width)/2);
	var win_right = ((screen.height-max_height)/2);

	self.resizeTo(max_width,max_height);
	self.moveTo(win_left,win_right);

	if(javascript_version> 1.0)	{ setTimeout('self.focus();',250); }
}

