﻿$(document).ready(function(){

	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed: 'normal', slideshow: 3000, deeplinking: false, overlay_gallery: false, social_tools: '', theme: 'facebook'});
	$("a[rel='prettyPhoto[image]']").prettyPhoto({animationSpeed: 'normal', slideshow: 3000, deeplinking: false, overlay_gallery: true, social_tools: '', theme: 'facebook'});

    $("body > div.back-window").height($(document).height());

    $("body > div.open-window a.close").bind("click", function(){
		$("body > div.open-window").fadeOut(300, function(){
			$("body > div.back-window").hide();
		});
		return false;
	});

    $("#content ul.technologies li div.right > h3 a").click(function(){
    	$(this).closest("li").children("div.more").slideToggle(500).siblings("li div.more:visible").slideUp(300);
    	$(this).closest("li").children("div.short").hide();
    	$(this).closest("li").toggleClass("active");
        $(this).closest("li").siblings("li.active").children("div.more").slideToggle(500);
        $(this).closest("li").siblings("li").removeClass("active");
    	//return false;
    });
	
	$('#sections > li > div.title a').bind('click', function(){
		if($(this).hasClass('active')) return false;
		$('#sections > li').removeClass('active').find('div.body').slideUp(300);
		$(this).closest('li').addClass('active').find('div.body').slideDown(300);
		return false;
	});
	

	$('#map-layer').bind('mousemove', function(e){
		if(Map.opened){
			var offset = $('#map-layer').offset();
			$('#map > div.tips').css({left:(e.pageX-offset.left)+'px', top:(e.pageY-offset.top)+'px'});
		}
	});
	
	$('#map > div.tips').bind('mouseenter', function(){
		$('#map > div.tips').css({zIndex:-1});
	});
	$('#map > div.tips').bind('mouseleave', function(){
		$('#map > div.tips').css({zIndex:1});
	});
	
	
	$('#content div.map-clients div.regions a').bind('mouseenter', function(){
		Map.getFlash().showRegion($(this).attr('rel'));
	});
	$('#content div.map-clients div.regions a').bind('mouseleave', function(){
		Map.getFlash().hideRegion($(this).attr('rel'));
	});

});


var Map = {
	x: 0,
	y: 0,
	getFlash: function () {
		var M$ =  navigator.appName.indexOf("Microsoft")!=-1;
		return (M$ ? window : document)["mapFlash"];
	},
	regions: {},
	showTips: function(region_id){
		this.hideTips();
		if(this.regions[region_id]){
			var region = this.regions[region_id];
			$('#map > div.tips > div').text(region.title);
			$('#map > div.tips').show();
			$('#content div.map-clients div.regions a[rel='+region_id+']').addClass('active');
			this.opened = true;
		}			
	},
	hideTips: function(){
		$('#map > div.tips').hide();
		this.opened = false;
		$('#content div.map-clients div.regions a').removeClass('active');
	}
	}
	
	
