﻿// JavaScript Document
 $(document).ready(function(){
	 
	 var logoi = $('.logo').css('left','-3000px');
	 i=0;
	(function prikaziLogoe()
		 {
			
			logoi.eq(i++).hide().css('left','0px').fadeIn(80,prikaziLogoe);
			 })();
	 
$('#workhour #left').animate({
    
    top: '0px'
  }, 1000, function() {
    // Animation complete.
	
	 $('#workhour #mid').animate({
    
    top: '0px'
  }, 1000, function() {
	  $('#workhour #right').animate({
    
    top: '0px'
  }, 1000, function() {
    // Animation complete.
  });
    // Animation complete.
  });	
	
  });
  
$('#inlogocontainer div').click(function(){
	$('#topdiv').fadeIn(500);
	var whichid = $(this).attr('id');
	var idbox = "trgovina[name="+whichid+"]";
		$.ajax({
			type: "GET",
			url: "new/trgovine.xml",
			dataType: "xml",
			success: function(xml) {
		 	
				 $(xml).find(idbox).each(function(){
					 var imefirme = $(this).find('name').text();
					 var slika = $(this).find('slika').text();
					 slika="<img src=\"new/img/trgovine/"+slika+"\" width=\"400\" height=\"300\" style=\"padding:15px;border:1px solid #000;background:#ddd;float:left;margin-right:10px;\">"
					 var kratkiopis = $(this).find('kratkiopis').text();
					 var etaza = $(this).find('etaza').text();
					 var webstranica = $(this).find('webstranica').text();
					 webstranica="<a id=\"linknastranicu\" href=\""+webstranica+"\">"+webstranica+"</a>";
					 var kontakt = $(this).find('kontakt').text();
					 $('#imefirme').html(imefirme);
					 $('#slika').html(slika);
					 $('#kratkiopis').html(kratkiopis);
					 $('#etaza').html(etaza);
					 $('#kontakt').html(kontakt);
					 $('#webstranica').html(webstranica);
				 }); 			
			
			}
		});
	
	}); 

$('#topdiv').click(function(){
	$('#topdiv').fadeOut(500);
	}); 


$('#inlogocontainer div').mouseover(function(){
	var whichid = $(this).attr('id');
	var animateonmouseover = "#click"+whichid;
	var animateonmouseovermsg = "#clickmsg"+whichid;
	$(animateonmouseover).stop().animate({ 
		top: '30',
		}, 100, function() {
		// Animation complete.
		});
	$(animateonmouseovermsg).stop().animate({ 
		top: '25',
		}, 100, function() {
		// Animation complete.
		});  
	});
	
$('#inlogocontainer div').mouseout(function(){
	var whichid = $(this).attr('id');
	var animateonmouseover = "#click"+whichid;
	var animateonmouseovermsg = "#clickmsg"+whichid;
	$(animateonmouseover).stop().animate({ 
		top: '60',
		}, 100, function() {
		// Animation complete.
		});
	$(animateonmouseovermsg).stop().animate({ 
		top: '60',
		}, 100, function() {
		// Animation complete.
		});  
	});


(function slideshow(){
	
$('.active').delay(4000).animate({ 
		left: '600',
		}, 500, function() {
		// Animation complete.
		});


$('.next').delay(4000).animate({ 
		left: '10',
		}, 500, function() {
		// Animation complete.

    	var whichactive = $('.active').attr('id');
		if(whichactive==1){
			$('.active').removeClass('active');
			$('.next').removeClass('next').addClass('active');
			$('#3').addClass('next');
			slideshow()
			}
		if(whichactive==2){
			$('.active').removeClass('active');
			$('.next').removeClass('next').addClass('active');
			$('#1').addClass('next');
			slideshow()
			}
		if(whichactive==3){
			$('.active').removeClass('active');
			$('.next').removeClass('next').addClass('active');
			$('#2').addClass('next');
			slideshow()
			}
		});
	
	
	
	})();

// prikaz karte splita
$('#showmap').click(function(){
	$('#topdiv2').fadeIn(500);
});

$('#topdiv2').click(function(){
	$('#topdiv2').fadeOut(500);
	}); 


// prikaz kataloga
$('#showkatalog').click(function(){
	$('#topdiv3').fadeIn(500);
});

$('#topdiv3').click(function(){
	$('#topdiv3').fadeOut(500);
	}); 
	 
   // Your code here
 });
