	function getCriteria(){
		var retArgs='';	
		
		arg=getFormData('criteriaForm','mediaCat');
		argTest=arg.substring(0,3);
		if (argTest!='all'){
			retArgs+= "&mediaCat=" + arg;
			retArgs+= "&" + arg + "=" + document.criteriaForm.mediaCat.options[whichSelected].text;
		}
		arg=getFormData('criteriaForm','media');
		argTest=arg.substring(0,3);
		if (argTest!='all'){
			retArgs+= "&media=" + arg;
			mediaText = document.forms['criteriaText'].elements[arg].value;
			retArgs+= "&" + arg + "=" + mediaText;
		}
/**
		arg=getFormData('criteriaForm','width');
		if (arg!='all'){
                      	 retArgs+= "&width=" + arg; 
                	}
		arg=getFormData('criteriaForm','height');
		if (arg!='all'){
                        retArgs+= "&height=" + arg;
        }
*/
		arg=extractCheckBoxes('priceForm','allPrices');
		if (arg){
			retArgs+="&priceCode=" + arg;
		}
		retArgs+="&artworkResultsCraftinfoPageView=craftinfo";
		retArgs+="&artworkPageLen=21&artworkSort=27,13,16,10";
		return retArgs;
	}
	
	function criteriaValidate(){
		if (!validateCheckForm('priceForm')){
			alert('At least one price range must be selected.');
			document.MM_returnValue=false;
		} else {
			MM_goToURL('parent','/cgi-bin/WebObjects/ArtFind.woa/wa/publicView?seekType=21&artworkSort=11'+getCriteria());
		}
	}
	
function updatemedia()
{
	//clear media
	for(index=0; index < 7; index++)
	{
		document.criteriaForm.media.options[index].text = "";
		document.criteriaForm.media.options[index].value = "";
	}
	document.criteriaForm.media.options[0].selected = true;
	whichSelected = document.criteriaForm.mediaCat.selectedIndex;
	if(document.criteriaForm.mediaCat.options[whichSelected].value == "all")
	{
		document.criteriaForm.media.options[0].value = "all";
		document.criteriaForm.media.options[0].text = "ANY";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "pntgfca")
	{
		document.criteriaForm.media.options[0].value = "allpntg";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "oilfme";
		document.criteriaForm.media.options[1].text = "Oil";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "prntfca")
	{
		document.criteriaForm.media.options[0].value = "allprnt";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "scprfme";
		document.criteriaForm.media.options[1].text = "Screen Print";
		
		document.criteriaForm.media.options[3].value = "otprfme";
		document.criteriaForm.media.options[3].text = "Other";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "sclpfca")
	{
		document.criteriaForm.media.options[0].value = "allsclp";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "brnzfme";
		document.criteriaForm.media.options[1].text = "Bronze";

		document.criteriaForm.media.options[2].value = "metlfme";
		document.criteriaForm.media.options[2].text = "Metal";

		document.criteriaForm.media.options[3].value = "mixdfme";
		document.criteriaForm.media.options[3].text = "Mixed";

		document.criteriaForm.media.options[4].value = "otscfme";
		document.criteriaForm.media.options[4].text = "Other";

		document.criteriaForm.media.options[5].value = "stonfme";
		document.criteriaForm.media.options[5].text = "Stone";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "jwlyfca")
	{
		document.criteriaForm.media.options[0].value = "alljwly";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "bracfme";
		document.criteriaForm.media.options[1].text = "Bracelets";

		document.criteriaForm.media.options[2].value = "broofme";
		document.criteriaForm.media.options[2].text = "Brooches";
		
		document.criteriaForm.media.options[3].value = "earrfme";
		document.criteriaForm.media.options[3].text = "Earrings";
		
		document.criteriaForm.media.options[4].value = "neckfme";
		document.criteriaForm.media.options[4].text = "Necklace";

		document.criteriaForm.media.options[5].value = "otjwfme";
		document.criteriaForm.media.options[5].text = "Other Jewelery";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "cerafca")
	{
		document.criteriaForm.media.options[0].value = "allcera";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "clayfme";
		document.criteriaForm.media.options[1].text = "Clay";
		
		document.criteriaForm.media.options[2].value = "erthfme";
		document.criteriaForm.media.options[2].text = "Earthenware";
		
		document.criteriaForm.media.options[3].value = "otpcfme";
		document.criteriaForm.media.options[3].text = "Other";
		
		document.criteriaForm.media.options[4].value = "prlnfme";
		document.criteriaForm.media.options[4].text = "Porcelain";
		
		document.criteriaForm.media.options[5].value = "terafme";
		document.criteriaForm.media.options[5].text = "Terracotta";
		
		document.criteriaForm.media.options[6].value = "vasefme";
		document.criteriaForm.media.options[6].text = "Vases";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "glasfca")
	{
		document.criteriaForm.media.options[0].value = "allglas";
		document.criteriaForm.media.options[0].text = "All";

		document.criteriaForm.media.options[1].value = "castfme";
		document.criteriaForm.media.options[1].text = "Cast Glass";
		
		document.criteriaForm.media.options[2].value = "crysfme";
		document.criteriaForm.media.options[2].text = "Crystal";

	}

	if(document.criteriaForm.mediaCat.options[whichSelected].value == "mmedfca")
	{
		document.criteriaForm.media.options[0].value = "allmmed";
		document.criteriaForm.media.options[0].text = "All";
		
		document.criteriaForm.media.options[1].value = "mm2dfme";
		document.criteriaForm.media.options[1].text = "Mixed Media 2-D";
		
		document.criteriaForm.media.options[2].value = "mm3dfme";
		document.criteriaForm.media.options[2].text = "Mixed Media 3-D";

	}
	
	if(document.criteriaForm.mediaCat.options[whichSelected].value == "othmfca")
	{
		document.criteriaForm.media.options[0].value = "allothm";
		document.criteriaForm.media.options[0].text = "All";
		
		document.criteriaForm.media.options[1].value = "ototfme";
		document.criteriaForm.media.options[1].text = "Other";

	}
	
	if(document.criteriaForm.mediaCat.options[whichSelected].value == "txtlfca")
	{
		document.criteriaForm.media.options[0].value = "alltxtl";
		document.criteriaForm.media.options[0].text = "All";
		
		document.criteriaForm.media.options[1].value = "fbrfme";
		document.criteriaForm.media.options[1].text = "Fibre Art";
		
		document.criteriaForm.media.options[2].value = "ottxfme";
		document.criteriaForm.media.options[2].text = "Other Textile";
		
		document.criteriaForm.media.options[3].value = "tapfme";
		document.criteriaForm.media.options[3].text = "Tapestry";

	}
	
	if(document.criteriaForm.mediaCat.options[whichSelected].value == "woodfca")
	{
		document.criteriaForm.media.options[0].value = "allwood";
		document.criteriaForm.media.options[0].text = "All";
		
		document.criteriaForm.media.options[1].value = "crmafme";
		document.criteriaForm.media.options[1].text = "Carving-Maori";
		
		document.criteriaForm.media.options[2].value = "otcrfme";
		document.criteriaForm.media.options[2].text = "Carving-Other";
		
		document.criteriaForm.media.options[3].value = "funcfme";
		document.criteriaForm.media.options[3].text = "Functional";
		
		document.criteriaForm.media.options[4].value = "furnfme";
		document.criteriaForm.media.options[4].text = "Furniture";
		
		document.criteriaForm.media.options[5].value = "wwrkfme";
		document.criteriaForm.media.options[5].text = "Wood Working";

	}

	return true;
}

function getFormData(form, component){ //pull stuff out of a form

         formData=document.forms[form].elements[component];
         if (formData.type == "select-one"){
         	return formData.options[formData.selectedIndex].value;
         } else if ((formData.type == "checkbox")||(formData.type == "radio")){
			if (formData.checked) {
				return "yes";
			} else {
				return "no";
			}
		} else if (formData.type == "select-multiple"){
			     out = new Array;
			     idx=0;
                       for (i=0; i < formData.options.length; i++){
                            if (formData.options[i].selected){
                            	out[idx]=formData.options[i].value;
					  			idx = idx + 1;
                            }
                       }
                       if ( out.length > 0 ) {
                            return out;
                       } else {
                            return null;
                       }
		} else if ((formData.type == "text") || (formData.type == "textarea")){
			return formData.value;
		} else {
			return 0;
		}
	return null;
}

function toggleForm(formName, controlBox){
	for (i=0; i < document.forms[formName].elements.length; i++){
		if (document.forms[formName].elements[i].type=="checkbox"){
			document.forms[formName].elements[i].checked=document.forms[formName].elements[controlBox].checked;
		}
	}
	return null;
}


function extractCheckBoxes(formName,controlBox){
	var count=0;
	var out = new Array;
	if((arg = getFormData(formName,controlBox))!='yes'){
		for (i=1; i < document.forms[formName].elements.length;i++){
			if(document.forms[formName].elements[i].checked){
				out[count] = document.forms[formName].elements[i].value;
				count = count + 1;
			}
		}
		if (out.length > 0) { 
			return out;
	        } else {
			return null;
		}
	} else {
		return null;
	}
	return null;
}

function extractRadioButtons(formName){
	var count=0;
	var out = new Array;
	for (i=0; i < document.forms[formName].elements.length;i++){
			if(document.forms[formName].elements[i].checked){
				return document.forms[formName].elements[i].value;
			}
	}
	return null;
}

function setSelector(formName,control,setValue){
	for (i=0; i < document.forms[formName].elements[control].options.length; i++){
		if(document.forms[formName].elements[control].options[i].value==setValue){
			document.forms[formName].elements[control].selectedIndex=i;
		}
	}
	return null;
}

function validateCheckForm(formName){
	var validated = false;
	for (i=0; i < document.forms[formName].elements.length;i++){
		if(document.forms[formName].elements[i].checked){
			validated=true;
		}		
	}
	return validated;
}


function addSelectedToList(toForm,fromForm,toList,fromList){

document.forms[toForm].elements[toList].options[document.forms[toForm].elements[toList].options.length] = new Option(
document.forms[fromForm].elements[fromList].options[document.forms[fromForm].elements[fromList].options.selectedIndex].text,
document.forms[fromForm].elements[fromList].options[document.forms[fromForm].elements[fromList].options.selectedIndex].value);
		
		
	
} 
	
function removeFromList(formName,component){
	document.forms[formName].elements[component].options[document.forms[formName].elements[component].options.selectedIndex] = null;
}
	
function selectAllInList(formName,component){
	for (i=0; i < document.forms[formName].elements[component].length; i++){
		document.forms[formName].elements[component].options[i].selected=true;
	}
}

function artworkEnqWindow(artworkCode,site,appNumber,artworkArtBureuaPageView){
	Open(site + '/cgi-bin/WebObjects/ArtFind.woa/' + appNumber + '/wa/publicView?seekType=100&artworkCodes=' + artworkCode + '&enquiryArtBureauPageView=' + artworkArtBureuaPageView,'contactbox','360','365');
}

// various macromedia fuctions ..

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i < a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function Open(url,windowname,horz,vert) {
	window.open(url, windowname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + horz + ',height=' + vert );
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

var win = null;

function NewWindow(mypage,myname,w,h,scroll)
{	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

