### LEADER

## LDR 05 - n - new
marc_leader('05','n');

## LDR 06 - a - language material 
marc_leader('06','a');

## LDR 07 - Bibliographic level 
marc_leader('07','s');	

## LDR 17 - Encoding level ; 7 - minimal level, u - unknown
marc_leader('17','u');

## LDR 18 - i - isbd 
marc_leader('18','i');

## LDR 19 - Multipart resource record level ; # - Not specified or not applicable, a - Set, b - Part with independent title, c - Part with dependent title 
#marc_leader('19','a');

### 005 
marc_fixed('005','00', rec('B'));

### 008 - All materials

if ( rec('A') =~ m/20(\d{6})/ ) {
	marc_fixed('008','00', $1);	# 00-05 - Date entered on file
}

## za 008 06 treba i lookup u tablicu gdje postoji podatak o tome jel tekuci casopis ili nije?
## c - Continuing resource currently published
## d - Continuing resource ceased publication

marc_fixed('008','06','c');

marc_fixed('008','15',  		# 15-17 - Place of publication, production, or execution
	lc ( rec('Z') ) 
);

marc_fixed('008','35',
	rec('Y')		# 35-37 - Language
);
					# 38 - Modified record
					# 39 - Cataloging source

### 008 - Continuing resources
marc_fixed('008','18', rec('N') );	# 18 - Frequency
marc_fixed('008','19', rec('O') );	# 19 - Regularity
				# 20 - Undefined, ontains a blank (#) or fill character (|)

# 008 21
marc_fixed('008','21', 'p');	# 21 - Type of continuing resource

				# 22 - Form of original item - blank
				# 23 - Form of item
				# 24 - Nature of entire work
				# 25-27 - Nature of contents
				# 28 - Government publication
				# 29 - Conference publication
				# 30-32 - Undefined
				# 33 - Original alphabet or script of title
				# 34 - Entry convention

### 022
marc('022','a',
	rec('P')
);

marc('030','a',
	rec('U')
);

### 035$6
# privemeno koristimo 0356 umjesto 0359, zato što marclint 9 prijavljuje kao grešku

marc('035','a', 
	join_with('',
		'(HR-ZaDZI)P',
		rec('C')
	)
);

### 040
# za sve je isti

marc('040','a',
	'HR-ZaDZI'
);

marc('040','b',
	'hrv'
);

marc('040','e',
	'HR PPIAK'
);

### 041 - indikatori

#marc_indicators('041', 0, ' ');

### 041

#marc_repeatable_subfield('041','a',
#	rec('Y')
#);


#_debug(3);

### 044 - zemlja izdavanja

#marc('044','a',
#	rec('Z')
#);

### 080

marc('080','a',
	rec('V')
);

### 210 indikatori
# marc_indicators('210', '1',' ');

### 210 - ABBREVIATED TITLE 
marc_indicators('210','1',' ');
marc('210','a',
	rec('T')
);
	


### 222 indikatori
# drugi indikator prema članu
# potrebna naknadna kontrola

marc_indicators('222',' ','0');

### 222 - Key title

marc('222','a',
	rec('Q')
);

### 245 indikatori
# generiraju se prema članu, trebalo bi možda i prema jeziku (jezika nema uvijek). 
# potrebna naknadna kontrola

marc_indicators('245', 0, 0);

if ( 	( rec('E') =~ m/^Die /) || 
	( rec('E') =~ m/^Das /) || 
	( rec('E') =~ m/^Der /) || 
	( rec('E') =~ m/^Les /) || 
	( rec('E') =~ m/^The /) ) {
		marc_indicators('245', 0, 4);

} 

if (	( rec('E') =~ m/^Un /) || 
	( rec('E') =~ m/^An /) ||
	( rec('E') =~ m/^La /) ||
	( rec('E') =~ m/^Le /) ||
	( rec('E') =~ m/^Il /) ) {
		marc_indicators('245', 0, 3);
} 

if (	( rec('E') =~ m/^A /) || 
	( rec('E') =~ m/^L'/) ) {
		marc_indicators('245', 0, 2);
} 

### 245

my $naslov = '' ;
my $podnaslov = '' ;
my $odgovornost = '' ;

if ( rec('E') =~ m/\$a(.*)\$e(.*)\$f(.*)/ ) {
	$naslov = $1;
	$podnaslov = $2;
	$odgovornost = $3;
} elsif ( rec('E') =~ m/\$a(.*)\$e(.*)/ ) {
	$naslov = $1;
	$podnaslov = $2;
} elsif ( rec('E') =~ m/\$a(.*)\$f(.*)/ ) {
	$naslov = $1;
	$odgovornost = $2;
} elsif ( rec('E') =~ m/\$a(.*)/ ) {
	$naslov = $1;
}
marc('245','a', $naslov);
marc('245','b', $podnaslov);
marc('245','c', $odgovornost);


### 246 inikatori

### 246

#_debug(0);


## 260 - izdavanje

my $mjesto = '' ;
my $izdavac = '' ;

if ( rec('H') =~ m/\$a(.*)\$c(.*)/ ) {
	$mjesto = $1 . ' :';
	$izdavac = $2 . ', ';
}
marc('260','a', $mjesto);
marc('260','b', $izdavac);
marc('260','c',
	rec('G')
);

## 300
marc('300','a', ' sv. :');
marc('300','c',
	rec('K')
);

## 310

marc('310','a',
	rec('L')
);

marc('500','a',
	rec('AA')
);

marc_indicators('780',' ','0');
marc('780','t',
	rec('R')
);

marc_indicators('785',' ','0');
marc('785','t',
	rec('S')
);

marc('942','c','C');

marc('952','a',
	lookup(
		sub { rec('K') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','b',
	lookup(
		sub { rec('K') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','d',
	lookup(
		sub { rec('I') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','h',
	lookup(
		sub { join_with('', 
			join_with(':',
				rec('E'),
				rec('F'), 
			),
			rec('D')
			
		) },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','r',
	lookup(
		sub { rec('M') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','t',
	lookup(
		sub { rec('H') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);

marc('952','y',
	lookup(
		sub { rec('P') },
		'dziv','inventar',
		sub { rec('A') },
		sub { rec('C') }
	)
);
