function colorBackground(colors){
	var color = colors[document.describe.color.value];
	document.getElementById("color").style.background = color;

	if(color == '#000000') document.getElementById("color").style.color = '#ffffff';
	else document.getElementById("color").style.color = '#000000';
}

function submitSelected(id){
	document.describe_selection.selection.value = id;
	document.describe_selection.submit();
}

function deleteSelected(id){
	var delform = document.submit_pending;

	try {
    		imageid = document.createElement("<input name='imageid' type='hidden' value='"+id+"' />");
	} catch (e) {
    		imageid = document.createElement("input");
    		imageid.setAttribute("name", "imageid");
    		imageid.setAttribute("type", "hidden");
		imageid.setAttribute("value", id);
	}
	delform.appendChild(imageid);

	try {
    		submitdelete = document.createElement("<input name='submitdelete' type='hidden' value='delete image' />");
	} catch (e) {
    		submitdelete = document.createElement("input");
    		submitdelete.setAttribute("name", "submitdelete");
    		submitdelete.setAttribute("type", "hidden");
		submitdelete.setAttribute("value", "delete image");
	}
	delform.appendChild(submitdelete);

	delform.submit();
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++)
      		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
	  		theForm[z].checked = theElement.checked;
}

function modelPhoto(obj){
	modelid = obj.value;

	if(obj.checked) img = '<img style="margin-left:3px;" src="/modelphoto/'+modelid+'|60|60|max" alt="model" />';
	else img = '';

	document.getElementById("model_img"+modelid).innerHTML = img;
		
}
