$('document').ready(function(){

$("#nav li").hover(
	function () {
		$(this).addClass("hover");
	}, 
	function () {
		$(this).removeClass("hover");
	}
);

$("#contentInner .blockTop").hover(
	function () {
		$(this).addClass("hover");
	}, 
	function () {
		$(this).removeClass("hover");
	}
);
	
$('.tourNavigation a.link').click(function() {

	$('.tourNavigation a.link').removeClass('active');
	$(this).addClass('active');
	
	$('.tuorHolder .tourBlock').removeClass('activeBlock');
	var show_block = $(this).attr('id');
	show_block = show_block.substring(4);
	$('.tour'+show_block).addClass('activeBlock');
	
	if($(this).hasClass('link4')){
		$('.tourNavigation a.next').parents('li').addClass('no');
	}else{
		$('.tourNavigation a.next').parents('li').removeClass('no');
	};
	if($(this).hasClass('link1')){
		$('.tourNavigation a.back').parents('li').addClass('no');
	}else{
		$('.tourNavigation a.back').parents('li').removeClass('no');
	};	
	return false;
	
});	

$('.tourNavigation a.next').click(function() {

	if($('.tourNavigation a.active').hasClass('link1')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.back').parents('li').removeClass('no');		
		$('.tourNavigation a.link2').addClass('active');
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour2').addClass('activeBlock');			
	}else if($('.tourNavigation a.active').hasClass('link2')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.link3').addClass('active');
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour3').addClass('activeBlock');			
	}else if($('.tourNavigation a.active').hasClass('link3')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.link4').addClass('active');
		$('.tourNavigation a.next').parents('li').addClass('no');
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour4').addClass('activeBlock');			
	}else if($('tourNavigation a.active').hasClass('link4')){
		return false;
	};
	return false;
	
});	

$('.tourNavigation a.back').click(function() {

	if($('.tourNavigation a.active').hasClass('link4')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.next').parents('li').removeClass('no');			
		$('.tourNavigation a.link3').addClass('active');
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour3').addClass('activeBlock');			
	}else if($('.tourNavigation a.active').hasClass('link3')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.link2').addClass('active');
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour2').addClass('activeBlock');			
	}else if($('.tourNavigation a.active').hasClass('link2')){
		$('.tourNavigation a.link').removeClass('active');
		$('.tourNavigation a.link1').addClass('active');
		$('.tourNavigation a.back').parents('li').addClass('no');		
		$('.tuorHolder .tourBlock').removeClass('activeBlock');		
		$('.tuorHolder .tour1').addClass('activeBlock');			
	}else if($('tourNavigation a.active').hasClass('link1')){
		return false;
	};
	return false;
	
});	
	
	
});

//----------------------------------------------------------------------------------------------------------------------------------	

/* google maps - starts */

function showMap() {

  var myOptions = {
    zoom: 13,
    center: new google.maps.LatLng(56.985910, 24.120976),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map"), myOptions);

  setMarkers(map, offices);
  
  
}


var offices = [['Auda Audari', 56.985910, 24.120976, 1]];

function setMarkers(map, locations) {
  var image = new google.maps.MarkerImage('images/icon.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(26, 26),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(7, 26));

  for (var i = 0; i < locations.length; i++) {
    var office = locations[i];
    var myLatLng = new google.maps.LatLng(office[1], office[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image,
        title: office[0],
        zIndex: office[3]
    });
  }
}

if($('#map').length > 0){
	showMap();
}


/* google maps - ends */

$(function(){
    var pikasomaPrUl = $('ul.pikasomaPrUl');
    if(pikasomaPrUl.length > 0){
        $('li:first-child').addClass('first');
        var lia = pikasomaPrUl.children('li').children('a');
        if(lia.length > 0){
            lia.click(function(){
                var li = $(this).parents('li');
                var liul = $('ul', li);
                if(liul.length > 0){
                    if(liul.is(':visible')){
                        li.removeClass('active');
                        liul.hide();
                    }else{
                        li.addClass('active');
                        liul.show();
                    }
                    return false;
                }
                return true;
            });
        }
    }
    
    /* load fancybox */
	var fancy = $('a.fancybox');
	if(fancy.length > 0){
		fancy.fancybox();
	}
    
});

$(function(){
	var tour = $('#footer .footer .tour');
	if(tour.length > 0){
		var a = $('a:first', tour);
		if(a.length > 0){
			tour.click(function(){
				window.location = a.attr('href');
			});
		}
	}
});
