
var labels = { 
		  'search_from_price': 'cena od', 
		  'search_to_price': 'cena do',
		  'search_from_area': 'pow. od', 
		  'search_to_area': 'pow. do',
		  'search_street': 'ulica', 
		  'search_city': 'miasto',
		  'contact_email': 'Email',
		  'contact_name': 'Imię i Nazwisko', 
		  'contact_message': 'Treść' 	  	
		  }; 
	
$(document).ready(function(){
	 //$('.nieruchomosci').pngFix(); 
	 $(document).pngFix(); 
	
	$(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 });
	$("select").selectbox();
	$('#contact_table input').click( function(){
		clearInput( this );
   	 
	})
	$('#contact_table textarea').click( function(){
   	 clearTextArea( this );
	})
	
	addSearchInputLabels();
	addContactLabels();
	$( '#search_panel input[type="text"]' ).click( function(){
		clearInput( this );
	})
	$('#header_photos').innerfade({  speed: 1500, timeout: 4500, type: 'sequence', containerheight: '277px' }); 

	$("#pager  img").hover(
	function () {
		var old = $(this).attr('src');
		var newi = old.replace(".png", "_hover.png" );
		$(this).attr('src', newi ) ;
	}, 
	function () {
		var old= $(this).attr('src');
		var newi = old.replace( "_hover.png" , ".png");
		$(this).attr('src', newi ) ;
	  }
	);
});

function getProjectPath(){
	var loc = location.href.substring(0, location.href.lastIndexOf('web')+4);
	return loc;
}

function loader( element ){
	$( element ).html( '<div class="loader"></div>' );
	
}

function loading_email( element ){
	$( element ).addClass( 'email_loader' );
	$('#contact_table input').attr("disabled", "true");
	$('#contact_table textarea').attr("disabled", "true");
	$('.send_button').attr("disabled", "true");
}
function loading_email_stop( element ){
	$( element ).removeClass( 'email_loader' );
	$('#contact_table input').removeAttr("disabled");
	$('#contact_table textarea').removeAttr("disabled");
	$('.send_button').removeAttr("disabled");
	
}



	
function clearInput( input ){
	
	var c =$( input ).val();
	$.each( labels, function(key, value) { 
		if( c == value ){
			$( input ).val("");
		}
	});
	
}

function addSearchInputLabels(){
	$( '#search_panel input[type="text"]' ).each( function(){
		var id = $(this).attr( 'id' ) ;
		var val = $(this).val( ) ;
		if( val == "" ){
			$( this ).val( labels[id] );
		}
	})
}
function addContactLabels(){
	$( '#contact_table input[type="text"]' ).each( function(){
		var id = $(this).attr( 'id' ) ;
		var val = $(this).val( ) ;
		if( val == "" ){
			$( this ).val( labels[id] );
		}
	})
}
function clearTextArea( input ){
	 $( "#msg_div").text("");
	var c =$( input ).text();
	if( c == "Treść" ){
		$( input ).text("");
	}
}
