function pop(what) {
	//open a help screen
	var url="explain.php?params="+what;
	var parms = 'location=1, status=1, scrollbars=1, width=550, height=500'
	x=window.open(url, 'y', parms);
}

function check_options() {
	//country search has no city or state elements
	var c_code = document.getElementById('country').selectedIndex;
	var country = document.getElementById('country')[c_code].value;
	if (country != 0 && country != 236) {
		document.getElementById('fap_footer').style.visibility = 'hidden';
		document.getElementById('city').value = '';
		document.getElementById('state').selectedIndex = 0;
		return;
	}
	//else show distance-limit option when city field is not empty
	if (document.getElementById('city').value != '') {
		set_radius();
		document.getElementById('fap_footer').style.visibility = 'visible';
	} else {
		document.getElementById('fap_footer').style.visibility = 'hidden';
	}
}

function set_radius() {
	if (document.getElementById('get_radius').value != '') {
		//if user has set a radius, honor it
		document.getElementById('radius').selectedIndex = document.getElementById('get_radius').value;
	} else {
		//try the lookup table; cities is a global var
		var idx = document.getElementById('city').value.toLowerCase().replace(/\s/g, '');
		if (cities[idx] > 0) {
			document.getElementById('radius').selectedIndex = cities[idx];
		} else {
			document.getElementById('radius').selectedIndex = 3;
		}
	}
}

function conjoin() {
	//show the both-either option only when 2 specialties are requested
	var s1 = document.getElementById('spec1').selectedIndex;
	var s2 = document.getElementById('spec2').selectedIndex;
	if (s1 > 0 && s2 > 0 && s1 != s2) {
		document.getElementById('fapcrit_join').style.visibility = 'visible';
	} else {
		document.getElementById('fapcrit_join').style.visibility = 'hidden';
	}
}

function final_check() {
	// make sure that a US city has a state
	var rx = new RegExp('[^0-9]');
	var city = document.getElementById('city').value;
	var c_code = document.getElementById('country').selectedIndex;
	var country = document.getElementById('country')[c_code].value;
	if (country == 0 || country == 236) {
		if (city != '' && rx.test(city)) { 
			if (document.getElementById('state').selectedIndex == 0) {
				alert("If you enter a city name, you must also specify the state.");
				return false;
			}
		}
	}
	//prevent duplicate button presses (but it breaks the Back button!)
	//document.getElementById('submitbutton').disabled = true;
	return true;
}

function spelrite(word) {
	document.getElementById('city').value = word;
	//prevent duplicate button presses? screws up the Back button
	//document.getElementById('submitbutton').disabled = true;
	document.findaphotographerform.submit();
}

function updateProfileThumbs(obj) {
	var id = obj.options[obj.selectedIndex].value;
	randstring = Math.random() + "";
	disableProfilePulldown(obj);
	
	jQuery('#thumbnails').load('/findaphotographer/replace_thumbnails.php?id=' + id, 
								randstring, 
								function(){ enableProfilePulldown(obj) }
							  );
}

function enableProfilePulldown(obj) {
	obj.disabled = false;
	id = document.getElementById('firstPhoto').value;
	//showFullPhoto(id);
	var html = jQuery('#member_popup_details').html();

	jq132('a.popup').colorbox({
		transition:'elastic',
		speed:300,
		photo: true,
		title: html,
		opacity: .8,
		'maxHeight': max_colorbox_height,
		'maxWidth': max_colorbox_width
	});

}

function disableProfilePulldown(obj) {
	obj.disabled = true;
}

function showFullPhoto(id) {
	//set image src to loading gif
	jQuery('img.fullsize').attr('src', '/images/findaphotographer/loading.gif');
	//load the url and place the contents into #full_size_stuff
	jQuery('#full_size_stuff').load( '/findaphotographer/best_size_photo.php?id=' + id ); 
}

function expand(up) {
	if (up) {
		document.getElementById('caption_truncated').style.display = 'none';
		document.getElementById('caption_infull').style.display = 'block';
	} else {
		document.getElementById('caption_truncated').style.display = 'block';
		document.getElementById('caption_infull').style.display = 'none';
	}
}


//optimum radius for selected places
// values are: 1=10miles, 2=25, 3=50, 4=100, 5=300
// entries must be lowercase, no spaces
var cities = 
{ 
arlington: 2,
baltimore: 2,
bayonne: 2,
bethesda: 2,
bloomfield: 2,
cheyenne: 5,
edison: 2,
elizabeth: 2,
jerseycity: 2,
miami: 2,
missoula: 4,
newark: 2,
newbrunswick: 2,
newyork: 1,
olympia: 2,
orlando: 2,
parsippany: 2,
pasadena: 2,
passaic: 2,
paterson: 2,
perthamboy: 2,
piscataway: 2,
plainfield: 2,
pomona: 2,
princeton: 2,
seattle: 2,
silverspring: 2,
stamford: 1,
tacoma: 2,
tampa: 2,
torrance: 2,
union: 2,
unioncity: 2,
washington: 2,
wayne: 2
}


