$(function () {
    if ($.browser.msie && $.browser.version < 7) return;
        $('#navigation li')
            .removeClass('highlight')
            .find('a')
            .append('<span class="hover" />').each(function () {
                var $span = $('> span.hover', this).css('opacity', 0);
                $(this).hover(function () {
                    // on hover
                    $span.stop().fadeTo(400, 1);
                }, function () {
                    // off hover
                    $span.stop().fadeTo(400, 0);
                });
            });
});
$(document).ready(function(){
	$('.kprednosti').css('display','none');
	$('.tocke ul li a').click(function(){
		$('.kprednosti').css('display','block');
		$('.kprednosti').empty();
		$('.kprednosti').append($(this).attr('opis'));
	});
});

function vpis_st_licenc (lic) {
var select_polje_licenca = document.getElementById('licenca').value;
if(document.getElementById('sum_obuka').value == "") {
document.getElementById('sum_obuka').value = 0; 
}
if(document.getElementById('sum_dodaci').value == "") {
document.getElementById('sum_dodaci').value = 0; 
}

	if (select_polje_licenca != "X") {
		//alert (select_polje_licenca);
		document.getElementById('broj_licence').value = "";
		document.getElementById('sum_licence').value = document.getElementById('sum_obuka').value;
		
		document.getElementById('sum_licence_dodaci').value = parseInt(document.getElementById('sum_obuka').value)+parseInt(document.getElementById('sum_dodaci').value);
		document.getElementById('sum_licence_dodaci1').value = parseInt(document.getElementById('sum_obuka').value)+parseInt(document.getElementById('sum_dodaci').value);
		
		document.getElementById('broj_licence').disabled = false;
	}else{
	document.getElementById('sum_licence').value = document.getElementById('sum_obuka').value;
	document.getElementById('sum_licence_dodaci').value = parseInt(document.getElementById('sum_obuka').value)+parseInt(document.getElementById('sum_dodaci').value);
		document.getElementById('sum_licence_dodaci1').value = parseInt(document.getElementById('sum_obuka').value)+parseInt(document.getElementById('sum_dodaci').value);
		document.getElementById('broj_licence').value = "";
		document.getElementById('broj_licence').disabled = true;
	}
}

function izracun_obuka () {
var st_ur = document.getElementById('sati_obuke').value;
	document.getElementById('sum_obuka').value = st_ur * 25;
	izracun_licenc();
}

/* V.B. 110627 --------------------------------------------------------------- */
function izracun_podmodula (cena,idd) {
var grandtotalField = document.getElementById('sum_podmoduli');
var grandtotalValue = document.getElementById('sum_podmoduli').value;
if (grandtotalValue == "") {
grandtotalValue = 0;
} 
if (document.getElementById(idd).checked == true) {
		grandtotalField.value = parseInt(grandtotalValue) + parseInt(cena);
	}else{
		grandtotalField.value = grandtotalValue - cena;
	}
	/*izracun_skupaj();*/
	izracun_licenci();
}

function izracun_dodmoduli (cena,idd) {
var grandtotalField = document.getElementById('sum_dodmoduli');
var grandtotalValue = document.getElementById('sum_dodmoduli').value;
if (grandtotalValue == "") {
grandtotalValue = 0;
} 
if (document.getElementById(idd).checked == true) {
		grandtotalField.value = parseInt(grandtotalValue) + parseInt(cena);
	}else{
		grandtotalField.value = grandtotalValue - cena;
	}
	/*izracun_skupaj();*/
	izracun_licenci();
}

function izracun_opcije (cena,idd) {
var grandtotalField = document.getElementById('sum_opcije');
var grandtotalValue = document.getElementById('sum_opcije').value;
if (grandtotalValue == "") {
grandtotalValue = 0;
} 
if (document.getElementById(idd).checked == true) {
		grandtotalField.value = parseInt(grandtotalValue) + parseInt(cena);
	}else{
		grandtotalField.value = grandtotalValue - cena;
	}
izracun_skupaj();
}

function izracun_implementacije() {
	var st_ur = document.getElementById('impl_2').value;
	document.getElementById('sum_implementacija').value = st_ur * 20;
	
	izracun_skupaj();
}

function izracun_licenci() {

var znesek_licenca = document.getElementById('licenca').value;
var broj_licenca = document.getElementById('broj_licence');
var suma_licenca = document.getElementById('sum_licence');
var suma_licenca_val = document.getElementById('sum_licence').value;
var suma_podmoduli = document.getElementById('sum_podmoduli').value;
var suma_dodmoduli = document.getElementById('sum_dodmoduli').value;
//alert();
if (suma_podmoduli == "") {
	suma_podmoduli = 0;
}
if (suma_dodmoduli == "") {
	suma_dodmoduli = 0;
}
if (znesek_licenca == "X") {
	znesek_licenca = 0;
}

if (broj_licenca.value == parseInt(broj_licenca.value) || broj_licenca.value == ""){
	if (broj_licenca.value <= 4) {
		broj_licenca.style.backgroundColor = '';
		suma_licenca.value = parseInt((parseInt(znesek_licenca)+parseInt(suma_podmoduli)+parseInt(suma_dodmoduli))*0.2*parseInt(broj_licenca.value));
		/*suma_licenca.value = parseInt((((znesek_licenca)+(suma_podmoduli))*0.2)*(broj_licenca.value));*/
	}else{
		broj_licenca.value = "";
		broj_licenca.style.backgroundColor = '#E2F4FD';
		mozBug = document.getElementById('broj_licence').id;
		setTimeout("document.getElementById(mozBug).focus()",0);
		alert("Broj licenci ne može biti veći od 4!");
	}
	izracun_skupaj();
}else{
	broj_licenca.value = "";
	broj_licenca.style.backgroundColor = '#E2F4FD';
	mozBug = document.getElementById('broj_licence').id;
	setTimeout("document.getElementById(mozBug).focus()",0);
	alert("Molim unesite brojke!");
}
//alert (cena_elementa);
}

function izracun_skupaj () {
	if (document.getElementById('licenca').value == "") {
		var Sosn = 0;
	}else{
		var Sosn = parseInt(document.getElementById('licenca').value);
	}
	
	if (document.getElementById('sum_licence').value == "") {
		var Slic = 0;
	}else{
		var Slic = parseInt(document.getElementById('sum_licence').value);
	}
	
	if (document.getElementById('sum_podmoduli').value == "") {
		var Spod = 0;
	}else{
		var Spod = parseInt(document.getElementById('sum_podmoduli').value);
	}
	
	if (document.getElementById('sum_dodmoduli').value == "") {
		var Sdod = 0;
	}else{
		var Sdod = parseInt(document.getElementById('sum_dodmoduli').value);
	}
	
	if (document.getElementById('sum_opcije').value == "") {
		var Sopc = 0;
	}else{
		var Sopc = parseInt(document.getElementById('sum_opcije').value);
	}
	
	if (document.getElementById('sum_implementacija').value == "") {
		var Simpl = 0;
	}else{
		var Simpl = parseInt(document.getElementById('sum_implementacija').value);
	}
	
document.getElementById('sum_podmoduli_1').value = (Spod);
document.getElementById('sum_dodmoduli_1').value = (Sdod);
document.getElementById('sum_opcije_1').value = (Sopc);
document.getElementById('sum_implementacija_1').value = (Simpl);

document.getElementById('sum_sum').value = (Sosn + Slic + Spod + Sdod + Sopc + Simpl);

izracun_ugovor();
}

function izracun_ugovor () {
	if (document.getElementById('sum_implementacija').value == "") {
		var Simpl = 0;
	}else{
		var Simpl = parseInt(document.getElementById('sum_implementacija').value);
	}
	
	if (document.getElementById('sum_sum').value == "") {
		var Ssum = 0;
	}else{
		var Ssum = parseInt(document.getElementById('sum_sum').value);
	}
	
	document.getElementById('sum_odrzavanje_s').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.07);
	document.getElementById('sum_odrzavanje_b').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.03);
	
	document.getElementById('sum_najam_avans').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.2);
	document.getElementById('sum_najam_1').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.1);
	document.getElementById('sum_najam_2').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.11);
	document.getElementById('sum_najam_3').value = Math.round((parseInt(Ssum)-parseInt(Simpl))*0.14);
	
	document.getElementById('impl_1').value = (parseInt(Ssum)-parseInt(Simpl))/100;
	
}

/* ---------------------------------------------------------------------------- */

function izracun_dodatki (cena,idd) {
var grandtotalField = document.getElementById('sum_dodaci');
var grandtotalValue = document.getElementById('sum_dodaci').value;
if (grandtotalValue == "") {
grandtotalValue = 0;
} 
/*alert (grandtotalValue);
for(var c=0; c <= 3; c++) {
	if(document.getElementById('dod_'+c+'').checked == true){
	sum_dodaci += parseInt(document.getElementById('dod_'+c+'').value);
	}
}
*/
if (document.getElementById(idd).checked == true) {
	grandtotalField.value = parseInt(grandtotalValue) + parseInt(cena);
}else{
	grandtotalField.value = grandtotalValue - cena;
}
izracun_skupaj();
}

function izracun_licenc() {

var znesek_licenca = document.getElementById('licenca').value;
var broj_licenca = document.getElementById('broj_licence');
var suma_licenca = document.getElementById('sum_licence');
var suma_licenca_val = document.getElementById('sum_licence').value;
var suma_obuka = document.getElementById('sum_obuka').value;
//alert();
if (suma_obuka == "") {
	suma_obuka = 0;
}
if (znesek_licenca == "X") {
	znesek_licenca = 0;
}

if (broj_licenca.value == parseInt(broj_licenca.value) || broj_licenca.value == ""){
	broj_licenca.style.backgroundColor = '';
	
	if (broj_licenca.value <= 3) {
	suma_licenca.value = parseInt((broj_licenca.value)*(znesek_licenca))+ parseInt(suma_obuka);
	}else{
		lic_nad_3 = (broj_licenca.value - 3);
		suma_licenca.value = parseInt(3 * znesek_licenca) + parseInt(lic_nad_3 * (znesek_licenca / 2)) + parseInt(suma_obuka);
	}
	izracun_skupaj();
}else{
broj_licenca.value = "";
broj_licenca.style.backgroundColor = '#E2F4FD';
mozBug = document.getElementById('broj_licence').id;
setTimeout("document.getElementById(mozBug).focus()",0);
	alert("Molim unesite brojke!");
}
//alert (cena_elementa);
}

/*function izracun_skupaj () {
if (document.getElementById('sum_licence').value == "") {
var Slic = 0;
}else{
var Slic = parseInt(document.getElementById('sum_licence').value);
}
if (document.getElementById('sum_dodaci').value == "") {
var Sdod =0;
}else{
var Sdod = parseInt(document.getElementById('sum_dodaci').value);
}
document.getElementById('sum_licence_dodaci').value = (Slic + Sdod);
document.getElementById('sum_licence_dodaci1').value = (Slic + Sdod);
}*/
