var slides = {};
$(function( $ ){
  if($('.slider').length > 0){
    $('.slider').width('');
    $('.slider li').width(jQuery('.slider').width());
    jQuery('.slide1_content').height(jQuery('.slider').height());

    slides['rest'] = 1;
    slides['lake'] = 2;
    slides['houses'] = 0;
        
    $('.slider').serialScroll({
      target:'#sections',
      items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
      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)
      start: 1, // On which element (index) to begin ( 0 is the default, redundant in this case )
      cycle:false,// 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 )
      onBefore:function( e, elem, $pane, $items, pos ){
        $('.modal_window').hide();
      }
    });

    var m = document.location.toString().match(/#(.+)/);

    if(m && slides[m[1]] != undefined){
      $('#sections').trigger( 'goto', [ slides[m[1]] ] );
    }
  }
});

function openDialogWindow(id){
  $('#'+id+'_description').css('position','absolute');

  var top = 0;
  if($.browser.opera){
    var for_opera = {
      'fresh_air': 132,
      'nature': 425,
      'water':285,
      'forest':212,
      'rest':300
    }
    top = for_opera[id];
  }else{
    top = $('#'+id).offset().top;
  }

  if(id == 'fresh_air'){
    top = top+29;
  }

  $('#'+id+'_description').css('top',top);
  $('#'+id+'_description').css('left',$('#'+id).offset().left);
  $('#'+id+'_description').show('slow');
  return false;
}

function closeDialogWindow(id){
  $('#'+id+'_description').hide('slow');
  return false;
}
