$(document).ready(function(){

    $("img").lazyload({ effect : "fadeIn", placeholder : "http://m.mieszkaniegdynia.pl/images/loader_offer.gif"});

	$("img.top_facebook").fadeTo("slow", 0.5);
	$("div.oferta div.box div.links img").fadeTo("fast", 0.5);
	
	$("img.top_facebook").mouseover(function(){
		$("img.top_facebook").fadeTo("slow", 1);
	});
	
	$("img.top_facebook").mouseout(function(){
		$("img.top_facebook").fadeTo("slow", 0.5);
	});

    $("#amount").priceFormat({
        prefix: '',
        postfix: '',
        centsSeparator: '',
        thousandsSeparator: ' ',
        centsLimit: 0
    });
		
    $('#email').attr('defaultValue', 'wprowadź swój adres e-mail');
    $('#phone').attr('defaultValue', 'wprowadź swój telefon');
    $('#ask').attr('defaultValue', 'wprowadź treść...');

    $('#email').focus(function(){
      if( $(this).val() == $(this).attr('defaultValue') ) {
        $(this).val('');
        $(this).css('paddingTop', '8px');
        $(this).css('fontSize', '18px');
      };
    
      $('#email').blur( function () {
        if ( $(this).val() == '' ){
          $(this).val(  $(this).attr('defaultValue') );
          if( jQuery.browser.mozilla  ) {
            $(this).css('paddingTop', '10px');
          } else {
            $(this).css('paddingTop', '2px');
          }
          $(this).css('fontSize', '13px');
        }
      });
    });

    $('#phone').focus(function(){
      if( $(this).val() == $(this).attr('defaultValue') ) {
        $(this).val('');
        $(this).css('paddingTop', '8px');
        $(this).css('fontSize', '18px');
      };
    
      $('#phone').blur( function () {
        if ( $(this).val() == '' ){
          $(this).val(  $(this).attr('defaultValue') );
          if( jQuery.browser.mozilla  ) {
            $(this).css('paddingTop', '10px');
          } else {
            $(this).css('paddingTop', '2px');
          }
          $(this).css('fontSize', '13px');
        }
      });
    });

    $('#ask').focus(function(){
      if( $(this).val() == $(this).attr('defaultValue') ) {
        $(this).val('');
      };
    
      $('#ask').blur( function () {
        if ( $(this).val() == '' ){
          $(this).val(  $(this).attr('defaultValue') );
        }
      });
    });

    if( jQuery.browser.mozilla  ) {
        $('#email').css('paddingTop', '10px');
        $('#phone').css('paddingTop', '10px');
        $('#ask').css('paddingTop', '10px');
    } else {
        $('#email').css('paddingTop', '0px');
        $('#phone').css('paddingTop', '0px');
        $('#ask').css('paddingTop', '10px');
    }
});

    $(function() {
        $("#slider-range-max").slider({
            range: "max",
            min: 0,
            max: 600000,
            value: 300000,
            step: 100,
            slide: function(event, ui) {
                $("#amount").val(ui.value).priceFormat({
				    prefix: '',
					postfix: '',
				    centsSeparator: '',
				    thousandsSeparator: ' ',
					centsLimit: 0
				});
            }
        });
        
        $('#amount').change(function() {
            $("#slider-range-max").slider("value", $("#amount").val() );
        });
    });

function gaClick(source) {
	pageTracker._trackPageview('ga/' + source);
}

function ikonkaFade(t,id){

	$(function(){
	
		$("img#" + id).fadeTo("fast", 1);
	
		$(t).mouseover(function(){
			$("img#" + id).fadeTo("fast", 1);
		});
		
		$(t).mouseout(function(){
			$("img#" + id).fadeTo("fast", 0.5);
		});
		
	});
}

function searchMore(id) {

	$(function(){

		$("#" + id).fadeTo("slow", 0, function callback() {
			$("div.search").css('visibility', 'hidden');
			$("#" + id).css('display', 'block');
			$("#" + id).fadeTo("slow", 1);			
		});	
		
	});
	
}

function searchMoreClose(id) {

	$(function(){

		$("div.search").fadeTo("slow", 0, function callback() {
			$("div.search").css('visibility', 'visible');
			$("#" + id).css('display', 'none');
			$("div.search").fadeTo("slow", 1);			
		});	
		
	});
}

