$(function(){
	
	if($('html').hasClass('ie7')){
sound="";
}
	
	
	
	if($('html').hasClass('ie8')){
		sound=false;
	}
	runslideshow="";
	
	//atmosound="undefined";
	
	news = function(){};
		
	
		
	work = function(){
		};
		
				
	contact = function(){};
	
	



if($('#main').hasClass('home')){
	$('.bottom .skip').fadeIn(10);
} else{
	$('.bottom .skip').css({'display':'none'});
}




//SPRITES NAVI
anim_news = function(){
$('#navanim_news')
	.sprite({fps: 13, no_of_frames: 10, play_frames: 10})
}	
anim_agentur = function(){
$('#navanim_agentur')
	.sprite({fps: 13, no_of_frames: 12, play_frames: 12});
}
anim_bauchschlaegtkopf = function(){
$('#navanim_bauchschlaegtkopf')
	.sprite({fps: 13, no_of_frames: 10, play_frames: 10});
}
anim_markenwelten = function(){
$('#navanim_markenwelten')
	.sprite({fps: 13, no_of_frames: 10, play_frames: 10});
}
anim_work = function(){
$('#navanim_work')
	.sprite({fps: 13, no_of_frames: 10, play_frames: 10});
}
anim_contact = function(){
$('#navanim_kontakt')
	.sprite({fps: 13, no_of_frames: 10, play_frames: 10});
}

anim_callout = function(){
$('.callout_dev').fadeIn(10);
$('.callout_sg').delay(500).css({'display':'block'})
}


$('#callout a').live('hover',function(){
	$('.callout_hover').fadeIn(10);
	
	});


$('#callout a').live('mouseleave',function(){
	$('.callout_hover').fadeOut(10);
	
	});


/*$('#callout a').live('click',function(){
	$('.callout_hover').fadeOut(10);
	
	
	url = $(this).attr('href');
	title = $(this).attr('title');
	cbfunction = $(this).attr('title').toLowerCase();
	
	
	$.ajax({
 		  url: url,
		  success: function(data) {
			  data = $(data).find('#load').html();
			  
			   $('#ajax').html(data);
			   QueryLoader.selectorPreload = "#loadcon";
			   QueryLoader.init();
			
			   eval(cbfunction+'()');
		
		}
		});		
	
	return false;
	});*/
	
	
	
	
	
	
	
	
	
	
	
	/*$('#logo').live('click',function(){
		
	
	url = $(this).attr('href');
	title = $(this).attr('title');
	cbfunction = $(this).attr('title').toLowerCase();
	
	
	$.ajax({
 		  url: url,
		  success: function(data) {
			  data = $(data).find('#load').html();
			  
			   $('#ajax').html(data);
			   QueryLoader.selectorPreload = "#loadcon";
			   QueryLoader.init();
			
			   eval(cbfunction+'()');
		
		}
		});		
	
	return false;
	});*/
	
	
	
	
	
	
	
	
	
	
		focuslost=false;
	
	///NAVI///	
	checkfocus=function(){
		focuslost=false;	
	}	
	
	
	hidenav=function(){
	if(focuslost==false){
		$('#navi').animate({
   			height: 25
  			}, 300);
		$('#navi li').animate({
   			paddingTop: 0
  			}, 300);
		/*$('#logo').animate({
   			height: 11,
			width:154
  			}, 300);*/
		};
	}	
	var check;
	var hide;
	
	$('#navi').live('mouseleave',function(){
		 check = setTimeout(checkfocus,500);
		 hide = setTimeout(hidenav,501);
		 });
	
	$('#navi').live('mouseenter',function(){
		clearTimeout(check);
		clearTimeout(hide);
		focuslost=true;
		
		$(this).animate({
   			height: 70
  			}, 300);
		$('#navi li').animate({
   			paddingTop: 45
  			}, 300);
		/*$('#logo').animate({
   			height: 17,
			width:240
  			}, 300);*/
		});
		
		
		
$('#navi ul li a').live('click',function(){
		
	
	/*if ($(this).hasClass('active')){
		return false;
	}*/
	
	
	
	
	if (!$(this).attr('title')=='Work'){		
	
	$('#navi ul li').removeClass('active');
	$(this).parent('li').addClass('active');
	
	url = $(this).attr('href');
	//alert(anim);
	title = $(this).attr('title');
	
	cbfunction = $(this).attr('title').toLowerCase();
	
	
	$.ajax({
 		  url: url,
		  success: function(data) {
			  data = $(data).find('#load').html();
			  
			  
			  //alert(data);
			   $('#ajax').html(data);
			   QueryLoader.selectorPreload = "#loadcon";
			   QueryLoader.init();
			   //$('#ajax').css('opacity',100);
			   
			   
			  //$('#loader').delay(500).fadeOut(300, function(){
				//  $('#loader').remove();
				  //});
			   
			   //eval(cbfunction+'()');
			   
					
				//newtitle = pagetitle + newtitle;
				//document.title = newtitle;
				
				
				//$('#left').delay(300).fadeIn('slow');
				//$('#right').delay(300).fadeIn('slow');
				//$('#loading_ajax').fadeOut('slow');
		}
		});	
	return false;

}


});
		
		

		
function callskip() {
	
	
$('.video-js-box').html('<img src="img/intro_skip.jpg" />');
	
};
		
		

introfinished = function(){
	$('#navi').animate({
   			height: 70,
			marginTop: 0
  			}, 500);
		$('#navi li').animate({
   			paddingTop: 45
  			}, 500);
		$('#logo').animate({
   			top: 0
	}, 500);
			
	
	setTimeout(anim_news,300);
	setTimeout(anim_agentur,800);
	setTimeout(anim_bauchschlaegtkopf,900);
	setTimeout(anim_markenwelten,1200);
	setTimeout(anim_work,1500);
	setTimeout(anim_contact,1800);
	$('.skip').fadeOut('slow');
	
	
	$('#follow_click').fadeIn(10);
	$('#callout').delay(2000).fadeIn('fast');
	setTimeout(anim_callout,2000);
	
	
	
	setTimeout(hidenav,5000);
	

}






$("video").bind("ended", function() {
		if($('html').hasClass('ipad')){
			callskip();
			}
		introfinished();                
	});




if($('html').hasClass('iphone') && $('body').hasClass('home_b')){
	introfinished();
}





$('.skip').live('click',function(){
	
	callskip();
	introfinished();
	//alert('skip');
	var video = document.getElementsByTagName("video")[0];
	video.currentTime = 14;
	$('a.skip').fadeOut(100);
	
	
	
	
	
	
	
		
});








//introfinished();	



if(!$('#main').hasClass('home')){

$('#navi .anim').css({
   			backgroundPosition: 550
});


$('#navi #navanim_agentur').css({
   			backgroundPosition: 650
});
}


/*
loadbreath = function() {
			$('.loader_animation span').animate({'opacity':'0'},1000,function(){
			$('.loader_animation span').animate({'opacity':'100'},500)
			});
		
		};
		
		
		loadbreath_int = function() {
			setInterval(loadbreath,1500);
		
		};


loadbreath_int();
*/











/*play_sound = function(){
 soundHandle = document.getElementById('soundHandle');
 soundHandle.src = 'audio/wen_audio.mp3';
 soundHandle.play();
}*/

played=false;

play_sound = function(){
	
	if(played){
	 $("#soundHandle").jPlayer("play");
 	}
	else{
 $("#soundHandle").jPlayer({
  ready: function () {
   $(this).jPlayer("setMedia", {
    mp3: "audio/wen_audio.mp3",
    oga: "audio/wen_audio.oga"
   }).jPlayer("play");
 // }, ended: function() { // The $.jPlayer.event.ended event
 // $(this).jPlayer("play"); // Repeat the media
  },
  swfPath: " js",
  supplied: "mp3,oga"
 });
	}
 
 
 
}




$('.subnav, .pfeil, .sized, .work_sample_navi, #navi ul li a').live('mouseenter',function(){
	if(sound){
		play_sound();		
		played=true;
	}
	});
	
	
	
	
///SOUND ON OFF

$('.sound_off').live('click',function(){
	
	$('.sound_on').removeClass('active');
	$(this).addClass('active');
	
	$.get('php/soundcheck.php?sound=off', function(data) {
		sound=false;
 		//atmosound.pause();
		
	});
	});

	
$('.sound_on').live('click',function(){
	
	$('.sound_off').removeClass('active');
	$(this).addClass('active');
			
	$.get('php/soundcheck.php?sound=on', function(data) {
		
 		
		sound=true;
	});
	});

	
	
});




   

