/**
 * jQuery Customs Adjustments for Effects and Plugins
 *
 * Date: 09/09/2009
 * @author Rene Berger
 * @version 0.3.0 Beta
 **/

$(document).ready(function(){

  // Add Bookmark

	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.toolBarBookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.toolBarBookmark").attr("rel","sidebar");
		}
	}

	$("a.toolBarBookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		//  var url = this.href;
		  var url = self.location.href;
		//  var title = this.title;
		//  var title = document.getElementsByTagName("title")[0].innerHTML;
		  var title = document.title; 

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Chrome etc - browsers who do not support bookmarking scripts
			 alert('Ihr Browser unterstützt diese Funktion nicht.'
			 + ' Bitte Legen Sie das Lesezeichen manuell an.');
		}

	});

  // jQuery UI Accordion Extended 
  // An accordion doesn't allow more than one content panel to be open at the same time
	$("#accordion-extended").addClass("ui-accordion ui-widget ui-helper-reset ui-accordion-icons")
	.find("h3")
		.addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
		.prepend('<span class="ui-icon ui-icon-triangle-1-e"/>')
		.click(function() {
			$(this).toggleClass("ui-accordion-header-active").toggleClass("ui-state-active")
				.toggleClass("ui-state-default").toggleClass("ui-corner-bottom")
			.find("> .ui-icon").toggleClass("ui-icon-triangle-1-e").toggleClass("ui-icon-triangle-1-s")
			.end().next().toggleClass("ui-accordion-content-active").toggle('fast');
			return false;
		})
		.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide();

  $(function(){

    // jQuery UI Accordion
    $("#accordion").accordion({
      active: false,
      autoHeight: false,
      collapsible: true
		});

    // jQuery UI Tabs
    $('#tabs').tabs({
//      fx:{opacity: 'toggle'}, collapsible:true, selected:0
    }); 

    // jQuery scroll Follow
    if ( $("#teaserForm").length > 0 ) {
      $( '#teaserForm' ).scrollFollow( {
        container: 'main',
        speed: 1000,
        offset: 20
      } );
    }

    // jQuery scroll Follow
//    $( '#teaserForm' ).scrollFollow( {
//      container: 'main',
//      speed: 1000,
//      offset: 20
//    } );

    // Featured Slider (s3Slider)
//    if ( $("#featuredSlider").length > 0 ) {
//      $('#featuredSlider').s3Slider({
//        timeOut: 8000
//      });
//    }

  });

});
