function hideRatingLabels(){
	$('ratelabels').childElements().invoke('hide');
}

function importselect() {
	if ($('selectbox').checked==true) {
		$$('.referralbox').each(function (elem) {elem.checked = true;});
	}
	else {
		$$('.referralbox').each(function (elem) {elem.checked = false;});
	}
}

function rateLabel(id){
	hideRatingLabels();
	var labelid='ratelabel-'+id;
	$(labelid).show();
}

function save_prices(art_id, price) {
	new Ajax.Request("/includes/art-forsale-price.php", {
		method: "post",
		parameters: {id:art_id,price:price},
		onComplete: function() { 
			window.location.reload();
		}
	});
}

function inputlimit(inputid, limit){
	countboxid = inputid+'-count';
	value = $(inputid).value;
	$(countboxid).innerHTML = limit - value.length;
	if (value.length > limit) {
		$(countboxid).setStyle({ color: '#f00' });
	} else {
		$(countboxid).setStyle({ color: '#000' });
	}
}

function view_bio(){
	$('fullbio').show();
}

function add_fav_art(id) {
	new Ajax.Updater('popupbox-content','http://www.artsavvy.com/includes/favorites-folder.php', {
		method: 'get', 
		parameters: {id:id},
		onComplete: function() { $('popupoverlay').show(); }
	});
}

function criteria_check(checkid,currentid){
	currentid = currentid || null;
	if(currentid!=null){
		if($(currentid).value!='') $(checkid).checked = true;
		else $(checkid).checked = false;
	}
	else $(checkid).checked = true;
}

function clear_input(textfield){
	if (textfield.defaultValue==textfield.value) textfield.value = "";
}

function text_limit(field, maxlen) {
	if (field.value.length > maxlen)
	field.value = field.value.substring(0, maxlen);
} 

function art_switchimage (divid) {
	$$('.art-button-outer').invoke('removeClassName','red');
	$$('.art-button-inner').invoke('removeClassName','redcontents');
	$('art-button-outer-'+divid).addClassName('red');
	$('art-button-inner-'+divid).addClassName('redcontents');
	$$('.art-image').invoke('hide');
	$('art-image-'+divid).show();
}

function profile_switchart (divid) {
	$$('.artsort').invoke('removeClassName','selected');
	$('artsort-'+divid).addClassName('selected');
	$$('.art-status').invoke('hide');
	$('art-status-'+divid).show();
}

function profile_switchcollab (divid) {
	$$('.collabsort').invoke('removeClassName','selected');
	$('collabsort-'+divid).addClassName('selected');
	$$('.collab-status').invoke('hide');
	$('collab-status-'+divid).show();
}

function remove_venue() {
	$('remove-venue').hide();
	$('event-venue').value='';
	$('venue-id').value='';
	$('event-address').value=''; $('event-address').readOnly=false;
    $('event-city').value=''; $('event-city').readOnly=false;
    $('event-state').value=''; $('event-state').readOnly=false;
    $('event-country').value=''; $('event-country').readOnly=false;
    $('event-zipcode').value=''; $('event-zipcode').readOnly=false;
}

function event_switchevent (divid) {
	$$('.event-view-event').invoke('hide');
	$('event-view-'+divid).show();
}

function index_switchproject (divid) {
	$$('.event-view-event').invoke('hide');
	$('event-view-'+divid).show();
}

function message_checkboxes(type)
{	
	var form=$('messages');
	if (type=='all') {
		$$('.read').each(function (elem) {elem.checked = true;});
		$$('.unread').each(function (elem) {elem.checked = true;});
	}
	if (type=='none') {
		$$('.read').each(function (elem) {elem.checked = false;});
		$$('.unread').each(function (elem) {elem.checked = false;});
	}
	if (type=='read') {
		$$('.read').each(function (elem) {elem.checked = true;});
		$$('.unread').each(function (elem) {elem.checked = false;});
	}
	if (type=='unread') {
		$$('.read').each(function (elem) {elem.checked = false;});
		$$('.unread').each(function (elem) {elem.checked = true;});
	}
}

function tour_switch(direction){
	
	var current;
	var target;

	$$('.tour-slide').each(function(s){
		if($(s).visible()==true){
			current=s;
		}
	});
	
	siblings=$(current).siblings();
	siblingtotal=siblings.length;
	lastsibling=siblingtotal-1;
	
	if(direction=='next'){
		target=current.next();
		if(target==null){
			target=siblings[0];
		}
	}
	
	else{
		target=current.previous();
		if(target==null){
			target=siblings[lastsibling];
		}
	}
	
	current.hide();
	target.show();
}
