$(document).ready(function() { 
//player movement and fade controls
function showControls(){
$('#video_box').hover(
	function(){
		$('#controls').stop(true,true).fadeIn();
	}, 
	function () {
	$('#controls').stop(true,true).fadeOut();
	});
	}
	
$('#play2,.posterImage').live('click',function(){
	$(this).stop(true,true).fadeOut();
	$('.posterImage').fadeOut();
	jwplayer("video").play();

});
$('#controls').fadeOut();

$('#play2').hover(
function () {
$('.playBackground').stop(true,true).animate({ opacity: ".5" }, "medium");
},
function () {
$('.playBackground').stop(true,true).animate({ opacity: ".0" }, "medium");
}); 


// contact handle
$('.contactTab, .contactTabHover').bind('click', function(){
	$('.contactOpen').stop(true,true).slideDown();
	$('.contactLogo').stop(true,true).fadeIn(function(){
	$('.contactX').stop(true,true).slideDown();
	});
});
$('.contactXhover, .contactX').bind('click', function(){
	$('.contactX').stop(true,true).slideUp();
	$('.contactOpen').stop(true,true).slideUp();
	$('.contactLogo').stop(true,true).fadeOut();
});
$('.contactTab').bind('mouseenter',
function(){
	$('.contactTabHover').stop(true,true).fadeIn();
	}); 
	$('.contactTabHover').bind('mouseleave',
function(){
	$('.contactTabHover').stop(true,true).fadeOut();
	}); 
	
	$('.contactX').bind('mouseenter',
function(){
	$('.contactXhover').stop(true,true).fadeIn();
	}); 
	$('.contactXhover').bind('mouseleave',
function(){
	$('.contactXhover').stop(true,true).fadeOut();
	}); 


//------------------------slider video slider
$('.slideContent ul li:first').before($('.slideContent ul li:last'));
	$('.slideContent ul').css({'left' : -117});
$('.slideRight').live('click',function(){
	
		var left_indent = parseInt($('.slideContent ul').css('left')) - 117;
		$('.slideContent ul').stop(true,true).animate({'left' : left_indent}, 600, 'easeInOutQuint',  function () {
		$('.slideContent ul li:last').after($('.slideContent ul li:first'));
		$('.slideContent ul').css({'left' : -117});
		});
		return false;
});
$('.slideLeft').live('click',function(){
	var left_indent = parseInt($('.slideContent ul').css('left')) + 117;
		$('.slideContent ul').stop(true,true).stop(true,true).animate({'left' : left_indent}, 600, 'easeInOutQuint', function(){
		$('.slideContent ul li:first').before($('.slideContent ul li:last')); 
		$('.slideContent ul').css({'left' : -117});
		});
		return false; 
});
//------------------------archive page slider
$('#shade').live('click',function(){
	$("body").css("overflow", "visible");
	jwplayer("video").stop();
	$("#shade").fadeOut();
	$("#vidPlay").animate({'marginLeft':'-2335'});
});
$('li.archiveVideo').hover(
  function () {
    $(this).find(".vidInfo").stop(true,true).animate({'top': 85});
  },
  function () {
    $(this).find(".vidInfo").stop(true,true).animate({'top': 128});
  });
$('li.archiveVideo').live('click', function(){

	var index3 = $(this).find('.vidHandle2').attr('name');
	var index2 = parseInt(index3);
	var playItem = index2 -1;
	var title = $(this).find('.vidHandle2').attr('title');
	var image = $(this).find('.vidHandle2').attr('rel');
	$('.posterImage img').attr('src', image);
	$('.playTitle a').html(title);
//	$("body").css("overflow", "hidden");
	jwplayer("video").playlistItem(playItem);
	jwplayer("video").stop();
	hideStuff();
	//$('#play2').fadeIn();
	
	});
function hideStuff(){
$('#vidPlay').animate({'marginLeft':'-335'});

$('#shade').fadeIn();
$('#play2, .posterImage').fadeIn();
}
//------------------------slider video switch
	$('.slideContent li').live('click', function(){
	var index3 = $(this).find('.vidHandle').attr('name');
	var index2 = parseInt(index3);
	var index = index2 -1;
	var title = $(this).find('.vidHandle').attr('title');
	var image = $(this).find('.vidHandle').attr('rel');
	
	$('#play2').fadeIn();
	$('.playTitle a').html(title);
	$('.posterImage img').attr('src', image);
	$('.posterImage').fadeIn();
	jwplayer().playlistItem(index);
	});
	$('.slideContent li').hover(
  function () {
    $(this).find(".tabTitle").stop(true,true).animate({marginTop:'-99'}, 600, 'easeInOutQuint');
  },
  function () {
    $(this).find(".tabTitle").stop(true,true).animate({marginTop:'0'}, 600, 'easeInOutQuint');
  });
//------------------------contact switch
$(".contactTrig").scrollToTop();

	$('.contactTrig').live('click', function(){
	$('.contactTab').trigger('click');
	});
$('.logoLink').live('click', function() {
window.location = '/'
return false;
});
});

