$(function(){
	$(".tiptip").tipTip();
});

$(document).ready(function() {
	$('div.lang a').animate({opacity: 0.5},1000, function(){});
	$('a.opacity-hover img').animate({opacity: 0},'fast', function(){});
		
	var keys = [37, 38, 39, 40];

	function preventDefault(e) {
		e = e || window.event;
		if (e.preventDefault)
		e.preventDefault;
		event.returnValue = false;  
	}

	function keydown(e) {
    	for (var i = keys.length; i--;) {
        	if (e.keyCode === keys[i]) {
            	preventDefault(e);
           	 return;
        	}
    	}
	}

	function wheel(e) {
		preventDefault(e);
	}

	function disable_scroll() {
		if (window.addEventListener) {
			window.addEventListener('DOMMouseScroll', wheel, false);
		}
		window.onmousewheel = document.onmousewheel = wheel;
		document.onkeydown = keydown;
	}

	function enable_scroll() {
    	if (window.removeEventListener) {
        	window.removeEventListener('DOMMouseScroll', wheel, false);
	    }
    	window.onmousewheel = document.onmousewheel = document.onkeydown = null;  
	}
	
	$('div.select div.show-button').click(function() {
		
		var select = $(this).parent().attr("id")		
		$('ul.visible-list').animate({opacity: 'hide'},500, function(){});
		$('ul.visible-list').removeClass('visible-list');

		var checkState = $('#'+select+' ul.select-list').css('display');
		if (checkState == 'none'){
			$('#'+select+' ul').addClass('visible-list');
			$('#'+select+' ul.select-list').animate({opacity: 'show'},500, function(){});
		}
		else {
			$('#'+select+' ul.select-list').animate({opacity: 'hide'},500, function(){});		
		}	
	});
		
	$('div.select ul.select-list li').click(function() {
		var item = $(this).parent().attr("id");
		var value = $(this).html();
		item = item.replace('-list','');
		$('#'+item+' li.sel').removeClass('sel');
		$(this).addClass('sel');
		$('#'+item+' input').attr("value", value);
		$('#'+item+' div.select-input').html(value);
		$('#'+item+' ul.visible-list').removeClass('visible-list');		
		$('#'+item+' ul.select-list').animate({opacity: 'hide'},500, function(){});
	});

   	$('div.menu-top').localScroll({
	   	'stop': true,
   		'hash': true,
	   	'duration': 1500,
	   	'onBefore':function(){disable_scroll()},
	   	'onAfter':function(){enable_scroll()}
   	});
   	
   	
	$('div.logo').localScroll({
	   	'stop': true,
   		'hash': true,
	   	'duration' : 3000,
	   	'onBefore':function(){disable_scroll()},
	   	'onAfter':function(){enable_scroll()}	   	
	});	
	$("a.fancybox").fancybox({
		'titleShow': false,
		'padding': 0
		}
	);
	
	$("a.portfolio-hover").hover(
		function(){
			$(this).children(".portfolio-opis").stop(true,false).animate({color: "#00aeef"},'fast', function(){});
			$(this).children(".portfolio-image").stop(true,false).animate({backgroundColor: "#00aeef"},'fast', function(){});
		},
		function(){
			$(this).children(".portfolio-opis").stop(true,false).animate({color: "#bbbbbb"},'fast', function(){});
			$(this).children(".portfolio-image").stop(true,false).animate({backgroundColor: "#cccccc"},'fast', function(){});
		}
	);

	$("a.opacity-hover").hover(
		function(){
			$(this).find('img').stop(true,false).animate({opacity: 1},'fast', function(){});
		},
		function(){
			$(this).find('img').stop(true,false).animate({opacity: 0},'fast', function(){});
		}
	);

	$("a.button").hover(
		function(){
			$(this).stop(true,false).animate({opacity: 0.75},350, function(){});
		},
		function(){
			$(this).stop(true,false).animate({opacity: 1},350, function(){});
		}
	);
	$("a.go").hover(
		function(){
			$(this).stop(true,false).animate({opacity: 0.65},350, function(){});
		},
		function(){
			$(this).stop(true,false).animate({opacity: 1},350, function(){});
		}
	);
	$("a.tag").hover(
		function(){
			$(this).stop(true,false).animate({backgroundColor: '#00aeef'},300, function(){});
		},
		function(){
			$(this).stop(true,false).animate({backgroundColor: '#999999'},300, function(){});
		}
	);
	$("a.menu-button").hover(
		function(){
			$(this).stop(true,false).animate({opacity: 0.70},350, function(){});
		},
		function(){
			$(this).stop(true,false).animate({opacity: 1},350, function(){});
		}
	);
	$("div.lang a").hover(
		function(){
			$(this).stop(true,false).animate({opacity: 1},350, function(){});
		},
		function(){
			$(this).stop(true,false).animate({opacity: 0.30},350, function(){});
		}
	);
	
	$("div.menu a.not-sel").hover(
		function(){
			$(this).stop(true,false).animate({color: '#ffffff', backgroundColor: '#00aeef', borderTopColor: '#0091c7',borderLeftColor: '#0091c7',borderBottomColor: '#0091c7',borderRightColor: '#0091c7'},'fast', function(){});			
		},
		function(){
			$(this).stop(true,false).animate({color: '#444444', backgroundColor: '#eeeeee', borderTopColor: '#bbbbbb',borderLeftColor: '#bbbbbb',borderBottomColor: '#bbbbbb',borderRightColor: '#bbbbbb'},'fast', function(){});
		}
	);	
	
	
});

/*---

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-26285001-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

---*/
