jQuery(document).ready(function($) {

if($('#side_bar').height() > 1231){
	$('#side_bar').css('background-position', 'left top');
}

$('a[title]').add('img[title]').data("title", $(this).attr("title")).removeAttr("title");

$('a[href$=".pdf"] img').add('a[href$=".doc"] img').add('a[href$=".docx"] img').parent('a').addClass('no-icon');

$('#nav li').hover(function(){
	$(this).addClass('hover');
}, function(){
	$(this).removeClass('hover');
});

$('a[rel]').overlay({
	mask: {
		color:'#000000',
		opacity:0.7
	}
	
});

$('#client_form').validate();
$('#billing-same').change(function(){
	if($(this).is(':checked')){
		$('#billing-name').val($('#name').val());
		$('#billing-phone').val($('#phone').val());
		$('#billing-email').val($('#email').val());
		$('#billing-address').val($('#address').val());
		$('#billing-city').val($('#city').val());
		$('#billing-state').val($('#state').val());
		$('#billing-zip').val($('#zip').val());
		$('#billing-address2').val($('#address2').val());
	}
});

var starterContent = $(".item").eq(0).find(".post-info").html();
	var starterLink = $('.item').eq(0).find('.read-more').attr('href');
	$('#scrollInsert .insertContent').html(starterContent);
	$('#scrollInsert .read-more').attr('href', starterLink);
	$('.scrollable').scrollable({
		speed: 1000,
		circular: true,
		easing:"linear",
		onBeforeSeek: function(event, index){
			$('#scrollInsert .insertContent').fadeOut();
		},
		onSeek: function(event, index){
			var newContent = $(".item").eq(index + 1).find(".post-info").html();
			var newLink = $('.item').eq(index + 1).find('.read-more').attr('href');
			$('#scrollInsert .insertContent').html(newContent).fadeIn();
			$('#scrollInsert .read-more').attr('href', newLink);
		}
		
	}).autoscroll({
		interval: 6000
	}).navigator();
						   

$("#content_area_tabs").hide();
$(".tab_button").click(function () {
      $("#content_area_tabs").slideToggle(1000);
    });
    
    
   var clearMePrevious = '';
   
   // clear input on focus
   $('.clearMeFocus').focus(function(){
	if($(this).val()===$(this).attr('title')){
		clearMePrevious = $(this).val();
		$(this).val('');
	}
   });
   
   // if field is empty afterward, add text again
   $('.clearMeFocus').blur(function(){
   	if($(this).val()===''){
   		$(this).val(clearMePrevious);
  	 }
   });
   
   $('a.comment-reply-link').attr('href', '#comments_area');
   
   $('a.comment-reply-link').click(function () {
   		
   		var id = $(this).closest("div").parent("div").attr("id");
   		
   		id = id.replace('comment-', "");
   		
   		$('#comment_parent').val(id);
   		  		
   		var title = $(this).closest("div").parent("div").children('.comment-author').children('cite').html();
  		
   		$('.submit_title').html('Reply to: '+ title);

   		$('#author').focus();
	   	return false;		
   });


});

