var artwork_selections_output;
var artist_selections_output;
var school_selections_output;
var exhibition_selections_output;
var dealer_selections_output;

var can_fetch_artwork_selections;
var can_fetch_artist_selections;
var can_fetch_school_selections;
var can_fetch_exhibition_selections;
var can_fetch_dealer_selections;

function fetch_artwork_selections(params) {
	var url = "isa=Metadot::SystemApp::Catalog;op=fetch_artwork_selections;";
	if (params.category != "" && params.category != undefined) {
		url += "category=" + escape(params.category) + ";";
	}
	if (params.medium != "" && params.medium != undefined) {
		url += "medium=" + escape(params.medium) + ";";
	}
	if (params.style != "" && params.style != undefined) {
		url += "style=" + escape(params.style) + ";";
	}
	if (params.location != "" && params.location != undefined) {
		url += "location=" + escape(params.location) + ";";
	}
	if (params.period != "" && params.period != undefined) {
		url += "period=" + escape(params.period) + ";";
	}
	$.ajax({
		type: "POST",
		url: "/index.pl",
		data: url,
		beforeSend: function(item) {
			can_fetch_artwork_selections = false;
		},
		success: function(message) {	
  			if (message.length > 5) {							
				artwork_selections_output = $.evalJSON(message);
			}
			can_fetch_artwork_selections = true;
		}
	});
}

function can_fetch_artwork_selections_output() {
	return can_fetch_artwork_selections;
}

function fetch_artwork_selections_output() {
	return artwork_selections_output;
}

function fetch_artist_selections(params) {
	var url = "isa=Metadot::SystemApp::Catalog;op=fetch_artist_selections;";
	if (params.category != "" && params.category != undefined) {
		url += "category=" + escape(params.category) + ";";
	}
	if (params.medium != "" && params.medium != undefined) {
		url += "medium=" + escape(params.medium) + ";";
	}
	if (params.style != "" && params.style != undefined) {
		url += "style=" + escape(params.style) + ";";
	}
	if (params.keywords != '' && params.keywords != undefined) {
		url += "keywords=" + escape(params.keywords) + ";";
	}
	$.ajax({
		type: "POST",
		url: "/index.pl",
		data: url,
		beforeSend: function(item) {
			can_fetch_artist_selections = false;
		},
		success: function(message) {	
  			if (message.length > 5) {							
				artist_selections_output = $.evalJSON(message);
			}
			can_fetch_artist_selections = true;
		}
	});
}

function can_fetch_artist_selections_output() {
	return can_fetch_artist_selections;
}

function fetch_artist_selections_output() {
	return artist_selections_output;
}

function fetch_school_selections(params) {
	var url = "isa=Metadot::SystemApp::Catalog;op=fetch_school_selections;";
	if (params.category != "" && params.category != undefined) {
		url += "category=" + escape(params.category) + ";";
	}
	if (params.medium != "" && params.medium != undefined) {
		url += "medium=" + escape(params.medium) + ";";
	}
	if (params.style != "" && params.style != undefined) {
		url += "style=" + escape(params.style) + ";";
	}
	if (params.keywords != '' && params.keywords != undefined) {
		url += "keywords=" + escape(params.keywords) + ";";
	}
	$.ajax({
		type: "POST",
		url: "/index.pl",
		data: url,
		beforeSend: function(item) {
			can_fetch_school_selections = false;
		},
		success: function(message) {	
  			if (message.length > 5) {							
				school_selections_output = $.evalJSON(message);
			}
			can_fetch_school_selections = true;
		}
	});
}

function can_fetch_school_selections_output() {
	return can_fetch_school_selections;
}

function fetch_school_selections_output() {
	return school_selections_output;
}

function fetch_exhibition_selections(params) {
	var url = "isa=Metadot::SystemApp::Catalog;op=fetch_exhibition_selections;";
	if (params.category != "" && params.category != undefined) {
		url += "category=" + escape(params.category) + ";";
	}
	if (params.artist != "" && params.artist != undefined) {
		url += "artist=" + escape(params.artist) + ";";
	}
	if (params.location != "" && params.location != undefined) {
		url += "location=" + escape(params.location) + ";";
	}
	if (params.keywords != "" && params.keywords != undefined) {
		url += "keywords=" + escape(params.keywords) + ";";
	}
	$.ajax({
		type: "POST",
		url: "/index.pl",
		data: url,
		beforeSend: function(item) {
			can_fetch_exhibition_selections = false;
		},
		success: function(message) {	
  			if (message.length > 5) {							
				exhibition_selections_output = $.evalJSON(message);
			}
			can_fetch_exhibition_selections = true;
		}
	});
}

function can_fetch_exhibition_selections_output() {
	return can_fetch_exhibition_selections;
}

function fetch_exhibition_selections_output() {
	return exhibition_selections_output;
}

function fetch_dealer_selections(params) {
	var url = "isa=Metadot::SystemApp::Catalog;op=fetch_dealer_selections;";
	if (params.category != "" && params.category != undefined) {
		url += "category=" + escape(params.category) + ";";
	}
	if (params.medium != "" && params.medium != undefined) {
		url += "medium=" + escape(params.medium) + ";";
	}
	if (params.style_cat != "" && params.style_cat != undefined) {
		url += "style=" + escape(params.style_cat) + ";";
	}
	if (params.period != "" && params.period != undefined) {
		url += "period=" + escape(params.period) + ";";
	}
	if (params.location != "" && params.location != undefined) {
		url += "location=" + escape(params.location) + ";";
	}
	if (params.keywords != "" && params.keywords != undefined) {
		url += "keywords=" + escape(params.keywords) + ";";
	}
	if (params.online_gallery != "" && params.online_gallery != undefined) {
		url += "online_gallery=" + escape(params.online_gallery) + ";";
	}
	$.ajax({
		type: "POST",
		url: "/index.pl",
		data: url,
		beforeSend: function(item) {
			can_fetch_dealer_selections = false;
		},
		success: function(message) {	
  			if (message.length > 5) {							
				dealer_selections_output = $.evalJSON(message);
			}
			can_fetch_dealer_selections = true;
		}
	});
}

function can_fetch_dealer_selections_output() {
	return can_fetch_dealer_selections;
}

function fetch_dealer_selections_output() {
	return dealer_selections_output;
}

