/* profitiraj.hr javascript */


var prof={};


prof.inputs = function(){
	$('input[type=text],input[type=password],textarea').each(function(){
		$(this).focus(function(){
			if($(this).val()==$(this).attr('defaultValue')) $(this).val('');
		}).blur(function(){
			if($.trim($(this).val())=='') $(this).val($(this).attr('defaultValue'));
		});
	});
};


$(document).ready(function() {
// top3 carousell
$("#top3 a").mouseover(function(){
	$("#top3 a").removeClass("act");
	$(this).addClass("act");
});
// bottom naj
$("#najnov").mouseover(function(){
	$("#naj h2").removeClass("act2");
	$("#naj div").removeClass("act2");
	$(this).addClass("act2");
	$("#najnov2").addClass("act2");
});

$("#najcit").mouseover(function(){
	$("#naj h2").removeClass("act2");
	$("#naj div").removeClass("act2");
	$(this).addClass("act2");
	$("#najcit2").addClass("act2");
});

$("#najkom").mouseover(function(){
	$("#naj h2").removeClass("act2");
	$("#naj div").removeClass("act2");
	$(this).addClass("act2");
	$("#najkom2").addClass("act2");
});
//manja veca slova na fullu
$("#cpovecaj").click(function(){	$("#complete p").addClass("big");});$("#csmanji").click(function(){	$("#complete p").removeClass("big");});
});



prof.dionice = new (function(){
	var handle = this;
	this.show = function(index){
		$('#diodabir a').each(function(i){
	 		(i==index) ? $(this).addClass('selected') : $(this).removeClass('selected');
		});
		$('#dionice table').each(function(i){
	 		(i==index) ? $(this).removeClass('inactiv') : $(this).addClass('inactiv');
		});	 
	};
	this.init = function(){ 
		$('#diodabir a').each(function(i){
			$(this).click(function(){ handle.show(i); return false; });
		});
	};
	return this;
});


prof.dionice2 = function(){
	$("#odrast").click(function(){ $("#dionice").removeClass(); $("#dionice").addClass('rast'); });
	$("#odpad").click(function(){ $("#dionice").removeClass(); $("#dionice").addClass('pad'); });
	$("#odprom").click(function(){ $("#dionice").removeClass(); });	
};


	function kreda(){
		var iznos = document.kreditna.iznos.value.replace(',','.');
		var kam = document.kreditna.kam.value.replace(',','.');
		var mje = document.kreditna.mje.value.replace(',','.');	
		var rata = iznos*(Math.pow(1+kam/100/12,mje)*(kam/100/12)/(Math.pow(1+kam/100/12,mje)-1));
		if(isNaN(rata)) document.kreditna.rata.value='Nepravilan unos!';
		else { document.kreditna.rata.value=Math.round(rata*100)/100; };
	}



prof.onready = function(){
	prof.inputs();
	prof.dionice.init();
	prof.dionice2();
};


prof.init = function(){
	$(document).ready(this.onready);
};


prof.init();

