/**
 * Create an item (new forms)
 *
 * @author		Julien CROUZET <jcrouzet@zilok.com>
 * @version		CVS: $Id:$
 * @uses		http://prototype.conio.net/
 * @uses		http://bennolan.com/behaviour/
 */




var										JavascriptAction_610 = {

	rules :								{

	/**
	 * If we are in hide optionals mode
	 */
	'.typeRadios' :						function(el) {
		el.onclick = 					function() {
			if (el.value == 1) {
				$('businessOptionalFields').hide();
			} else {
				$('businessOptionalFields').show();
			}
		}
	},
	
	'#deposit_0' :						function(el) {
		el.onclick =					function() {
			if (el.checked) {
				Element.hide('deposit_div');
			} else {
				Element.show('deposit_div');
			}
		}
	},

	'#deposit_1' :						function(el) {
		el.onclick =					function() {
			if (el.checked) {
				Element.show('deposit_div');
			} else {
				Element.hide('deposit_div');
			}
		}
	},

	'ul#medialist li div.remove' :		function(el) {
		el.onclick =					function() {
			Element.remove(el.parentNode);
		}
	},
	
	'#showBottom' :						function(el) {
		el.onclick =					function() {
			if ($('bottomFields1').style.display == 'none') {
				Element.show('bottomFields1');
			} else {
				Element.hide('bottomFields1');
			}
			if ($('bottomFields2').style.display == 'none') {
				Element.show('bottomFields2');
			} else {
				Element.hide('bottomFields2');
			}
		}		
	},

	'lastButNotLeast' :					function() {}

	} /** rules **/

	
}

function accountType(radio_1,radio_2,radio_3,div) {

	if ($(radio_2).checked==true) $(div).show();
	if ($(radio_3).checked==true) $(div).show();

	Event.observe($(radio_3), "focus", function() {
		$(div).show();
	});
	Event.observe($(radio_2), "focus", function() {
		$(div).show();
	});
	Event.observe($(radio_1), "focus", function() {
		$(div).hide();
	});
}

function closemap() {
	$('map_geo').hide();
	$('location_form').show();
}

function displayMapInput(address,country_code) {
	$('map_geo').show();
	$('location_form').hide();
	load(address,country_code);
}

function returnPosition(lat,lng) {
	$('lat').value=lat;
	$('lng').value=lng;
	addLocation(0, $F('badAddress'));
}

function addLocation(id,title) {
	if ($('location_form')) {
		$('location_form').hide();
	}
	if ($('map_geo')) {
		$('map_geo').hide();
	}
	if ($('locationExplicit')) {
		$('locationExplicit').value = title;
	} else {
		Insertion.After('location_form', '<div><input size="80" type="text" id="locationExplicit" disabled="disabled" value="' + title + '"/></div>');
	}
	if ($('locationIdExplicit')) {
		$('locationIdExplicit').value = id;
	} else {
		Insertion.After('locationExplicit', '<input type="hidden" id="locationIdExplicit" name="location[]" value="' + id + '" />');
	}
	
}



Behaviour.register(JavascriptAction_610.rules);
