function goToByScroll(id){
		if (id =='about1'){
			var whereTo = $('article#intro').height()+$("#"+id).offset().top-20;
			$('html,body').animate({scrollTop: whereTo},'slow');
			}else{
	     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
		}
}
function onloadReset(){
		$('#submitform').ajaxForm({
			target: '#error',
			success: function() {
			$('#error').fadeIn('slow');
			}
		});
}
function checkIfSent(){
	if ($('#success').is(":visible") == true){alert('visible');}	
}
function getMinHeight(){
	var winW = (($(window).width()-1000)/2);
		$('nav').css('left', winW);
	var minH =  $(window).height();
	
		if ($('section#contact').height()<minH){
			$('section#contact').height(minH);
		}
		if ($('section#portfolio').height()<minH){
			$('section#portfolio').height(minH);
		}
		if ($('section#about').height()<minH){
			$('section#about').height(minH);
		}
}
function attachEventHandlers(){
	$('nav span, .cloud p').delegate('a','click', function(event) {
		var id = $(this).attr("title");
		goToByScroll(id);
	});	
	
	$(window).resize(function() {
		getMinHeight();
	});
	$('a#magic').mouseover(function() {
		$(this).text('Jquery');
		$(this).addClass('jq');
  	}).mouseout(function(){
		$(this).text('magic');
		$(this).removeClass('jq');
  	});
	$('span#thisGuy').mouseover(function() {
		$('#arrow').show();
  	}).mouseout(function(){
		$('#arrow').hide();
  	});
}
$(document).ready(function() {
	$('body').fadeIn(2000).show("slide", {direction:"left"}, 2000);

	
	checkIfSent();
	getMinHeight();
	onloadReset();
    attachEventHandlers();
    $().UItoTop({ easingType: 'easeOutQuart' });
});
