// JavaScript Document
jQuery(function( $ ){
	/**
	 * Demo binding and preparation, no need to read this part
	 */
	//borrowed from jQuery easing plugin
	//http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};


	// back links
	$('a.back').click(function(){
		$(this).parents('div.pane').scrollTo( 0, 800, { queue:true } );
		$(this).parents('div.section').find('span.message').text( this.title );
		return false;
	});
	//just for the example, to stop the click on the links.
	$('ul.links').click(function(e){
		e.preventDefault();
		var link = e.target;
		link.blur();
		if( link.title )
			$(this).parent().find('span.message').text(link.title);
	});
	
	// This one is important, many browsers don't reset scroll on refreshes
	// Reset all scrollable panes to (0,0)
	$('div.pane').scrollTo( 0 );
	// Reset the screen to (0,0)
	$.scrollTo( 0 );
	
	// TOC, shows how to scroll the whole window
	$('.aboutus_js').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( '#aboutus', 1000/*, { axis:'x' }*/);
		return false;
	});
	$('.contactus_js').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( '#contactus', 1000/*, { axis:'x' }*/);
		return false;
	});
	$('.hireus_js').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( '#hireus', 1000/*, { axis:'x' }*/);
		return false;
	});
	$('.start_js').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( '#start', 1000/*, { axis:'x' }*/);
		return false;
	});
	
	// Target examples bindings
	// THIS DEMO IS NOT INTENDED TO SHOW HOW TO CODE IT
	// JUST THE MULTIPLE OPTIONS. THIS CODE IS UGLY.
	var $paneTarget = $('#pane-target');
	

	$('#dom-element').click(function(){
		var target = $paneTarget.find('#aboutus').get(0).childNodes[20];
		$paneTarget.stop().scrollTo( target, 800 );
	});
	$('#relative-position').click(function(){
		$paneTarget.stop().scrollTo( '+=100', 500 );
	});

	$('#absolute-position').click(function(){
		$paneTarget.stop().scrollTo( '520px', 800 );
	});
	
	$('#options-axis').click(function(){// only scroll horizontally
		$paneTarget.scrollTo( '100%', 1000, { axis:'x' } );
	});

});


$(function() {
	//Collapser für menue
	$("#example1").jcollapser({
		target: '#jcollapse1', 
		state: 'collapsed'
	});



	//dialog1
	$( ".dialogs" ).dialog({
		autoOpen: false,
		resizable: false,
		closeText: '(x)',
	});
	$('.opener1').click(function() {
		$( "#dialog1" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog2
	$('.opener2').click(function() {
		$( "#dialog2" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog3
	$('.opener3').click(function() {
		$( "#dialog3" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog4
	$('.opener4').click(function() {
		$( "#dialog4" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog5
	$('.opener5').click(function() {
		$( "#dialog5" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog6
	$('.opener6').click(function() {
		$( "#dialog6" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});
	
	//Dialog7
	$('.opener7').click(function() {
		$( "#dialog7" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});

	//Dialog8
	$('.opener8').click(function() {
		$( "#dialog8" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});

	//Dialog9
	$('.opener9').click(function() {
		$( "#dialog9" ).dialog('open');
		// prevent the default action, e.g., following a link
		return false;
	});


	$( "#accordion" ).accordion({
			autoHeight: false,
			navigation: true
		});



//	$( "#tabs" ).tabs({ ajaxOptions: { async: false } });
	
	
	


        var $tabs = $('#tabs').tabs({ ajaxOptions: { async: false } });

//$tabs.data('selected.tabs'); 	



        $("ul.ui-tabs-nav li").each(function(i){

          var totalSize = $(".ui-tabs-panel").size() - 1;

          if (i != 0) {
              prev = i -1;
                  $(this).append("<a href='#ui-tabs-" + prev + "' class='prev-tab mover' rel='" + prev + "'>&#171; Zur&uuml;ck</a>");
          }

          if (i != totalSize) {
              next = i + 1;
                  $(this).append("<a href='#ui-tabs-" + next + "' class='next-tab mover' rel='" + next + "'>Weiter &#187;</a>");
          }

        });

        $('.next-tab, .prev-tab').click(function() {
           $tabs.tabs('select', $(this).attr("rel"));
           return false;
       });


		
});
