$(document).ready(function() {

      $("#tv").toggle(
      function () {
      	if($('#sub-navigation').is(':visible')){
	      $("#whatwedo").trigger('click');
	      $("#content-left").animate({width: "40%"},0);
	      $("#tv-side").delay(500).show("blind",{direction: "horizontal"},500);
      	}else{
      	  $("#content-left").animate({width: "40%"},0);
	      $("#tv-side").delay(100).show("blind",{direction: "horizontal"},500);
      	}
      },
      function () {
      $("#tv-side").hide("blind",{direction: "horizontal"},500);
      $("#content-left").delay(500).animate({width: "60%"},0);
      }
      );
      
    setTimeout(function() {
    $("#tv").trigger('click');
    },10);
    
    $(".dropdown").toggle(
    function (){
    	$(".dropdownmenu").show("blind",{direction: "vertical"},500);
    },
    function (){
    	$(".dropdownmenu").hide("blind",{direction: "vertical"},500);
    }
    );
	  
      
      $(".vthumb").click(
      function () {
      	  var video = 'test.php?id=' + $(this).attr('name');
	      $("#tv").trigger('click');
	      $("#navigation").animate({marginLeft:"-258px"},500);
	      $("#viewer").delay(800).show("slide",{direction: "right"},500);
	      $("#mediaspace").load(video);
	      return false;
      }
      );
      
      $(".vthumb2").click(
      function () {
      	  var video = 'test.php?id=' + $(this).attr('name');	
	      $("#viewer").delay(800).show("slide",{direction: "right"},500);
	      $("#mediaspace").load(video);
	      return false;
      }
      );
      
      $("#see_all").click(
      function () {
      $('#videos-container').load('all.php?random=' + Math.random()*99999 ); 
      $("#tv").trigger('click');
      $("#navigation").animate({marginLeft:"-258px"},500);
      $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      return false;
      }
      );
      
      $(".close").click(
      function () {
      $("#navigation").delay(800).animate({marginLeft:"0px"},500);
      $("#viewer").hide("slide",{direction: "right"},500);
      $("#tv").delay(800).trigger('click');
      }
      );
      
      $(".closeall").click(
      function () {
      $("#navigation").delay(800).animate({marginLeft:"0px"},500);
      $("#viewer-all").hide("slide",{direction: "right"},500);
      $("#tv").delay(800).trigger('click');
      }
      );
      
      $("#whatwedo").toggle(
      function () {
	      	if($('#tv-side').is(':visible')){
	      		  $("#tv").trigger('click');
	      		  $("#content-left").animate({width: "40%"},0);
			      $("#sub-navigation").delay(500).show("blind",{direction: "horizontal"},500);
			      $(this).parent().addClass("selected").siblings().removeClass("selected");
			      $('#content-left').load('pages/commercialdivision.html');
      	          $("#subnav-commercialdivision").addClass('red');
			      return false;
	      	}else{
			      $("#content-left").animate({width: "40%"},0);
			      $("#sub-navigation").delay(100).show("blind",{direction: "horizontal"},500);
			      $(this).parent().addClass("selected").siblings().removeClass("selected");
			      $('#content-left').load('pages/commercialdivision.html');
      	          $("#subnav-commercialdivision").addClass('red');
	      	}
      	},
      function () {
		      $("#sub-navigation").hide("blind",{direction: "horizontal"},500);
		      $("#content-left").delay(500).animate({width: "60%"},0);
		      return false;
      }
      );
            
      
      $("#whoweare").click(function(){
      	if($('#sub-navigation').is(':visible')){
      	$('#whatwedo').trigger('click');
      	$('#content-left').load('pages/whoweare.html'); 
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	}else{
      	$('#content-left').load('pages/whoweare.html');
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	} 
      }
      );
      
      $("#hww").click(function(){
      	if($('#sub-navigation').is(':visible')){
      	$('#whatwedo').trigger('click');
      	$('#content-left').load('pages/hww.html'); 
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	}else{
      	$('#content-left').load('pages/hww.html');
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	} 
      }
      );
      
      $("#whoweworkwith").click(function(){
      	if($('#sub-navigation').is(':visible')){
      	$('#whatwedo').trigger('click');
      	$('#content-left').load('pages/whoweworkwith.html'); 
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	}else{
      	$('#content-left').load('pages/whoweworkwith.html');
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	} 
      }
      );
      
      $("#wts").click(function(){
      	if($('#sub-navigation').is(':visible')){
      	$('#whatwedo').trigger('click');
      	$('#content-left').load('pages/wts.html'); 
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	}else{
      	$('#content-left').load('pages/wts.html');
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	} 
      }
      );
      
      
      $("#wtc").click(function(){
      	if($('#sub-navigation').is(':visible')){
      	$('#whatwedo').trigger('click');
      	$('#content-left').load('pages/wtc.html'); 
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	}else{
      	$('#content-left').load('pages/wtc.html');
      	$(this).parent().addClass("selected").siblings().removeClass("selected");
      	return false;
      	} 
      }
      );
      
      
      $("#subnav-live").click(function(){
      	$('#content-left').load('pages/live.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-studio").click(function(){
      	$('#content-left').load('pages/studio.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-newmedia").click(function(){
      	$('#content-left').load('pages/newmedia.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-tourservices").click(function(){
      	$('#content-left').load('pages/tourservices.html');
      	$(this).addClass('red').parent().siblings().children().removeClass('red'); 
      	return false;
      }
      );
      
      $("#subnav-graphicsdepartment").click(function(){
      	$('#content-left').load('pages/graphicsdepartment.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-creativeservices").click(function(){
      	$('#content-left').load('pages/creativeservices.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-commercialdivision").click(function(){
      	$('#content-left').load('pages/commercialdivision.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-facilities").click(function(){
      	$('#content-left').load('pages/facilities.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-footagelibrary").click(function(){
      	$('#content-left').load('pages/footagelibrary.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
      $("#subnav-longformprogramming").click(function(){
      	$('#content-left').load('pages/lfp.html'); 
      	$(this).addClass('red').parent().siblings().children().removeClass('red');
      	return false;
      }
      );
      
       $("#see_lfp").click(function(){
      	$('#videos-container').load('specific.php?category=Long-Form%20Programming'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_cp").click(function(){
      	$('#videos-container').load('specific.php?category=Commercial%20Production'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_cs").click(function(){
      	$('#videos-container').load('specific.php?category=Creative%20Services'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_graphics").click(function(){
      	$('#videos-container').load('specific.php?category=Graphics'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_lr").click(function(){
      	$('#videos-container').load('specific.php?category=Live/Remote'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_nm").click(function(){
      	$('#videos-container').load('specific.php?category=New%20Media'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_sp").click(function(){
      	$('#videos-container').load('specific.php?category=Series%20Production'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_studio").click(function(){
      	$('#videos-container').load('specific.php?category=Studio'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#see_ts").click(function(){
      	$('#videos-container').load('specific.php?category=Tour%20Services'); 
      	$("#tv").trigger('click');
        $("#navigation").animate({marginLeft:"-258px"},500);
        $("#viewer-all").delay(800).show("slide",{direction: "right"},500);
      	return false;
      }
      );
      
        $("#cat_lfp").click(function(){
      	$('#videos-container').load('specific.php?category=Long-Form%20Programming'); 
      	return false;
      }
      );
      
        $("#cat_cp").click(function(){
      	$('#videos-container').load('specific.php?category=Commercial%20Production'); 
      	return false;
      }
      );
      
        $("#cat_cs").click(function(){
      	$('#videos-container').load('specific.php?category=Creative%20Services'); 
      	return false;
      }
      );
      
        $("#cat_graphics").click(function(){
      	$('#videos-container').load('specific.php?category=Graphics'); 
      	return false;
      }
      );
      
        $("#cat_lr").click(function(){
      	$('#videos-container').load('specific.php?category=Live/Remote'); 
      	return false;
      }
      );
      
        $("#cat_nm").click(function(){
      	$('#videos-container').load('specific.php?category=New%20Media'); 
      	return false;
      }
      );
      
        $("#cat_sp").click(function(){
      	$('#videos-container').load('specific.php?category=Series%20Production'); 
      	return false;
      }
      );
      
        $("#cat_studio").click(function(){
      	$('#videos-container').load('specific.php?category=Studio'); 
      	return false;
      }
      );
      
        $("#cat_ts").click(function(){
      	$('#videos-container').load('specific.php?category=Tour%20Services'); 
      	return false;
      }
      );
});
