$(document).ready(function(){

	var href=$('.video-thumb').attr('href');
	$("#video-frame").attr("src",href);
	$("#video-frame").load();
	
	$('.video-thumb').click(function(event){
		event.preventDefault();
		var href=$(this).attr('href');
		$("#video-frame").attr("src",href);
		
		$("#video-frame").load(function(){
			$("#slide-holder").delay(200).slideDown();
			$.scrollTo("#slide-top",400);
		});
		
	});
	
	var href=$('.image-thumb').attr('href');
	$("#image-frame").html('<img src="'+href+'" />');

	
	$('.image-thumb').click(function(event){
		event.preventDefault();
		var href=$(this).attr('href');
		$("#image-frame").fadeOut(200,function(){
			$(this).html('<img src="'+href+'" />');
			$("#slide-holder").slideDown();
			$.scrollTo("#slide-top",400);
			$(this).fadeIn(200);
		});
		
	});
	
	$('#link-more').click(function(event){
		event.preventDefault();
		slideToggle($('#content-more'));
		/*
		if($('#content-more').is(':visible')){
			$('#content-more').slideUp();
		}else{
			$('#content-more').slideDown();
		}
		*/
		
	});

});

// this is a fix for the jQuery slide effects
function slideToggle(el, bShow){
  var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
  
  // if the bShow isn't present, get the current visibility and reverse it
  if( arguments.length == 1 ) bShow = !visible;
  
  // if the current visiblilty is the same as the requested state, cancel
  if( bShow == visible ) return false;
  
  // get the original height
  if( !height ){
    // get original height
    height = $el.show().height();
    // update the height
    $el.data("originalHeight", height);
    // if the element was hidden, hide it again
    if( !visible ) $el.hide().css({height: 0});
  }

  // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
  if( bShow ){
    $el.show().animate({height: height}, {duration: 250});
	$('#link-more').html("LESS...");
  } else {
    $el.animate({height: 0}, {duration: 250, complete:function (){
        $el.hide();
		$('#link-more').html("MORE...");
      }
    });
  }
}
