
// --------- start jQuery document.ready() ---------- //

//Lore
  
$(document).ready(function() {

//adding ID menu for compatibility
$("menu").attr({id: "menu"});

//removing titles from menu
$("menu a").attr({title: ""});

// handle nav selection
function selectNav() {
  $('menu a').removeClass('selected')
  $(this).addClass('selected');
}

$('menu').find('a').click(selectNav);

// go find the navigation link that has this target and select the nav
function trigger(data) {
  var el = $('menu').find('a[href$="' + data.id + '"]').get(0);
  selectNav.call(el);
}

if (window.location.hash) {
  trigger({ id : window.location.hash.substr(1) });
} else {
  $('menu a:first').click();
}

// adding hover effect to menu li
//$('menu li').append('<em></em>');
/*
$('menu a').hover(
    function () {
      $(this).parent().css({"backgroundPosition" : "100% 0"});
    },
    function (){
      $(this).parent().css({"backgroundPosition" : "100% -600px"});
});

$('menu li.m3 a').hover(
    function () {
      $(this).parent().css({"backgroundPosition" : "75% 0"});
    },
    function (){
      $(this).parent().css({"backgroundPosition" : "75% -600px"});
});
*/
//width of window
var larghezza = $(window).width();

//var larghezzaMenu = larghezza-765;
//var menuPosizione = (larghezzaMenu/2)+30;

var larghezzaContent = 1950-larghezza;
var contentPosizione = larghezzaContent/2;

// position menu and content
//$('menu').css({"left" : menuPosizione})
$('#home, #chi, #cosa, #portfolio, #contatti, #usermessage2').css({"left" : -contentPosizione});

//$('#home, #chi, #cosa, #portfolio, #contatti').append('<p class="logo"><a href="#home"></a></p>');


//----------------------------- scrolTo ----------------------------- //
var $panels = $('#content > .inside > div');
var $container = $('#content > .inside');

var horizontal = true;

// float the panels left if we're going horizontal
if (horizontal) {
  $panels.css({
    'float' : 'left',
    'position' : 'relative', // IE fix to ensure overflow is hidden
    'width' : '1950px'
  });
  
  // calculate a new width for the container (so it holds all panels)
  $container.css('width', $panels[0].offsetWidth * $panels.length);
}
var $scroll = $('#content').css({"overflow" : "hidden"});

var scrollOptions = {
  target: $scroll,
  items: $panels,
  navigation: 'menu a',
  axis: 'x',
  onAfter: trigger,
  offset: contentPosizione,
  duration: 500,
  easing: 'swing'
};

$('#content').serialScroll(scrollOptions);

$.localScroll(scrollOptions);
scrollOptions.duration = 1;
$.localScroll.hash(scrollOptions);

//HEADER
/*var headerLinks = $("#header p a");
headerLinks.wrapAll("<div></div>")
headerLinks.eq(0).addClass('client');

//working with login inputs  
  $("#header fieldset form input:text, #header fieldset form input:password ").click(function() {
    $(this).attr({value: ""});
  });
  
  //showing and hidding login
  $("#header p a.client").click(function(){
      if ($("#header fieldset form").is(':hidden'))
          $("#header fieldset form").show();
      else{
          $("#header fieldset form").hide();
      }
      return false;
  });

  $('#header fieldset form').click(function(e) {
      e.stopPropagation();
  });
  
  $(document).click(function() {
      $('#header fieldset form').hide();
  });
*/
//HP
/*var hpText = $("#home p").not('p.logo');
hpText.wrapAll('<div class="intro"></div>');
var hpAnimace = $('#home div.intro');

hpAnimace.hover (
  function () {
    $(this).animate({fontSize: '100%'}, 200).css({cursor : 'text', color : '#222'})
    .find('strong').animate({fontSize: '120%', marginLeft: '1px', marginRight: '1px'}, 200);
  },
  function () {
    $(this).animate({fontSize: '70%'}, 200).css({cursor : 'text', color : '#444'})
    .find('strong').animate({fontSize: '100%', marginLeft: '0px', marginRight: '0px'}, 200);
  }
);
*/
//ABOUT US
/*$('#chi h3:first, #chi ul:first').wrapAll('<div class="left"></div>');
$('#chi h3:last, #chi ul:last').wrapAll('<div class="right"></div>');
*/
//PORTFOLIO
/*var folioLink = $("#portfolio blockquote a");

folioLink.hover(
  function() {
    $(this).append('<em></em>');
  }, 
  function () {
    $(this).find('em').remove();
  }
);
*/

//FOOTER
//$('#footer ul, #footer p').wrapAll('<div class="holder"></div>');

//end - Ludek part

//Bulda
/*$('div#portfolio a.previous, div#portfolio a.next').live('click', function() {
    $('div#portfolio a.previous, div#portfolio a.next').hide();
    var urlko = $(this).attr('href')+"&ajax=true";
    $.ajax({type:"GET", async:true, url: urlko, success: function(html){
        $('#portfolio .inside').html(html);
    }});
   
        return false;
})*/

if (dal_progetto) vmedia();

});
// -------- end of jQuery document.ready() ---------- //

function vmedia() {
    $('.m2 a').addClass('selected');
	$('#content').scrollTo({left:3900});
}
