
$(document).ready( function () {
	$('.outside_container h3').html('&nbsp;');
	$('#buttons-for-materials li').html('&nbsp;');
	$('#window-for-materials:not([style])').css('background-image', 'url('+$('.material_mini:first').children('a').attr('href')+')');
	
	
	$('#papke_box img').css({opacity: .7});
	$('.outside_container img').css({opacity: .7});
	
	$('#papke_box img').hover(function () {
		$(this).animate({opacity: 1},400);
	},
	function () {
		$(this).animate({opacity: .7},400);
	});
	$('.images_box img').css({opacity: .7});
	$('.images_box img').hover(function () {
		$(this).animate({opacity: 1});
		},function () {
		$(this).animate({opacity: .7});
		});
	
	$('.outside_container').hover(function () {
		$(this).children('img').animate({opacity: 1});
		},function () {
		$(this).children('img').animate({opacity: .7});
		});
	$('.okna_bcg').hover(function () {
		$(this).children('p').animate({opacity: 1});
		},function () {
		$(this).children('p').animate({opacity: .5});
		});
	
	
	initLogoChanger();
	//Shadowbox.init({ overlayOpacity: '.85', counterType: 'skip', slideshowDelay: 3.5, resizeDuration: .7, continuous: true, paused:true});
	$('#email-cloaking').attr("href", "mailto:papke@papke.pl");
	$('#email-cloaking').html("papke@papke.pl");
	//google maps
  if(typeof pointPlaceInGoogleMap == 'function') {
	  pointPlaceInGoogleMap();
  }
  //materials changer
  $('.material_mini a').click(function () {
		$('#window-for-materials').css('background-image', 'url('+this.href+')');
		$('input[name=material_kolor]').attr('value', $(this).attr('id'));
		return false;
	});
	$('.material_mini a').hover(function () {
		$(this).children('.opis').animate({opacity: .8});
		},function () {
		$(this).children('.opis').animate({opacity: .6});
	});
	$('#choice_window img').click(function () {
		$('#choice_window img').removeClass('active');
		$(this).addClass('active');
		$('#window-for-materials').attr('src', '/images/'+$(this).attr('id')+'.png');
		$('input[name=border_kolor]').attr('value', $(this).attr('id'));
	});
	
	$('#buttons-for-materials li').click(function () {
		$('#buttons-for-materials li').removeClass('active');
		$(this).addClass('active');
		$('.materials').hide();
		$('.'+$(this).attr('id')).show();
	});
	$('a').each(function() {
	if($(this).attr('title') == '')
		$(this).attr('title', $(this).text());
	});
	
	
	// SLIDE MAIN MENU
		$(".main_menu_item").hover(function() {
		$(this).children(".submenu").show();
		$(this).children(".submenu").css('z-index', '500');
	});
	
	
	$('.main_menu_item').mouseleave(function () {
		if($(this).prev().hover() || $(this).next().hover()) {
			$(this).children('.submenu').hide();
			return ;
		}
		else {
			$(this).children('.submenu').hide();
		}
	});
	$('.submenu').hover(function(){
		$(this).parent().css('background-color', '#e9e9e9');
		},function(){
		$(this).parent().css('background-color', '#ffffff');
	});
	// END SLIDE MENU
});

function initLogoChanger() {
	$('#logo').innerfade({ animationtype: 'fade', speed: 1000, timeout: 9000, type: 'sequence', containerheight: '240px' });
}

function materialChanger() {
	
}
  
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-15434577-4']);
  _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);
  })();


