$(document).ready(function() {
	$('#podglad_box_table [name=nazwa]').keyup(function(){$('#podglad_box h3').html(this.value)});
	$('#podglad_box_table [name=opis1]').keyup(function(){$('#podglad_box span').first().html(this.value)}); 
	$('#podglad_box_table [name=opis2]').keyup(function(){$('#podglad_box span').last().html(this.value)});
	
	$('.box').css('cursor', 'pointer').click(function(){window.location=$(this).find('h3 a').attr('href')});
	
	
	$('.company_foto_prev').has('img').css('cursor', 'pointer').click(function(){$('#company_foto_main img').attr('src', $(this).find('img').first().attr('src').replace('_m', ''))});
	
	$('#new_company_ads_box a').first().click(function(){$('#new_company_ads_box form').show();return false;});
	$('#new_company_ads_box form button').first().click(function(){$('#new_company_ads_box form').hide();return false;});
	
	if ($('#new_company_ads_box form .error_form').html()) {
		window.scrollTo(100,500);
		$('#new_company_ads_box form').show();
	}
})


function powiat_change(s) {
	if (select_regiony) {
		if (select_regiony[s.value]) {
			$('select[name=region_id]').empty();
			$('select[name=region_id]').append('<option value="0">wybierz...</option>');
			for(i=0; i<select_regiony[s.value].length;i++) {
				$('select[name=region_id]').append('<option value="'+select_regiony[s.value][i].id+'">'+select_regiony[s.value][i].n+'</option>');
			}
			$('select[name=region_id]').attr('disabled', '');
		} else {
			$('select[name=region_id]').attr('disabled', 'disabled');
		}
		
		
	} else {
		alert('Błąd krytyczny. Proszę odśwież stronę.');
	}
}


function company_ads_delete(id) {
	if (confirm('Na pewno chcesz usunąć to ogłoszenie???')) {
		window.location=site_urli+'firma/usun_ogloszenie/'+id+'.html';
	}	
}


function branza_switch(s,r) {
	if (s.value) {
		window.location=site_urli+'katalog/jump/'+s.value+'/'+r+'.html';
	}	
	
}

function ads_move(oid,fid,dir) {
	window.location=site_urli+'firma/oferta_przesun/'+oid+'/'+fid+'/'+dir+'.html';
	return false;
}
