﻿var timesClicked = 0;
var projectsAmount;

$(function() {    
  // find all the input elements with title attributes
  if('input[title!=""]' != 'undefined'){
    $('input[title!=""]').hint();
  }
  
  projectsAmount = $('#slider_wrapper .project_wrapper').size();
  //alert(projectsAmount);
  var projectsWidth = projectsAmount * 234;
  $('#slider_wrapper').css('width', projectsWidth);
  
  $('#arrow_left').click(function() {
      $("#slider_wrapper").animate({
        "margin-left": "+=234px"
      }, 500, "linear", function() {
      // Animation complete.
      });
      
      --timesClicked;
      showHideArrows();
  });
  
  if (projectsAmount < 4) {
    var arrr = document.getElementById('arrow_right');
	if (arrr != undefined) {
		arrr.style.display = 'none';
	}
  }
  
  $('#arrow_right').click(function() {
      $("#slider_wrapper").animate({
        "margin-left": "-=234px"
      }, 500, "linear", function() {
      // Animation complete.
      });
      
      ++timesClicked;  
      showHideArrows();
  });
});

function showHideArrows(){
  if(timesClicked <= 0){
      $('#arrow_left').addClass('display_none');
      $('#arrow_left_wrapper').addClass('cursor_none');
    }else if(timesClicked >= projectsAmount - 3){
      $('#arrow_right').addClass('display_none');
      $('#arrow_right_wrapper').addClass('cursor_none');
    }else{
        $('#arrow_left').removeClass('display_none');
        $('#arrow_right').removeClass('display_none');
        $('#arrow_left_wrapper').removeClass('cursor_none');
        $('#arrow_right_wrapper').removeClass('cursor_none');
    }
}

function DoNav(theUrl){
    document.location.href = theUrl;
}

function ChangeColor(tableRow, highLight)
    {
    if (highLight)
    {
      tableRow.style.color = '#d1482a';
    }
    else
    {
      tableRow.style.color = '#2463B4';
    }
  }

