/* Author:

*/

$(function(){
	
	if($.browser.msie && $.browser.version < 7)
  {
    $('.lines').hide();
  }

	function resize()
	{
		var winWidth = $(window).width();

		if(winWidth <= 1220)
		{

			$('#main').width(960);

			$('#content-wrap').css('margin-left','0');

			$('#buttons .box').width(300);
  			$('.box1').stop().animate({
   				top:810,
   				left:-920
  			}, 1000);

  			$('.box2').stop().animate({
   				top:810,
   				left:-610
  			}, 1000);

  			$('.box3').stop().animate({
   				top:810,
   				left:-300
  			}, 1000);

        $('footer').stop().animate({
          'margin-top':280,
          'margin-left':0
        }, 1000); 

		}

		else if(winWidth > 1220)
		{
			
			var buttonWidth = (winWidth - 920 - 90);

			$('#content-wrap').css('margin-left','40px');

			$('.box1').stop().animate({
   				top:0,
   				left:10
  			}, 1000);

  			$('.box2').stop().animate({
   				top:270,
   				left:10
  			}, 1000);

  			$('.box3').stop().animate({
   				top:540,
   				left:10
  			}, 1000);
  			
        
        $('footer').stop().animate({
          'margin-top':20,
          'margin-left':40
        }, 1000); 
  				

  			if(buttonWidth <= 260)
  			{
  				$('#buttons .box').width(260);
  			}
  			else if(buttonWidth >= 385)
  			{
  				$('#buttons .box').width(385);
  			}
  			else
  			{
  				$('#buttons .box').width(buttonWidth);
  			}
  			  			
  			var mainWidth = 970 + $('#buttons div').width();
  			$('#main').width(mainWidth);
		}
	}

	resize();

	$(window).resize(function(){
		resize();
	})

  $('#images').cycle({ 
    fx:       'fade', 
    random:   1,
    timeout:  7000
  });


	$('#show-btn img').click(function(){
		$('#show').fadeOut(300);
    $('#content').fadeIn(300);
	});

  $('#hide').click(function(){
    $('#show').fadeIn(300);
    $('#content').fadeOut(300);
  });

  var pulled = true;

  $('#pull img').not('#hide').attr('src','images/buttons/hide.png');

  $('#pull img').click(function(e){
    
    e.preventDefault();

    if(pulled == false)
    {
      $('.nav').animate({
        'height': 175,
        'padding-top': 18,
        'padding-bottom': 18

      },500, function(){
         
         $('#pull img').attr('src','images/buttons/hide.png');
         pulled = true;
      });
    }
    else
    {
      $('.nav').animate({
        'height': 0,
        'padding-top': 0,
        'padding-bottom': 0

      },500, function(){
        $('#pull img').attr('src','images/buttons/pull.png');
         pulled = false;
      });
    }

  });

  $('#left-arrow').click(function(){
    
    $('#images').cycle('prev');

  })

  $('#right-arrow').click(function(){
    
    $('#images').cycle('next');

  })

  $("a.iframe").fancybox({
    'transitionIn'  : 'elastic',
    'transitionOut' : 'elastic',
    'width'   : 640, 
    'height'    : 600
  });

  $("nav a.iframe").fancybox({
    'transitionIn'  : 'elastic',
    'transitionOut' : 'elastic',
    'width'   : 400, 
    'height'    : 400
  });
  //$("ul.gallery a").attr("rel", "photos");
  $("ul.gallery a").fancybox();

})






