function show_hide(id)
{
	if(document.getElementById(id).style.display == 'none')
		document.getElementById(id).style.display = 'block';
	else
		document.getElementById(id).style.display = 'none';
}

$(document).ready(function(){
	$("#adr").focus(function () {
         if($("#adr").val() == 'Adres e-mail')
		   $("#adr").val('');
    });
	 $("#adr").blur(function () {
         if($("#adr").val() == '')
		   $("#adr").val('Adres e-mail');
    });
	
	$("#content2").focus(function () {
         if($("#content2").val() == 'Treść wiadomości')
		   $("#content2").val('');
    });
	 $("#content2").blur(function () {
         if($("#content2").val() == '')
		   $("#content2").val('Treść wiadomości');
    });
});

function checkConfirm(question, url)
{
	if(confirm(question)) location.href=url;	
}

function clearField(id, value)
{
	if(document.getElementById(id).value == value) document.getElementById(id).value = '';
}

function fillField(id, value)
{
	if(document.getElementById(id).value == '')
		document.getElementById(id).value = value;
}

function addfavorite(id)
{
	$.ajax({
		type: 'POST',
		url: siteurl+'ajax/wybrane',
		data: 'id='+id,
		beforeSend: function() { $('#fav').html('<img src="'+siteurl+'public/gfx/fav.gif" /> <img src="'+siteurl+'public/gfx/loader_observe.gif" /> Trwa dodawanie'); },
		success: showResponse
	});
}

function showResponse(response)
{
	if(response == 1)
	{
		$('#fav').html('<img src="'+siteurl+'public/gfx/fav_2.gif" />Obserwowana oferta');
		alert('Dodano ofertę do obserwowanych');
	}
	else
	{
		$('#fav').html('<img src="'+siteurl+'public/gfx/fav.gif" />Obserwuj ofertę');
		alert('Aby obserwować ofertę musisz być zalogowany!');
	}
}

function highlight(field)
{
    field.focus();
    field.select();
}
