$(document).ready(function() {
	var config = {
		over: showMenu,
		timeout: 100,
		out: hideMenu
	};
  $('#sub-menu li').hoverIntent( showMenu, hideMenu );
  $('#morevideos li').hoverIntent( showMenu, hideMenu );

  $('.projects .more a').click(function (){
  	var id = $(this).attr('rel');
		if(id) {
			id= '#'+id;
			$(id).slideToggle(100);
			if($(this).hasClass('active')) {
				$(this).removeClass('active');
				$('span', this).html('mehr');
			}
			else {
				$(this).addClass('active');
				$('span', this).html('weniger');
			}
		}
	})

	$("#footer .menu .menu-item:last").html($("#footer .menu .menu-item:last").html().replace("</a> |","</a>"));
  $('a[rel=external]').attr('target', '_blank');

  $("#video .swf").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		  : 853,
			'height'		: 505,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'		: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});
		return false;
	});

	$("#interface .face").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: true,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'href'			: this.href
		});
		return false;
	});

	$("#interface .info").animate({'opacity':0},0);
	$("#interface .info").hover(function(){
		$(this).stop().animate({'opacity':1},300, 'swing');
	}, function() {
		$(this).stop().animate({'opacity':0},300, 'swing');
	});

	$('#interface .info strong').wraplines();

});
function showMenu(ev) {
	li = ev.currentTarget;
	if(li.childNodes.length > 1) {
  	$(li.childNodes[0]).addClass('hover');
  	$(li.childNodes[2]).fadeIn(150);
  }
}
function hideMenu(ev) {
	li = ev.currentTarget;
	if(li.childNodes.length > 1) {
  	$(li.childNodes[0]).removeClass('hover');
  	$(li.childNodes[2]).fadeOut(150);
  }
}
/*
Cufon.replace('#nav h3', { fontFamily: 'MyFont' });
Cufon.replace('#nav li a', { fontFamily: 'MyFont', hover: true });
*/
Cufon.replace('#page h2', { fontFamily: 'MyFont' });
//Cufon.replace('h1.references', { fontFamily: 'MyFont' });
//Cufon.replace('.player-info h1', { fontFamily: 'MyFont' });
Cufon.replace('h2.references', { fontFamily: 'MyFont' });
Cufon.replace('.breadcrumb', { fontFamily: 'MyFont' });
Cufon.replace('.refBack', { fontFamily: 'MyFont' });


function loadVideo (url){
  $('#videoPlayer').css('display','block');
  $('#videoFrane').attr('src','http://www.youtube.com/embed/'+url+'?autoplay=1');
}

$(window).load(function() {

    $('#slider').nivoSlider({
      effect: 'fade',
      pauseTime: 6000,
      directionNav: false
    });

    //sidebar - kontakt
    $(".dkmain .box").click(function(){
      var $boxtxt = $(".dkmain .ktextmain");

      if (!$boxtxt.is(":visible") && $boxtxt.hasClass("khidden")) {
        $boxtxt.css('opacity', 0);
        $boxtxt.css('marginLeft', $boxtxt.outerWidth());
        $boxtxt.removeClass("khidden");
      }

      $boxtxt.animate({
        opacity: parseInt($boxtxt.css('opacity'),10) == 1 ? 0 : 1,
        marginLeft: parseInt($boxtxt.css('marginLeft'),10) == 0 ? $boxtxt.outerWidth() : 0
      });

      $(this).toggleClass("boxopen");
      /*
      $(this).animate({
        //opacity: parseInt($(this).css('opacity'),10) == 1 ? 0 : 1,
      }).toggleClass("boxopen").animate({
        //opacity: parseInt($(this).css('opacity'),10) == 1 ? 1 : 0,
        //marginLeft: parseInt($boxtxt.css('marginLeft'),10) == 0 ? $boxtxt.outerWidth() : 0
      });*/

    });

    $('area').each(function(){
      var href=$(this).attr('href');
      if(href=='info[a]sologics.de'){
        $(this).attr('href','mailto:info@sologics.de')
      }
    });
    $('a.email').each(function(){
      var href=$(this).attr('href');
      if(href=='info[a]sologics.de'){
        $(this).attr('href','mailto:info@sologics.de')
        $(this).html('info@sologics.de')
      }
    });

});



$(function() {

  $(".menuTip").tipTip({maxWidth: "auto", edgeOffset: 10});
  $('.portfolio li').mouseenter(function() {
    $(this).find('a.popup').fadeTo('slow', 0.7);
    $(this).find('p.spantitle').fadeTo('slow', 1);
  });
  $('.portfolio li').mouseleave(function() {
    $(this).find('a.popup').fadeTo('slow', 0.0);
    $(this).find('p.spantitle').fadeTo('slow', 0.0);
  });

});






