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

// Audio Player
	$("#jquery_jplayer_1").jPlayer({
		ready: function () {
			$(this).jPlayer("setMedia", {
				m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
				oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
			}).jPlayer("play");
		},
		ended: function (event) {
			$(this).jPlayer("play");
		},
		swfPath: "../js",
		supplied: "m4a, oga"
	});
	
		
// Main Content Toggle
			$('#scrollable').fadeOut();
			var flag=false;
			
			
			$('.openContent img').click(function() {
			if(flag==false){
  				$('#scrollable').slideDown(2400);
				$('.openContent img').attr("src","img/closeContent.png");
				flag=true;
			}
			else {$('#scrollable').slideUp(2400);
				$('.openContent img').attr("src","img/openContent.png");
				flag=false;
				}
});		 
			
			
			
// Portfolio item animation
var lis = $("#latestWork li");
	$("#latestWork li").hover(
	  function () {
		$(this).find('.description-overlay').animate({top:'20px'}, 600, 'easeOutExpo');
	  },
	  function () {
		$(this).find('.description-overlay').animate({top:'160px'}, 500, 'easeOutExpo');
	  }
	);


// Scroll to top
$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});



// Infield Text (Input)
	$('.text').click(

	function () {
		if (this.value == this.defaultValue) {
			this.value = '';
		}
	});
	$('.text').blur(

	function () {
		if (this.value == '') {
			this.value = this.defaultValue;
		}
	});
	


// Contact Button
var toggler = false;

$("#menu .toggle").click(function () {
	
		if(toggler==false){
				$('#content').animate({
   			    top: '-1500px',
    			height: 'toggle'
  				}, 500, function() {
    			// Animation complete.
  				});
				
				$('#contactWrapper').animate({
   			    top: '140px',
    			height: 'toggle'
  				}, 500, function() {
    			// Animation complete.
  				});
				
				$("#menu .toggle").html("Powrót");
				
				toggler=true;
				
			} else {
				
				$('#contactWrapper').animate({
   			    top: '7000px',
    			height: 'toggle'
  				}, 500, function() {
    			// Animation complete.
				});
				
				
				$('#content').animate({
   			    top: '140px',
    			height: 'toggle'
  				}, 500, function() {
    			// Animation complete.
  				});
				
				$("#menu .toggle").html("Kontakt");
				
				toggler=false;
				}	
	});
	
	
});
