
$(document).ready(function(){
	if($('.thickbox').length > 0){
		$('.thickbox').fancybox({
			'hideOnContentClick': true,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});
	}
});
	
function startBannerCarousel(){
    pendingAnimation = false;
    bannerTimer = null;
    activeBanner = 0;
    bannerCount = jQuery(".flash .banners li").length;
    if (bannerCount > 1) {
        $("#menuHolder").css({"z-index": 2000});
        bannerContainer = $(".flash");
	$(".banners li", bannerContainer).css({opacity: 0.0});
	$(".banners li:first", bannerContainer).css({opacity: 1.0});
        bannerTimer = setInterval("rotateBannerCarousel()", 25000);
        $(".nav a", bannerContainer).click(function(e){
            e.preventDefault();
            if (pendingAnimation) {
                return false;
            }
            stopBannerCarousel();
            skipBannerCarousel($(".nav a", bannerContainer).index(this));
            bannerTimer = setInterval("rotateBannerCarousel()", 25000);
        });
        $(".flash .banners li").hover(
			function () {
				stopBannerCarousel();
			}, 
			function () {
				bannerTimer = setInterval("rotateBannerCarousel()", 25000);
			}
		);
    }
}

function stopBannerCarousel(){
    if (bannerTimer === null) {
        return;
    }
    clearInterval(bannerTimer);
}

function rotateBannerCarousel(){
    pendingAnimation = true;
    $(".banners li:eq(" + activeBanner + ")", bannerContainer).animate({opacity: 0.0}, 1000, function(){$(this).removeClass("active");});
    $(".nav li:eq(" + activeBanner + ")", bannerContainer).removeClass("active");
    activeBanner++;
    if (activeBanner >= bannerCount) {
        activeBanner = 0;
    }
    $(".banners li:eq(" + activeBanner + ")", bannerContainer).css({opacity: 0.0}).addClass("active").animate({opacity: 1.0}, 1000, function(){pendingAnimation = false;});
    $(".nav li:eq(" + activeBanner + ")", bannerContainer).addClass("active");
}

function skipBannerCarousel(i){
	if (i == activeBanner) {
		return;
	}
    pendingAnimation = true;
    $(".banners li:eq(" + activeBanner + ")", bannerContainer).animate({opacity: 0.0}, 1000, function(){$(this).removeClass("active");});
    $(".nav li:eq(" + activeBanner + ")", bannerContainer).removeClass("active");
    activeBanner = i;
    $(".banners li:eq(" + activeBanner + ")", bannerContainer).css({opacity: 0.0}).addClass("active").animate({opacity: 1.0}, 1000, function(){pendingAnimation = false;});
    $(".nav li:eq(" + activeBanner + ")", bannerContainer).addClass("active");
}

$(function(){
    startBannerCarousel();
});


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

/* google maps - starts */

function showMap() {

  var myOptions = {
    zoom: 16,
    center: new google.maps.LatLng(54.692373, 25.406726),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
	scrollwheel: false
  }
  var map = new google.maps.Map(document.getElementById("map"), myOptions);

  setMarkers(map, offices);

}


var offices = [
  ['Vieta 1', 54.692373, 25.406726, 1]
]

function setMarkers(map, locations) {
  var image = new google.maps.MarkerImage('/img/icon.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(113, 89),
      // 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(58, 89));

  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]
    });
  }
}

$(function(){
	if($('#map').length > 0){
		showMap();
	}
	
/* external link - starts */

	$('a[rel~="external"]').click(function(){$(this).attr({'target':'_blank'});});	
	
/* external link - ends */	
	
});




/* google maps - ends */
