$(window).load(function(){
	$('#tabs').tabs({
					 load: function(event, ui) { 
						 $('.content h4').click(function(){
							$(this).next().toggle();
						});
				 }
	});
	
	
	$('.flexslider').flexslider({
		animation: 'slide',
		controlsContainer: '#slider',
		controlNav: false
	});
	$('input:radio, input:checkbox, select, textarea').uniform();
	$('input:text').focus(function(){
		var newValue = $(this).val();
		var defValue= $(this).attr('rel');
		if($(this).val() == defValue){
		$(this).attr('value','');
		} else {
		$(this).val(newValue);
		}
	});
	$('input:text').blur(function(){
		var newValue = $(this).val();
		var defValue= $(this).attr('rel');
		if($(this).val() == ''){
		$(this).attr('value', defValue);
	} else {
		$(this).val(newValue);
	}
	});
	
	$( "input[name='bill_type']").change( function( ){
		bill_type();
	} );
	
	if( $( "input[name='bill_type']").val( ) )
		bill_type();
	
	function bill_type()
	{
		$( ".invoice_h" ).show( );
		$( "#invoice_ul" ).show( );
		
		$( ".ds" ).remove( );
		if( $( "input[name='bill_type']:checked").val( ) == 1 )
		{
			console.log( add_reg );
			$( "#company_name" ).parent( ).show( );
			
			if( add_reg == "undefined" || add_reg != "1" )
			{
				$( "#company_name" ).after( "<span class='ds'>pole obowiązkowe" );
				$( "#nip" ).after( "<span class='ds'>pole obowiązkowe" );
			}
		}
		else
		{
			$( "#company_name" ).val( "" );
			$( "#company_name" ).parent().hide( );
		}
	}
	
	$( "#accordion" ).accordion( );
	
	$( ".newWindow" ).click( function( ){
		window.open( $( this ).attr( "href" ) );
		return false;
	} );
});
