// JavaScript Document
// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
function resetBut(){
	$('#nav li a').removeClass('mnselected');
	$('#nav li a').addClass('mnunselected');
}

function getTT(){
	//TOOLTIP REFERENZEN
	$("#referenzen li").easyTooltip({
		tooltipId: "tooly",
		clickRemove: true,
		useElement: "reftip"
	});
}



function refLoad(page){
	if(! page >= 0) page = 0;
	$('#refmain').remove();
		
		$('#sections003').fadeOut('slow', function(){
			
			$('#navigation003').fadeOut('slow');
			$('#sections003').load('fileadmin/templates/loading.html', function(){$('#sections003').trigger('goto',[page]);}).fadeIn('fast', function(){
				
				$('#sections003').fadeOut('fast', function(){
					
					$('#sections003').load('index.php?id=24', function(){
						
						$.getScript("fileadmin/templates/js/pagina.js", function(){
							$('#sections003').trigger('goto',[page]);
							$('#paginator003 li').removeClass('selected');
							$('#paginator003 li').addClass('unselected');
							$('#paginator003 li').eq(page).addClass('selected');
						});
						getTT();
						
					});
					
					$('#sections003').fadeIn('slow');
					$('#navigation003').fadeIn('slow');
					
				});
				
			});
			
		});
}

jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){

$('#homesec').load('index.php?id=26');
$('#sections001').load('index.php?id=34');
$('#sections002').load('index.php?id=25');
$('#sections003').load('index.php?id=24');
$('#sections004').load('index.php?id=23');
$('#sections005').load('index.php?id=32');
$('#sections007 #partnerdiv').load('index.php?id=36');

});


//HOME
jQuery(function( $ ){
	
	 
	$('#home').serialScroll({
		target:'#homesec',
		items:'#schome', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		//stop:true,// Each click will stop any previous animations of the target. (false by default)
		//lock:true, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:true, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		lazy:true,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		interval:8000, // It's the number of milliseconds to automatically go to the next
		constant:true, // constant speed
		easing:'easeOutQuart',
		
		onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			 $('#homepag li').removeClass('selected'),
			 $('#homepag li').addClass('unselected'),
			 $('#homepag li').eq(pos).addClass('selected');
			 
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
		}
	});
	$.getScript("fileadmin/templates/js/pagina_home.js");
});


//IDEALISMUS
jQuery(function( $ ){
		 
	
		
	$('#screen001').serialScroll({
		target:'#sections001',
		items:'#abli', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		stop:true,// Each click will stop any previous animations of the target. (false by default)
		lock:false, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		lazy:true,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		//interval:5000, // It's the number of milliseconds to automatically go to the next
		constant:true, // constant speed
		easing:'easeOutQuart',
		
		onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			 $('#paginator001 li').removeClass('selected'),
			 $('#paginator001 li').addClass('unselected'),
			 $('#paginator001 li').eq(pos).removeClass('unselected'),
			 $('#paginator001 li').eq(pos).addClass('selected');
			 
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
			
		}
	});
	$.getScript("fileadmin/templates/js/pagina_ideal.js");
});


//ÜBER UNS
jQuery(function( $ ){
		 
	
		
	$('#screen002').serialScroll({
		target:'#sections002',
		items:'.abli', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		stop:true,// Each click will stop any previous animations of the target. (false by default)
		lock:false, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		lazy:true,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		//interval:5000, // It's the number of milliseconds to automatically go to the next
		constant:true, // constant speed
		easing:'easeOutQuart',
		
		onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			 $('#paginator002 li').removeClass('selected'),
			 $('#paginator002 li').addClass('unselected'),
			 $('#paginator002 li').eq(pos).removeClass('unselected'),
			 $('#paginator002 li').eq(pos).addClass('selected');
			 
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
			
		}
	});
	$.getScript("fileadmin/templates/js/pagina_about.js");
});





//LEISTUNGEN
jQuery(function( $ ){
				
	$('#screen005').serialScroll({
		target:'#sections005',
		items:'#abli', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		stop:true,// Each click will stop any previous animations of the target. (false by default)
		lock:false, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		lazy:true,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		//interval:5000, // It's the number of milliseconds to automatically go to the next
		constant:true, // constant speed
		easing:'easeOutQuart',
		
		onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			 $('#paginator005 li').removeClass('selected'),
			 $('#paginator005 li').addClass('unselected'),
			 $('#paginator005 li').eq(pos).removeClass('unselected'),
			 $('#paginator005 li').eq(pos).addClass('selected');
			 
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
			
		}
	});
	$.getScript("fileadmin/templates/js/pagina_about.js");
});




//REFERENZEN
jQuery(function( $ ){
				
	 var $nav = $('#paginator003 li');		
		
	$('#screen003').serialScroll({
		target:'#sections003',
		items:'.scrolly', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:100,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		cycle:true,	
		lazy:true,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		constant:true, // constant speed
		//easing:'easeOutQuart',
		navigation:$nav,
		lock:false,
		jump:true,
		start:0,
		
		onBefore:function( e, elem, $pane, $items, pos ){
			 
			 $('#paginator003 li').removeClass('selected');
			 $('#paginator003 li').addClass('unselected');
			 $('#paginator003 li').eq(pos).addClass('selected');
			 $('#paginator003 li').eq(pos).removeClass('unselected');

			 
			 e.preventDefault();
			 if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			
		}
	});
	
	
	$.getScript("fileadmin/templates/js/pagina.js", function(){
		$('#sections003').trigger('goto',[0]);
		$('#paginator003 li').removeClass('selected');
		$('#paginator003 li').addClass('unselected');
		$('#paginator003 li').eq(0).addClass('selected');
	});
	
	
//LOADING CLIENT PAGE			
	$("#referenzen a").live('click', function(){
		var tag = $(this).attr("tag");
		
		$('#sections003').fadeOut('slow', function(){
				
				$('#navigation003').fadeOut('slow');
				
				$('#sections003').load('fileadmin/templates/loading.html', function(){}).fadeIn('fast', function(){
					
					$('#sections003').fadeOut('fast', function(){
						
						$('#sections003').load('index.php?id=28', function(){
						
						var item = $('#refid'+tag);
						var index = $('#sections003 li').index(item);
							
						$.getScript("fileadmin/templates/js/pagina.js", function(){
							//$('#sections003').trigger('goto',[index], {duration:3000});
							//Fast Jump
							$('#sections003').scrollTo( 'li:eq('+[index]+')', {duration:0} );
							$('#paginator003 li').removeClass('selected');
			 				$('#paginator003 li').addClass('unselected');
			 				$('#paginator003 li').eq(index).addClass('selected');
						});
						
						//Make Links clickable
						
						$('#sections003 #txt a').click(function(){
					
							window.open($(this).attr('href'), 'Neues Fenster');
				 
						});
						
						
					});
					
					$('#sections003').fadeIn('slow');
					$('#navigation003').fadeIn('slow');
						
					});
					
				});
				
			});
	});
});


jQuery(function($){
//GOING BACK TO REFERENZEN
	$('#refmain').live('click', function(){
		refLoad();
		
	});

});



//TOOLTIPS

jQuery(function( $ ){
            $("img.next").easyTooltip({
				tooltipId: "tt",
				clickRemove: true,
				xOffset:-85,
				yOffset:-15
			});
			
			$("img.prev").easyTooltip({
				tooltipId: "tt",
				clickRemove: true,
				xOffset:10,
				yOffset:-15
			});
});



//HAUPTNAVIGATION

jQuery(function( $ ){
			//INITAL ON BODY LOAD
			$('div#centercourt').scrollTo( '#home', 1500, {axis:'y'} );
			$.getScript("fileadmin/templates/js/pagina_home.js");
			//$('#nav li a').removeClass('mnselected');
			$('#nav li a').addClass('mnunselected');
			$('#homebut').addClass('mnselected');
			
			
			//HOME
			$('#homebut').click(function(){
			 	duration:90;
				$('#homesec').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#home', 1500, {axis:'y'} );
				resetBut();
				$('#homebut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
			 
			$('.wuplogo').click(function(){
			 	duration:90;
				$('#homesec').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#home', 1500, {axis:'y'} );
				resetBut();
				$('#homebut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
			 
			 $('.wup').click(function(){
			 	duration:90;
				$('#homesec').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#home', 1500, {axis:'y'} );
				resetBut();
				$('#homebut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
			 			 
			 //ÜBER UNS
			 $('#idealbut').click(function(){
			 	duration:90;
				$('#sections001').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#screen001', 1500, {axis:'y'} );
				resetBut();
				$('#idealbut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
					 
			 //REFERENZEN
			 $('#referenzenbut').click(function(){
			 	duration:90;
				refLoad();
				getTT();
				$('#sections003').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#screen003', 1500, {axis:'y'} );
				resetBut();
				$('#refmain').remove();
				$('#referenzenbut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
			 
			 //KONTAKT
			 $('#kontaktbut').click(function(){
			 	duration:90;
				$('#sections004').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#screen004', 1500, {axis:'y'} );
				resetBut();
				$('#kontaktbut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
			 Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 
			 //LEISTUNGEN
			 $('#leistungenbut').click(function(){
			 	duration:90;
				$('#sections005').trigger('goto',[0]);
				$('div#centercourt').scrollTo( '#screen005', 1500, {axis:'y'} );
				resetBut();
				$('#leistungenbut').addClass('mnselected');
				Cufon.replace('.mainnavi a', { fontFamily: 'Conduit ITC', hover: true, hoverables: { a: true } });
			 });
});


//KUNDENNAVIGATION
jQuery(function($){

	$('#kunden a').bind('click', function(){
		
		$('#refmain').remove();
		$('#nav li a').removeClass('mnselected').addClass('mnunselected');
		$('#referenzenbut').removeClass('mnunselected').addClass('mnselected');
		Cufon.refresh();
		
		var tag = $(this).attr("tag");
		
		$('div#centercourt').scrollTo( '#screen003', 1500, {axis:'y', onAfter:function(){
			
			$('#navigation003').fadeOut('slow');
				
				$('#sections003').load('fileadmin/templates/loading.html', function(){}).fadeIn('fast', function(){
					
					$('#sections003').fadeOut('fast', function(){
						
						$('#sections003').load('index.php?id=28', function(){
						
						var item = $('#refid'+tag);
						var index = $('#sections003 li').index(item);
							
						$.getScript("fileadmin/templates/js/pagina.js", function(){
							
							//$('#sections003').trigger('goto',[index]);
			
							//Fast Jump
							$('#sections003').scrollTo( 'li:eq('+[index]+')', {duration:0} );
	
							$('#paginator003 li').removeClass('selected');
			 				$('#paginator003 li').addClass('unselected');
			 				$('#paginator003 li').eq(index).addClass('selected');
						});
						
					});
					
					$('#sections003').fadeIn('slow');
					$('#navigation003').fadeIn('slow');
						
					});
					
				});
			
		}});
	});


});


//SCHILD FADEN ENDE
jQuery(function($){

	$("#schildbox").animate({"top": "-=100px"}, "slow"),
	$("#schildbox").animate({"top": "+=20px"}, "slow"),
	$("#schildbox").animate({"top": "-=20px"}, "slow"),
	$("#schildbox").animate({"top": "+=50px"}, "slow");
	
	$('#nav a').live('click', function(){
		$("#schildbox").animate({"top": "-=50px"}, "slow"),
		$("#schildbox").animate({"top": "+=20px"}, "slow"),
		$("#schildbox").animate({"top": "-=30px"}, "slow"),
		$("#schildbox").animate({"top": "+=60px"}, "slow");
	});
	
	$("#schildbox").bind("mouseenter",function(){

		$("#schildbox").animate({"top": "-=210px"});
	});
	$("#schildbox").bind("mouseleave",function(){

		$("#schildbox").animate({"top": "+=210px"});
	});
	
	$("#schildbox").bind("click",function(){

		$('div#centercourt').scrollTo( '#screen006', 1500, {axis:'y'} );
	});


});

//TEAM NAVIGATION
jQuery(function($){
	
	
		$('#team #wagner a:eq(0)').click(function(){
		
			var tag = $(this).attr("tag");	
			
			resetBut();
			//$('#wirbut').addClass('mnselected');
			Cufon.refresh();
			$('div#centercourt').scrollTo( '#screen002', 1500, {axis:'y', onAfter:function(){
				//$('#sections002').trigger('goto',[tag]);
			}} );
			
				 
		});
});


//PARTNER NAVIGATION
jQuery(function($){
	
	
		$('#team #wagner a:eq(1)').click(function(){
		
			var tag = $(this).attr("tag");		
			
			resetBut();
			//$('#wirbut').addClass('mnselected');
			Cufon.refresh();
			$('div#centercourt').scrollTo( '#screen007', 1500, {axis:'y', onAfter:function(){
				//$('#sections007').trigger('goto',[tag]);
			}} );
			
				 
		});
});


//LEISTUNGEN NAVIGATION
jQuery(function($){

	
		$('#leistungen a').click(function(){
					
			var tag = $(this).attr("tag");		
	
			resetBut();
			$('#leistungenbut').addClass('mnselected');
			Cufon.refresh();
			$('div#centercourt').scrollTo( '#screen005', 1500, {axis:'y', onAfter:function(){
				//$('#sections005').trigger('goto',[tag]);
			}} );
			
			$('#sections005').trigger('goto',[tag]);
			
				 
		});

});

// GOOGLE MAPS

// JavaScript Document
function initialize() {
		var latlng = new google.maps.LatLng(48.40828,15.59902);
		var settings = {
			zoom: 16,
			center: latlng,
			mapTypeControl: true,
			mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
			navigationControl: true,
			navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
			mapTypeId: google.maps.MapTypeId.ROADMAP
    };
	var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
	var companyLogo = new google.maps.MarkerImage('fileadmin/templates/img/mapmarker.png',
	new google.maps.Size(100,50),
	new google.maps.Point(0,0),
	new google.maps.Point(45,45)
);
var companyShadow = new google.maps.MarkerImage('fileadmin/templates/img/mapshadow.png',
	new google.maps.Size(130,50),
	new google.maps.Point(0,0),
	new google.maps.Point(45, 45)
);
var companyPos = new google.maps.LatLng(48.40828,15.59902);
var companyMarker = new google.maps.Marker({
	position: companyPos,
	map: map,
	icon: companyLogo,
	shadow: companyShadow,
	title:"Wagner und Partner"
});
	}


