	cnt = 0;
	index = 0;
	var top5fx = [];
	var bot5fx = [];
	var per;
	var fx2;
	
	

    window.addEvent("domready",function() {
    	
    	if ($("formaPreg")) {
	    	new FormCheck('formaPreg', {
	    		display : {
	    			errorsLocation : 1,
	    			indicateErrors : 1,
	    			showErrors : 0
	    		}
	    	});
	    }
	    
    	
    	var mySmoothScroll = new Fx.SmoothScroll({
		    wheelStops: false
		});
    
    	if ($('slideshow')){
	        $$("div.slide").each(function(el, index){
	            if(el.getStyle("display")=="none"){
	                el.setStyles({"display": "block", "opacity": "0"});
	            }
	            if(index==0) el.setStyles({"display": "block", "opacity": "1"});
	            top5fx.push(new Fx.Tween(el, {duration:750, wait:false}));
	        })
	        
	        
	        $$("img.clickableImage").each(function(el, index){
	        
	            bot5fx.push(new Fx.Tween(el, {duration:750, wait:false}));
	            el.setStyle("cursor","pointer");
	            el.setProperty("res", index);
	             
	            el.addEvents({
	                "click":function(){
	                    $clear(per);
	                  
	                   $$("img.clickableImageActive").each(function(ele){
	                     ele.removeClass("clickableImageActive");
	                     ele.setProperty("src","img/slideshowDotEmpty.png");
	                   });
	                     
	                    el.addClass("clickableImageActive");
	                    
	                    el.setProperty("src","img/slideshowDot.png");
	                    
	                    $$("div.slide").each(function(el, index){
	                        if(el.getStyle("opacity")!=0) {
	                            top5fx[index].start('opacity', 0);
	                        }
	                    });		
	                    		
	                    top5fx[el.getProperty("res")].start('opacity', 1);	
	                    
	                    cnt=index;
	                    per = fx.periodical(5000);
	                }
	            })
	        })
	        
	        per = fx.periodical(5000);
	        
	        $('arrowleft').setStyle("cursor","pointer");
	        $('arrowright').setStyle("cursor","pointer");
	        $('arrowleft').addEvents({
        		mouseover: function(){
			        $('arrowleft').setProperty("src","img/arrowLeftHover.png");
			    },
			    mouseout: function(){
			        $('arrowleft').setProperty("src","img/arrowLeft.png");
			    },
                "click":function(){
                    fx('minus');
                }
            });
            
            $('arrowright').addEvents({
        		mouseover: function(){
			        $('arrowright').setProperty("src","img/arrowRightHover.png");
			    },
			    mouseout: function(){
			        $('arrowright').setProperty("src","img/arrowRight.png");
			    },
                "click":function(){
                    fx();
                }
            });
            
            
            index = 0;
        
	        $$("div.tabsDiv").each(function(el, index){
	            if(el.getStyle("display")=="none"){
	                el.setStyles({"display": "block", "opacity": "0"});
	            }
	            if(index==0) el.setStyles({"display": "block", "opacity": "1"});
	        })
	        
	        $$("a.tabs2").each(function(el, index){
	            el.addEvents({
	                "click":function(){
	                    $$("a.tabs2").each(function(ele){
	                    	ele.offsetParent.removeClass("tabActive");
	                    });
	                    el.offsetParent.addClass("tabActive");
	                 
	                    $$("div.tabsDiv").each(function(ele, index2){
	                        if(ele.getStyle("opacity")!=0) {
	                            ele.setStyle('opacity', 0);
	                        }
	                        if(index==index2) {
	                        	ele.setStyle('opacity', 1);
	                        }
	                    });		
	                }
	            })
	        })
            
	        
    	}
    	

    })
    
	
    var moze=1;
    function fx(kam){
    	if (moze==1){
    		moze=0;
	    	$clear(per);
	        if (kam=='minus'){
	        	cnt--;
	        }else{
	        	cnt++;
	        }
	    	
	        if (cnt==top5fx.length) cnt = 0;
	        if (cnt<0) cnt = top5fx.length-1;
	       // alert(cnt);
	        top5fx[cnt].start('opacity', 1);
	       
		    $$("img.clickableImageActive").each(function (el){
	            el.removeClass("clickableImageActive");
	            el.setProperty("src","img/slideshowDotEmpty.png");
	            
	        })
	        $$("img.clickableImage")[cnt].addClass("clickableImageActive");
	        $$("img.clickableImage")[cnt].setProperty("src","img/slideshowDot.png");
	        $$("div.slide").each(function(el, indx){
	            if(el.getStyle("opacity")!=0){
	                top5fx[indx].start('opacity', 0).chain(function(){
	                	moze=1;
	                });
	            }
	        })
	        per = fx.periodical(5000);
	    }
    }
    
    
    
    function racunaj(){
    	
    	if ($("god").value=="") {
    		alert("Molimo upišite svoje godine!")
    		return;
    	}
    	if ($("diop").value=="") {
    		alert("Molimo upišite svoju diptriju!")
    		return;
    	}
    	
    	
    	var rez = 0.0;
    	var godine = parseInt($("god").value);
    	var nofci;
    	var nofciOfta;
    	var novciLeceOtop;
    	var diop = parseInt($("diop").value.replace("+",""));
    	var cili = parseInt($("cili").value.replace("+",""));
    	    	
    	if ($("selOdabir1").value==1){        		 
    		nofci = $("novciNaoc").value.replace(/,/gi,".");   	
    		nofciOfta = $("novciNaocOfta").value.replace(/,/gi,".");   	
    		rez = ((50 - godine)*nofci) + ((50 - godine)*nofciOfta);
    		$("rez").innerHTML = "<strong>Očekivana potrošnja na naočale do Vaše 50. godine iznosi " + rez.toString().replace(".",",") + " Kn</strong><br /><br />";	
    	} else if ($("selOdabir1").value==2){   		
    		nofci = $("novciLece").value.replace(/,/gi,".");    	
    		nofciOfta = $("novciLeceOfta").value.replace(/,/gi,".");
    		novciLeceOtop = $("novciLeceOtop").value.replace(/,/gi,".");
    		rez = ((50 - godine)*nofci) + ((50 - godine)*nofciOfta) + ((50 - godine)*novciLeceOtop);
    		$("rez").innerHTML = "<strong>Očekivana potrošnja na leće do Vaše 50. godine iznosi " + rez.toString().replace(".",",") + " Kn</strong><br /><br />";   			
    	}   	
    	
    	if (diop>=-10 && diop<=5 && cili>=-5 && cili<=5) {
			$("rez").innerHTML += "Vi ste najvjerojatnije kandidat za lasersku operaciju te bi trebali posjetiti Kliniku Svjetlost zbog pregleda za sam zahvat, za pregled se možete naručiti <a href='http://www.svjetlost.hr/rezervirajte-vas-termin-za-pregled'>ovdje</a>.";
		} else {
			$("rez").innerHTML += "Dioptrija koju ste unjeli je pre visoka za skidanje laserom, ali svjedno dođite na pregled jer nudimo i druge metode korekcije dioptrije, Vaš termin možete rezervirati <a href='http://www.svjetlost.hr/rezervirajte-vas-termin-za-pregled'>ovdje</a>."
		}
		
		$("rez").style.display='block';		
		$("rez2").style.display='block';
		
    }
    
    
 
