$(document).ready(function(){
  // get height for work
  var work = $(".work-large").height();
  //$("#work").css("height",work);
  //$(".work-large").css("height",work);
  //$("#main-content").css("height",work);
  
  //var worksidebar = $("#work-sidebar").height();
  //$("#work-sidebar").css("height",worksidebar);

	// home DP fade in
  $(".home #logo").hide();
  $(".home #logo").fadeIn(3000);
		
	// hovers for portfolio
  $(".thumb-container").hover(function(){
		$(this).children("div.thumb-bg").fadeTo("fast", 0); // This should set the opacity to 0% on hover
		$(this).children("div.thumb-type").fadeTo("fast", 1.0);
		},function(){
		$(this).children("div.thumb-bg").fadeTo("fast", 1.0); // This should set the opacity back to 100% on mouseout
		$(this).children("div.thumb-type").fadeTo("fast", 0);
	});
    
  $('#main-jq').cycle({ 
    fx: 'scrollHorz', 
    speed: 'fast',
    next:   '#left', 
    prev:   '#right',
    pager:  '#cycle-nav',
    timeout: 9000,
    cleartype: true, 
    cleartypeNoBg: true
	});
	
	$('#main-jq-experience').cycle({ 
    fx: 'scrollHorz', 
    speed: 'fast',
    next:   '#left', 
    prev:   '#right',
    pager:  '#cycle-nav',
    timeout: 30000,
    cleartype: true, 
    cleartypeNoBg: true
	});
	
	$('.banner').cycle({ 
    fx: 'scrollHorz', 
    speed: 'fast',
    next:   '.experience-left-arrow', 
    prev:   '.experience-right-arrow',
    timeout: 9000,
    cleartype: true, 
    cleartypeNoBg: true
	});
	
	$('.about-image-holder').cycle({ 
    fx: 'scrollHorz', 
    speed: 'fast',
    next:   '#left-about', 
    prev:   '#right-about',
    pager:  '#about-cycle-nav',
    timeout: 9000,
    cleartype: true, 
    cleartypeNoBg: true
	});
	
  // portfolio catgegory choices
  $(".categories").click(function() {
    var id_cat = $(this).attr("rel"); 
    $(this).attr("rel"); 
    window.location = "/portfolio/?cat_id=" + id_cat;
  });
    
  // next previous for viewing work
  var workId = 1;
    
  $(".next").click(function() {
    var id_work = $(this).attr("rel");
    var id_work_int = parseInt(id_work); 
    window.location = "/work/?id=" + (id_work_int + workId);
  });
    
  $(".previous").click(function() {
    var id_work = $(this).attr("rel");
    var id_work_int = parseInt(id_work);  
    window.location = "/work/?id=" + (id_work_int - workId);
  });
  
  // case studies
  $('.case-study-list').hide();
  $('.show-case-study-list').hover(function() {
    clearTimeout($(this).data('timeout'));
    $("ul",this).slideDown("fast");
  }, function() {
    var hover = $("ul",this);
    var t = setTimeout(function() {
      $(hover).slideUp("fast");
    }, 200);     
    $(this).data('timeout', t);
    });
    
  // portfolio catgegory choices
  $(".show-case-study").click(function() {
    var id_case = $(this).attr("id"); 
    $(this).attr("id"); 
    window.location = "/case-studies/?case_id=" + id_case;
  });
  
  // blog stuff
  $(".add-comment").toggle(function() {
    $(".add-comment-form").slideDown();
    return false;
  }, function(){
	$(".add-comment-form").slideUp(function(){
		$(".add-comment-form").hide();
	});
    return false;
  }); 
  
  // comment form submit
  $(".submit-comment").click(function() {   
     var name = $("input#comment-name").val();  
	   var email = $("input#comment-email").val();  
     var comment = $("textarea#comment-comment").val();
     var parent_id = $(this).attr("rel");  
     
     var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment + '&parent_id=' + parent_id;  
      $.ajax({  
       type: "POST",  
       url: "/blog-comments.php",  
       data: dataString, 
       success: function(data) { 
         $('.add-comment-form').slideUp(function(){
            $('.current-comments').prepend('<div class="individual-comment"><h1>'+ data.name + ' says:</h1><p>'+ data.comment +'</p><p class="comment-date">Commented on ' + data.date + '</p></div>').fadeIn(1500, function(){
              $('input#comment-name, input#comment-email, textarea#comment-comment').val('');
            }); 
         });
       }  
      });  
      return false;            
    });
    
    // show individual post
    $(".blog-title, .read-more").click(function() {
      var id = $(this).attr("rel"); 
      $(this).attr("rel"); 
      window.location = "/blog/?id=" + id;
    });
    
    $(".post:last").removeClass("border");
    
});         