$(document).ready(function() {	
	$('#dret5o2').hide();
});

function reg_company(cid) {	
	switch(cid)
	{
		case 1: $('tr.df').hide();$('#osprow').hide();$('tr.pdata').show(); break;
		case 2: $('tr.df').show();$('#osprow').show();$('tr.pdata').hide(); break;
		case 3: $('tr.df').show();$('#osprow').show();$('tr.pdata').hide(); break;
		case 4: $('tr.df').show();$('#osprow').show();$('tr.pdata').hide(); break;
		default: $('tr.df').hide();$('#osprow').hide();$('tr.pdata').hide();
	}
}

function set_price() {
	var pow_calkowita = $('#pow_calkowita').attr('value');
	var cena          = $('#cena').attr('value');
	var cena_za_m2    = $('#cena_za_m2').attr('value');
	
	if(!isNaN(pow_calkowita) && !isNaN(cena)) $('#cena_za_m2').attr('value',Math.round(cena / pow_calkowita));	
}

function offdate() {
	if($('#dost32').val()==3)
		$('#dret5o2').show();
	else
		$('#dret5o2').hide();
}

function setMainImage(id) {
	$('#mlinkfoto').attr('href','/img/adv/562x400/'+id+'.jpg');
	$('#mfoto').attr('src','/img/adv/562x400/'+id+'.jpg');
}

function getCity()
{
	$.ajax({
		url: '/ajax/getCity/city/'+$('#miastolt1').val(),
		success: function(msg){
			$('#citylist').html(msg);
			if(msg) $('#citylist').show(); else $('#citylist').hide();
		}		
	})
}

function schowek(elm,id)
{
	$.ajax({
		url: '/ajax/schowek/id/'+id,
		success: function(msg){
			elm.innerHTML = '<img src="/gfx/schowek.png" alt="" /> ogłoszenie zapisane';
			alert(msg);
			if(msg=='Ogłoszenie zostało dodane do schowka')
			{
				$('#schowekbox').show();
				ile = $('#showeka1').html();
				ile = ile.replace('(','');
				ile = ile.replace(')','');
				ile = parseInt(ile);	
				$('#showeka1').html('('+(ile+1)+')');
			}
		}		
	});	
}

function checkConfirm(question, url)
{
	if(confirm(question))
		location.href=url;
}
