
function pscroll_arrow_check(left) {
  if(left >= 0){
    // hide left arrow
    $(".pscroll-left").hide();
    $(".pscroll-right").show();

  } else if(left <= -3100) {
    //hide right arrow
    $(".pscroll-right").hide();
    $(".pscroll-left").show();
  } else {
    $(".pscroll-right").show();
    $(".pscroll-left").show();
  }
}

$(document).ready(function(){


  $(".pscroll li ul li a").each(function(){
    var w = $(this + " img").css("width")
    $(this + " .pcaption").css("width", w);
  });


  var left = parseInt($(".pscroll").css('left'), 10);
  pscroll_arrow_check(left);

  $("#pscroll-right").click(function() {
    var $mover = $(".pscroll");
    $mover.animate({
      left: '-=640'
    },
    {
      duration: '3000',
      easing: 'easeOutSine',
      complete: function() {
        pscroll_arrow_check(parseInt($mover.css('left'),10));
      }
    });

    

  });

  $("#pscroll-left").click(function() {
    var $mover = $(".pscroll");
    $mover.animate({
      left: '+=640'
    },
    {
      duration: '3000',
      easing: 'easeOutSine',
      complete: function() {
        pscroll_arrow_check(parseInt($mover.css('left'),10));
      }
    });
  });






  //set left nav active location
  var template = getCurrentTemplate();
  
  //set meta tag for work pages
  
var metas = [
{name:'avalon',val: 'shore_house'},
{name:'body_iq_lifestyle_center',val: 'pilates_yoga_studio'},
{name:'center_city_law_office',val: 'law_office'},
{name:'english_village',val: 'garden_room'},
{name:'fairmount_avenue',val: 'corridor_revitalization'},
{name:'fairmount',val: 'house_renovation'},
{name:'imperial_theater',val: 'theater_reuse'},
{name:'gwynedd_valley',val: 'house_addition'},
{name:'mdp_master_plan',val: 'campus_planning'},
{name:'mdp_parish_center',val: 'educational_architecture'},
{name:'mesa_development',val: 'residential_developer'},
{name:'murano',val: 'condominium_renovation'},
{name:'narberth',val: 'house_addition'},
{name:'riverpark',val: 'rowhouse_renovation'},
{name:'tria_fermentation_school',val: 'interior_design'},
{name:'ubatuba',val: 'sustainable_house'},
{name:'venice_bridge_museum',val: 'museum'}
];


for (var i = 0; i < metas.length; i++) {
	if (template == metas[i].name) {
		$('title').before('<meta name="keywords" content="'+metas[i].val+'" />');
	}
}


  var uri = getCurrentUri();

  $(".sf-menu .subnav-list li").each(function(){
    $(this).removeClass("active");
    if($(this).attr("id") == template) {
      // var me = $(this).attr("id");
      //console.log(me + " is active");
      $(this).addClass("active");
    }
  });

  $(".subnav li").each(function(){
    $(this).removeClass("active");
    var mypath = $(this).attr("id");

    if($(this).attr("id") == template)  {
      // var me = $(this).attr("id");
      //console.log(me + " is active");
      $(this).addClass("active");
    }
  });

//handle oddball profile page 2 edge case
  if(template == "profile_page2") {
      $("#profile").addClass("active");
  }


  $(".sf-menu li").each(function() {
    $(this).removeClass("active");
    var t = $(this).attr("id");
    if(uri.indexOf(t) != -1){
      $(this).addClass("active");
    }
  });


  // console.log("uri: " + uri);
  // console.log("template: " + template);
  if(uri.indexOf("about") != -1){
     // console.log("about");
    //$("#work ul").hide();
    $("#work").removeClass("active");
    $("#about").addClass("active");
  }

  if(uri.indexOf("work") != -1 ){
   // $("#about ul").hide();
    $("#about").removeClass("active");
    $("#work").addClass("active");
    $("#work a:first").css("color", "#7f7e14");

  } else {

  }




  /* publications scroller */
  $(".pscroll-left, .pscroll-right").hover(function() {
    $(this).css("cursor","pointer")
  }, function() {
    $(this).css("cursor","default")
  })






});
