$(document).ready(function(){
	initfocus();
	initSlider();
	initcycle();
	initHover();
	Cufon.replace('#main .personal-title h2, #content h2, .bottom-block .box h3, .location h3, .block-box  h3 span.left', { fontFamily: 'Adobe Garamond Pro', hover:true } );
});
$(window).load(function(){
	initHeight($('.block-box'));
	initHeight($('.bottom-block'));
	
});
function initfocus(){
	$("input.form-text").each(function(){
   var _val = $(this).val();
   $(this).focus(function(){
     $(this).addClass('focus')
	if($(this).val()==_val){
     $(this).val('')
}
   });
   $(this).blur(function(){
    $(this).removeClass('focus')
	if($(this).val()==''){
     $(this).val(_val);
    	
	}
   });
  });
  $("textarea").each(function(){
   var _val = $(this).val();
   $(this).focus(function(){
     $(this).addClass('focus')
	if($(this).val()==_val){
     $(this).val('')
}
   });
   $(this).blur(function(){
    $(this).removeClass('focus')
	if($(this).val()==''){
     $(this).val(_val);
    	
	}
   });
  });
}
function initcycle(){
	$('.slider-block').cycle({
		fx:      'scrollHorz',
		prev:    '#prev', 
        next:    '#next', 
		speed:  3000, 
    	timeout:  4000,
		pager: '.nav' 	
	});
	$('.slide-text').cycle({
		fx:      'scrollHorz',
		speed:  4000, 
    	timeout:  4000,
		pager: '.nav-1' 	
	});
	$('.slide-media').cycle({
		fx:      'scrollHorz',
		speed:  4000, 
    	timeout:  4000,
		pager: '.nav-2' 	
	});
	$('.sliders').cycle({
		fx:      'scrollHorz',
		speed:  4000, 
    	timeout:  4000,
		prev:    '.prev', 
        next:    '.next' 
	
	});
}
function initHover(){
	$('ul.menu li').hover(
		function(){ $(this).addClass('hover'); },
		function(){ $(this).removeClass('hover');}	
	);

}
function initHeight(boxes){
	boxes.each(function(){
		setHeight($(this).find(' .bg-box-grad'));
	});	
};
function setHeight(col) {  
	var maxHeight = 0;
	col = $(col);
	col.each(function() {  
	if ($(this).height()==0) {$(this).css('height','auto');}
	   if ($(this).height() > maxHeight) {	
		  maxHeight = $(this).height();
		}
	});
	col.height(maxHeight);
};
function initSlider(){
	$('.block-logo').scrollable({
		size: 6,
		loop: true,
		interval: 4000,
		items: 'ul'
	});
	
}
