$(function() {
	$('.admin-form-expand').hide();
	$('.admin-header').click(function(){
	$('.admin-form-expand').slideToggle(1000);
	return false;
	});

	$('#editAdress, #addAdress').find('#town_id').change(function(){
		$('#othertown-label, #othertown-element').remove();
		if($(this).val() > 109) {
			$("#town_id-element").after('<dt id="othertown-label"><label for="othertown">Город: </label></dt><dd id="othertown-element"><input type="text" name="othertown" id="othertown"></dd>');
		}
	}).end().submit(function(){
		if ($('#othertown').val() != '') {
		$('#text').val($('#othertown').val() + ', ' + $('#text').val());
		}
	});

	$('button#change').click(function(){
		window.location.href = '/order/new/step/3/';
	});
	$('button#prev').click(function(){
		window.location.href = '/order/selectuser/';
	});
	$('.login-box').hide();
	$('a#user-login').css({'text-decoration':'none', 'border-bottom': '1px dashed #01aeff'})
						.click(function() {
							$('.login-box').slideToggle(100);
							return false;
						});
	$('textarea.tiny').not('#register-adress').not('#register-adress').tinymce({
		script_url : '/js/tiny_mce/tiny_mce.js',
		mode : "textareas", 
		theme : "advanced",
		editor_selector : "tiny",
		language : "ru",
		plugins : "advimage, media, fullscreen, safari,pagebreak,style,table,save,images,advlink,inlinepopups,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_blockformats : "p,h3,h4",
		theme_advanced_buttons1 : "cut,copy,paste,|,undo,redo,|,link,unlink,images,|,justifyleft,justifycenter,justifyright,justifyfull,|",
		theme_advanced_buttons2 : "bold,italic,|,bullist,numlist,blockquote,|,formatselect,|,sub,sup,charmap",
		theme_advanced_buttons3 : "tablecontrols, code, fullscreen",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		relative_urls : false,
		remove_script_host : true,
		});
	
 });

