$(document).ready(function(){						   
	homeBoxHeight();
	clearPostBoderbtm();
	showGoTop();
	portfolio();
	$("img").lazyload({         
     effect      : "fadeIn"
	});
	contactForm();
})

function homeBoxHeight(){	
	if ($('div').hasClass('home-box')){
		var max = null;
		
		$('.home-box').each(function(){	
			if ( !max || max.height() < $(this).height() )
  			 max = $(this);
		});
		$('.home-box').each(function(){
			$(this).css({'height':max.height()});									 
		});		
	}
}

function clearPostBoderbtm(){
	if ($('div').hasClass('post')){
		$('.post:last').css({'border-bottom':0, 'margin-bottom':0});
	}
	if($('div').hasClass('portfolio-post')){
		$('.portfolio-post:last').css({'border-bottom':0, 'margin-bottom':0});
	}
}

function portfolio(){
	if($('div').hasClass('folio-image')){
		$('.folio-image img').css({'opacity':0.7});
		$('.folio-image img').each(function(index){
			$(this).hover(
			  function () {
				$(this).animate({opacity:1},300);
			  }, 
			  function () {
				$(this).animate({opacity:0.7},300);
			  }
			);
												   
		});
	}
}

function showGoTop(){
	//$wHeight = $(window).height();   
    $top = $('.to-top');
    $top.hide();
    $(window).scroll(function(){
        $sHeight = $(window).scrollTop();
        $('.temp').html($sHeight);
        if($sHeight > 300){
            $top.fadeIn('slow');
			$top.click(function(){
				$('html, body' ).stop().animate({scrollTop:0}, 400);								
			})
        }
        else{
            $top.fadeOut('slow');
        }
    });
}

function contactForm(){
	$('form.wpcf7-form input.name').attr('title','Please write your name here.');
	$('form.wpcf7-form input.email').attr('title',"Please give me your email addres to reply your inquiry.");
	$('form.wpcf7-form input.subject').attr('title',"Please write subject here.");
	$('form.wpcf7-form textarea.message').attr('title',"Any inquriy? please write here.");
	
	$('form.wpcf7-form :input').tooltip({

		// place tooltip on the right edge
		position: "center right",
	
		// a little tweaking of the position
		offset: [8, 10],
	
		// use the built-in fadeIn/fadeOut effect
		effect: "slide",
	
		// custom opacity setting
		opacity: 0.7,
		
		events: {
		input: 'mouseenter,mouseleave'
	}

	});
}
